Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 28th January 2009, 10:42   #1  |  Link
mikeytown2
Resize Abuser
 
mikeytown2's Avatar
 
Join Date: Apr 2005
Location: Seattle, WA
Posts: 623
Sharpener Testing Script

After watching this video here (Skip to about 19 Min in, the rest of it is kinda boring...)
http://meetthegimp.org/episode-085-geeks-only-really/
I decided to replicate this using the files provided via this link
http://simplefilter.de/en/analysis/contrast.html
http://simplefilter.de/download/SF_C...estkit_RGY.zip

Run Script Below and have fun testing various AviSynth sharpeners!
Code:
#Number of pixels In (1-5)
pixels = 5


#Don't Change
colors = 256 
depth = pixels*2-1
#Gray Bars
BlankClip(1,colors,colors*depth,"YV12",25, color=$000000)
base = mt_lutspa(false, mt_polish("(x%2)?127-(x/2):128+(x/2)"), U=-128, V=-128).PointResize(width*depth, height)
#Gradient
gradient_mask = base.GraMaMa(4, 0, colors*depth, 0, colors*depth)
#Blank Clip
BlankClip(1,colors*depth,colors*depth,"YV12",25, color=$000000)
blank=last
#Red Channel
mtString_red = (depth==3) ? mt_polish("(x%3==0)?255:(x%3==2)?255:0") : \
	(depth==5) ? mt_polish("(x%5==0)?255:(x%5==2)?255:(x%5==4)?255:0") : \
	(depth==7) ? mt_polish("(x%7==0)?255:(x%7==2)?255:(x%7==4)?255:(x%7==6)?255:0") : \
	(depth==9) ? mt_polish("(x%9==0)?255:(x%9==2)?255:(x%9==4)?255:(x%9==6)?255:(x%9==8)?255:0") : \
	mt_polish("0")
red = mt_lutspa(false, mtString_red, U=-128, V=-128)
#Green Channel
mtString_green = (depth==3) ? mt_polish("(x%3==1)?255:0") : \
	(depth==5) ? mt_polish("(x%5==1)?255:(x%5==2)?255:(x%5==3)?255:0") : \
	(depth==7) ? mt_polish("(x%7==1)?255:(x%7==2)?255:(x%7==3)?255:(x%7==4)?255:(x%7==5)?255:0") : \
	(depth==9) ? mt_polish("(x%9==1)?255:(x%9==2)?255:(x%9==3)?255:(x%9==5)?255:(x%9==6)?255:(x%9==7)?255:0") : \
	mt_polish("0")
green = mt_lutspa(false, mtString_green, U=-128, V=-128)
#Blue Channel
mtString_blue = (depth==7) ? mt_polish("(x%7==3)?255:0") : \
	(depth==9) ? mt_polish("(x%9==3)?255:(x%9==4)?255:(x%9==5)?255:0") : \
	mt_polish("0")
blue = 	mt_lutspa(false, mtString_blue, U=-128, V=-128)
#RGB Channel - Color Mask
rgy_color_mask = MergeRGB(red, green, blue)

base
##########################
#Test Your Sharpener Here#
##########################
LimitedSharpenFaster()

##########################
#End of Sharpener Area   #
##########################
Overlay(last, gradient_mask, mode="difference", pc_range=true)
Levels(129,128,0,0,255,false)
(Depth==1) ? last : Overlay(rgy_color_mask, last, mode="multiply", pc_range=true)

PointResize(width,512).Spline64Resize(512,512).Levels(0,4,255,0,255)
GraMaMa() - http://www.geocities.com/wilbertdijkhof/
mt_***() - http://avisynth.org/mediawiki/MaskTools2

Here's LSF Output (yes it's not all black - click on the thumbnail)


EDIT:
Use this to test about any function... DeHalo, Resize, Blur, ect...

EDIT:
Thanks J_Darnley for using masktools!

EDIT:
Using Better Colors -Cyan & Magenta
Better resize for high pixel count - Easier to read, still gets the idea across.

Last edited by mikeytown2; 2nd February 2009 at 10:04.
mikeytown2 is offline   Reply With Quote
Old 28th January 2009, 13:10   #2  |  Link
*.mp4 guy
Registered User
 
*.mp4 guy's Avatar
 
Join Date: Feb 2004
Posts: 1,350
try lsf with:

limitedsharpenfaster(smode=4, ss_y=1, ss_x=1, overshoot=0, strength=80)

That should more accurately reflect the performance of limitedsharpen's underlying principles.

I would like to play around with this, but I have an old version of the GIMp which won't wok with that stuff, and I'm not willing to update it.
*.mp4 guy is offline   Reply With Quote
Old 28th January 2009, 13:44   #3  |  Link
J_Darnley
Registered User
 
J_Darnley's Avatar
 
Join Date: May 2006
Posts: 959
I think you could generate them with some mt_lutspa and MergeRGB
rgycolourmask goes: red, green, yellow, green, red, repeat

To generate testimage:
Code:
mtString = mt_polish("(x%2)?127-(x/2):128+(x/2)")
mt_lutspa(false, mtString, U=-128, V=-128)
PointResize(width*5, height)
With mt_lutspa getting a 256px wide video gets you all of testimage (height doesn't really matter for vertical stripes).

To generate rgycolourmask:
Code:
mtString_red = mt_polish("(x%5==0)?255:(x%5==2)?255:(x%5==4)?255:0")
red = mt_lutspa(false, mtString_red, U=-128, V=-128)

mtString_green = mt_polish("(x%5==1)?255:(x%5==2)?255:(x%5==3)?255:0")
green = mt_lutspa(false, mtString_green, U=-128, V=-128)

MergeRGB(red, green, blank)
P.S. *.mp4 guy, do you mean you can't open the image with gimp or are some of the features used missing from your version?
And here is your lsf suggestion: http://users.telenet.be/darnley/avisynth/test-lsf-1.png

And so for completeness:
Code:
BlankClip(1500,256,1280,"YV12",25, color=$000000)
base = mt_lutspa(false, mt_polish("(x%2)?127-(x/2):128+(x/2)"), U=-128, V=-128).PointResize(width*5, height)

gradient_mask = base.GraMaMa(4, 0, 1280, 0, 1280)

BlankClip(1500,1280,1280,"YV12",25, color=$000000)
mtString_red = mt_polish("(x%5==0)?255:(x%5==2)?255:(x%5==4)?255:0")
red = mt_lutspa(false, mtString_red, U=-128, V=-128)
mtString_green = mt_polish("(x%5==1)?255:(x%5==2)?255:(x%5==3)?255:0")
green = mt_lutspa(false, mtString_green, U=-128, V=-128)
rgy_color_mask = MergeRGB(red, green, last)

base
#Test Your Sharpener Here
limitedsharpenfaster(smode=4, ss_y=1, ss_x=1, overshoot=0, strength=80)

Overlay(last, gradient_mask, mode="difference", pc_range=true)
Levels(129,128,0,0,255,false)
Overlay(rgy_color_mask, last, mode="multiply", pc_range=true)
__________________
x264 log explained || x264 deblocking how-to
preset -> tune -> user set options -> fast first pass -> profile -> level
Doom10 - Of course it's better, it's one more.

Last edited by J_Darnley; 28th January 2009 at 15:18.
J_Darnley is offline   Reply With Quote
Old 28th January 2009, 15:05   #4  |  Link
*.mp4 guy
Registered User
 
*.mp4 guy's Avatar
 
Join Date: Feb 2004
Posts: 1,350
It opens, but there is no way for me to select the layers. Thanks for your help, I was able to test lsf with the settings I suggested, and it indeed, does nothing.
*.mp4 guy is offline   Reply With Quote
Old 1st February 2009, 11:09   #5  |  Link
mikeytown2
Resize Abuser
 
mikeytown2's Avatar
 
Join Date: Apr 2005
Location: Seattle, WA
Posts: 623
@J_Darnley
Nice Work! Going to play around with MaskTools now...

EDIT: Done playing check the first post.
Sorta generalized it.
Code:
level 5 - RGYCMCYGR
level 4 -  RGYCYGR
level 3 -   RGYGR
level 2 -    RGR
level 1 -     W

Last edited by mikeytown2; 2nd February 2009 at 10:04.
mikeytown2 is offline   Reply With Quote
Old 2nd February 2009, 02:09   #6  |  Link
MadRat
Registered User
 
MadRat's Avatar
 
Join Date: Jan 2008
Posts: 110
Thanks mikeytown2, this is just what I was looking for.
MadRat is offline   Reply With Quote
Old 2nd February 2009, 06:16   #7  |  Link
Jeremy Duncan
Didée Fan
 
Jeremy Duncan's Avatar
 
Join Date: Feb 2006
Location: Canada
Posts: 1,079
I caN get the patten and put a sharpener in there, but I can't be multiple colored lines in there and I don't know what those colored lines represent.
i tried to get it going to colored lines for close to a hour now and I'm tired and need to rest.

Jeremy Duncan is offline   Reply With Quote
Old 2nd February 2009, 09:19   #8  |  Link
mikeytown2
Resize Abuser
 
mikeytown2's Avatar
 
Join Date: Apr 2005
Location: Seattle, WA
Posts: 623
2 Things that are important:
  1. Imputing the test code in the right place
  2. Knowing what the colored lines mean & the Pixel Level

1.
thats the easy part

2.
level _n_ - The "radius/width" of the vertical lines is _n_px.
M=Magenta
R=Red
G=Green
Y=Yellow
C=Cyan
Code:
level 1 -     M
level 2 -    RGR
level 3 -   RGYGR
level 4 -  RGYCYGR
level 5 - RGYCMCYGR
So Level 2 the test "pattern" is a total of 3px wide, level 3 is 5px wide.

At Level 5: (9px wide)
Red: first pixel on either side, right on the edge. -Edge Sharpness/Contrast
Green: second pixel in from the edge. - Edge Sharpness/Halo
Yellow: third pixel in from the edge. - Halo/Edge Sharpness
Cyan: forth pixel in from the edge. - Halo
Magenta: fifth pixel in from the edge. - Halo
It lets you know how deep in from the edge the sharpener works. The more advanced/potentially stronger ones reach deeper into the stack. Example: if the Yellow line is more vertical then the Red line, then you get halos (means the center's contrast is increasing more then the edge).


The more vertical the line is, it's more sharp. The more horizontal the line is, it's less sharp. 45 degree angle is untouched - "generally" what u want deeper in the stack: less halos in general. Watch the video (on the first post) in it's entirety if you still have questions... or play around by giving this script different inputs. Also disable the Levels() and/or the last Overlay() to play see this before mid stream.

An Interesting Example is SeeSaw - It effects all levels.
Code:
a=FFT3DFilter(10)
SeeSaw(last,a)

Last edited by mikeytown2; 2nd February 2009 at 10:05.
mikeytown2 is offline   Reply With Quote
Old 2nd February 2009, 10:01   #9  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,390
IMO it's mostly a waste of time. If you know your filter, then this method shows you what you already knew beforehand. If you don't know your filter, there's not much information to derive from the result.

Short of exhaustive elaboration, a few small examples:

RemoveGrain(4), XSharpen(255,255), LimitedSharpen(ss_x/x=1.0,overshoot=0) all (should) give the same result: zero change.
Same for SeeSaw: vanilla SeeSaw should give a zero result. In the above example with SeeSaw(+FFT3DFilter), you're actually measuring the effect of FFT3DFilter, not of SeeSaw.

Whether there is overshoot or not has not much to say per se. Sharpness/contrast are partly correlated. Which kind of change is useful/wishful and which are not, that's a tricky decision to make. With a method as simple as this one (in regard to the test pattern), you won't get behind the lines.

The way of generating the displayed result is nice by itself.
Alas, the result is not interesting.

Quote:
Originally Posted by Shakespeare
"Much ado about nothing".
__________________
- We´re at the beginning of the end of mankind´s childhood -

My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!)
Didée is offline   Reply With Quote
Old 2nd February 2009, 10:21   #10  |  Link
mikeytown2
Resize Abuser
 
mikeytown2's Avatar
 
Join Date: Apr 2005
Location: Seattle, WA
Posts: 623
@Didée
You are correct, it's mainly pointless.

So I came up with a more interesting example showing the degradation of an image. I also updated the function... output is more user friendly in my opinion.

Blur(1)


Blur(1).Sharpen(1)


Blur(1).Sharpen(1).Blur(1)


Blur(1).Sharpen(1).Blur(1).Sharpen(1)
mikeytown2 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 13:30.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2018, vBulletin Solutions Inc.