View Full Version : Here is LimitedSharpen()


Didée
20th October 2004, 23:54
Hello friends :)

Seems this is my millenium post. Since for me this is a rather seldom event, I thought I could at least make a usable and halfway worthy one, instead of doing only small talk in other places.

Time ago, I started a thread in the Development section about "thresholded sharpening". The thread turned into a little idea bin (and is still open for that purpose ;) ), and one of the breed's results is the function

"LimitedSharpen()"

It's been around for a while now, a little wild at times, in several different versions regarding features and so ... but by now, I think it has reached a status where it is working quite nice and sufficiently fast, and has (most) of the features it's supposed to have. Time to make an own, proper thread in Avisynth Usage for this little function.

So, what's the deal?

LimitedSharpen() can be used like a traditional sharpener, but producing much less artefacts. It can be used as a replacement for the common "resize(x4)-XSharpen-resize(x1)" combo, with very similar results (perhaps even better) - but at least 2 times faster, since it requires much less oversampling. And by chaining several instances, it can even be used for something like a "[very] poor man's deconvolution" - but only if one knows how to battle the noise ;)


What's the problem with "normal" sharpening?

Traditional sharpeners like sharpen() or UnsharpMask() compare each pixel against the average of its neighborhood, and emphasize the difference between them. The results (something like "per-pixel contrast enhancement") are good as long as the strength is kept low enough. But artefacts will arise very soon.
XSharpen, being a non-linear sharpener, replaces each pixel with either its darkest or brightest neighbor, depending on which is nearer in range. By the nature of the method, XSharpen produces edges with maximal possible aliasing (jaggyness). So one has either to reduce the percentage, thereby weakening the overall effect, or to work with big supersampling, which makes it both extremely slow and less effective.

Let's have a look at a simple transition from dark to bright, and what our standard sharpeners will do to it:

http://img93.exs.cx/img93/7876/normal_sharpen.png

The blue line represents the original edge, the dark side on the left, the bright side on the right, and in-between the gradient that builds "the edge". Red is (basically) the result of sharpen() or UnsharpMask(), pink is the result of XSharpen().
Obviously, both methods have their pro's, and both have their con's.

Note: Discussion about "ideal sharpening" is lengthy. To make an "optimal" sharpness restauration or enhancement, one would need to know the exact process that did reduce the source's sharpness. Since we never know that, we can only search for compromises that work sufficiently good in most cases.


Now, LimitedSharpen() doesn't re-invent the wheel. It just tries to take the best of both worlds.


Shortly, LimitedSharpen() applies one out of three different sharpeners (two domain sharpeners or a windowed range sharpener) to the source, but will limit the oversharpening (either "hard" or "soft") IF it exceeds a defined "overshoot".

In reference to the graphs above, the script's results look like that (basically) :

http://img93.exs.cx/img93/1228/Limited_sharpen.png

(The proportions are not "real" - both graphs were constructed free-handed.)

As you see, LimitedSharpen always takes the enhanced edge steepyness from normal sharpening, but avoids oversharpening in the same way as XSharpen, as long as overshoot is kept at zero, and limiting mode 1 is used.
In many cases, this comes out really nice, and is sufficient.
However, with really strong sharpening there may still occur jaggy edges and/or noticeable loss of gradients in edge neighborhoods. For these cases, limiting mode 2 can be used, as well as supersampling. (The required supersampling factors are only half of what XSharpen usually needs - therefore this script will run much faster in comparison, since only a quarter of image data has to be processed, as opposed to "4*SSXSharpen")



The basic operation is like this:

- make a traditional sharpening operation
- compare each pixel's sharpened result against its brightest and darkest neighbor in the original clip:
-- if the result is inbetween of these, then the pixel is not oversharpened, and the result is used as-is
-- if the result exceeds either the min or max neighbor, then the pixel is oversharpened, and will get limited.

"Neighborhood" of a pixel currently is either its 3x3 or its 5x5 neighborhood, depending on the "wide=true|false" parameter.

Available sharpeners are: UnsharpMask(), Sharpen(), and MinMaxSharpen().

UnsharpMask() and Sharpen() are common - the former sharpens each pixel against a gaussian blurred input, the latter against a 3x3 average. The third mode sharpens each pixel against the average of the brightest & the darkest neighbor. This primitive form of range filtering is less "exact" in theory, but nevertheless turns out useful. The effect is stronger than that of a normal sharpen() operation, and somehow it is less prone to enhance noise and hi-frequency DCT artefacts. The downside is that it does a less optimal job in restoration of blurred corners - but that's mostly neglectable when working with supersampling.

The limiters are: hard limiting, and soft limiting.

With hard limiting, each pixel that becomes either darker than [min_neighbor - overshoot] or brighter than [max_neighbor + overshoot] through sharpening, will simply get clipped to that min|max value.

With soft limiting, no clipping takes place, but a reduction: the effective overshoot from sharpening will get replaced by sqrt(overshoot). This means, a little oversharpening will be present, but it'll be much weaker than it would normally be. As long as the sharpening strength is kept in reasonable range, the oversharpening will still be hardly visible, while still being less prone to loose gradient tone levels in edge neighborhoods.

Lastly, there is the "special" switch. It should be considered as "experimental". Activating this one, the function will perform a simple "smart contrast sharpening": in the range of low levels, pixels will get only brighter through sharpening, not darker. In the high levels range, pixels will get only darker, not brighter. Mid level pixels may get darker/brighter as usual.
This is done by building the comparison frame through a sliding blend of (min_neighbor) for dark pixels and (max_neighbor) for bright pixels, instead of taking the plain average over the whole range. Therefore, in dark areas all values will get sharpened against their darkest neighbor, vice versa in bright areas. Visually, especially in dimmed and dark areas more detail will raise out of the "dark swamp". Simple, not too scientific, but often effective. However, one should use relatively low strengths for this one, or the effect might become strange. But even bigger strengths might come handy for some special tasks of mask creations. Usage of "wide = true" might be a good idea too with lower strengths.
This mode is available only together with Smode=3.


Full function call & parameter description:

LimitedSharpen( float "ss_x", float "ss_y", int "dest_x", int "dest_y",
\ int "Smode", int "strength", int "radius",
\ int "Lmode", bool "wide", int "overshoot",
\ bool "soft", int "edgemode", bool "special",
\ int "exborder" )


ss_x, ss_y
As usual, these floats are the factors for supersampled operation. You'll hardly ever need to go higher than 2.0. For simple sharpening tasks, set these to 1.0 (no supersampling). Default is 1.5 each, however.

dest_x, dest_y
These parameters specify an arbitrary output resolution. Comes handy if supersampled operation is used in a processing chain that involves resizing anyways, to avoid an unneeded extra resizing step.
Default is [none], i.e. same resolution as the input clip.

Smode ("Sharpen mode")
1 = UnsharpMask() [from WarpSharp.dll package]
2 = Sharpen()
3 = "MinMaxSharpen()" [private routine of LimitedSharpen]
Default is Smode=3. Change yourself if you prefer another one.

strength
Obviously, the strength of sharpening. For Smode=1, it can be 0~127 (simple sharpening), 128~255 (simple overdrive), 255~4096 (big overdrive).
For Smode=2, values 0~100 are handled over to Sharpen() as 0.0~1.0. Values >100 are mapped to 100.
For Smode=3, 0~100 is common, but 100~inf. can be used if necessary.
Default is strength=160 for Smode=1, and strength=100 for Smode=2|3.

radius
The radius for the unsharp masking of Smode=1. For Smode=2|3, it's simply ignored.
In contrary to former versions, the radius now applies "directly". It's no more scaled along with the ss_x|y values. I like it more this way.
Default is radius=2.

Lmode ("Limiting mode")
1 = hard limiting, together with "overshoot".
2 = soft limiting (use square of real overshoot)
Default is Lmode=1.

wide
false = use min. and max. values of a 3x3 neighborhood for limiting.
true == use min. and max. values of a 5x5 neighborhood for limiting.
Default is wide=false, and this should do the job most times. TRUE might come handy for very blurry sources and/or bigger supersampling factors.

overshoot
This specifies how much the sharpening result may "shoot over" the min and max limits, before either clipping or reduction will be done. 0=no overshoot allowed at all, 128="make-this-script-useless"
Default is overshoot=1.

soft
A misleading name. If TRUE, then the clip will undergo a blur(1) command only for finding the min and max limits (in order to not acidentially use too high or too low limits, caused by noise, small artefacts, or edge-halos.) This does not blur the processed clip itself.
But attention!! This is mostly useful for soft sources with noise. On sharp sources with little noise, you'll loose some detail nevertheless.
Default is soft=FALSE.

edgemode
0 = deactivated, process the whole frame
1 = process only edge areas
2 = process only NOT-edge areas
Default is edgemode=0

special
When TRUE, *and* Smode=3, this will activate the above mentioned smart contrast sharpening. When using other sharpeners, it has simply no effect.
This feature is not fully mature. But be sure to try it out, the effect might be pleasing.
Default is special=FALSE

exborder
If the outmost borders of the input clip are not clean, they can be excluded from the sharpening by setting exborder > 0.
values of 1 to 4 will exclude roughly 2 to 8 pixels from each side of the frame, plus an additional soft transition to the processed area.
This feature is thought for cases when you don't want to crop into the image area. The transition to black borders usually contains artefacts. Setting exborder to an approbriate value will prevent these artefacts from getting emphasized.
Default is 0 (no border exclusion). Usage of borderexclusion will cause a small speed loss.

The defaults are equivalent to
LimitedSharpen( ss_x=1.5, ss_y=1.5, dest_x=last.width, dest_y=last.height,
\ Smode=3, strength=100, radius=2,
\ Lmode=1, wide=false, overshoot=1,
\ soft=false, edgemode=0, special=false,
\ exborder=0 )


Notes

Required are MaskTools >= v1.5.1 and the WarpSharp.dll package.

In case someone's going to use "edgemode": check yourself if the hardcoded values are suited. If not, please adjust them yourself. I myself use it almost never, and don't want to blow up the parameter list unnecessarily.

No RGB input accepted.

Parameter checkings are not water proof, and in no way fool proof.

This is a sharpener. Of course the needed bitrate will grow noticeably. Be careful. Use a denoiser beforehand.


Examples

Hah, gotcha! No, I won't kill your fun of toying-around ...

However, the initially mentioned "speedy version" of 4*supersampled XSharpen'ing would look as simple as

LimitedSharpen( ss_x=2.0, ss_y=2.0, Smode=2)


Apart from that, there are so many possibilities to use this script, dependant on the source quality and the effect one wants to achieve ... toy around with the parameters, I'm sure you will get a good grip to it in short time.

And if something is not clear, feel free to ask.

Have fun!


- Didée

Wilbert
21st October 2004, 00:04
Congrats with your 1000th post!

Btw, you might want to add a link to the plugin/script :)

Didée
21st October 2004, 00:13
Patience. I'm still smoking that cigar.


edit 24 Oct '04: added "exborder" parameter (border exclusion).

edit 26 Nov '04: made the "wide=true" limiting mode working correctly.
# LimitedSharpen()
#
# A multi-purpose sharpener by Didée
#

function LimitedSharpen( clip clp,
\ float "ss_x", float "ss_y",
\ int "dest_x", int "dest_y",
\ int "Smode" , int "strength", int "radius",
\ int "Lmode", bool "wide", int "overshoot",
\ bool "soft", int "edgemode", bool "special",
\ int "exborder" )
{
ox = clp.width
oy = clp.height
ss_x = default( ss_x, 1.5 )
ss_y = default( ss_y, 1.5 )
dest_x = default( dest_x, ox )
dest_y = default( dest_y, oy )
Smode = default( Smode, 3 )
strength = Smode==1
\ ? default( strength, 160 )
\ : default( strength, 100 )
strength = Smode==2&&strength>100 ? 100 : strength
radius = default( radius, 2 )
Lmode = default( Lmode, 1 )
wide = default( wide, false )
overshoot= default( overshoot, 1)
overshoot= overshoot<0 ? 0 : overshoot
soft = default( soft, false )
edgemode = default( edgemode, 0 )
special = default( special, false )
exborder = default( exborder, 0)
#radius = round( radius*(ss_x+ss_y)/2) # If it's you, Mug Funky - feel free to activate it again
xxs=round(ox*ss_x/8)*8
yys=round(oy*ss_y/8)*8
smx=exborder==0?dest_x:round(dest_x/Exborder/4)*4
smy=exborder==0?dest_y:round(dest_y/Exborder/4)*4

clp.isYV12() ? clp : clp.converttoyv12()

ss_x != 1.0 || ss_y != 1.0 ? last.lanczosresize(xxs,yys) : last
tmp = last

edge = logic( tmp.DEdgeMask(0,255,0,255,"5 10 5 0 0 0 -5 -10 -5", divisor=2)
\ ,tmp.DEdgeMask(0,255,0,255,"5 0 -5 10 0 -10 5 0 -5", divisor=2)
\ ,"max").levels(0,0.86,128,0,255,false)

bright_limit = (soft == true) ? tmp.blur(1.0) : tmp
dark_limit1 = bright_limit.inpand()
bright_limit1 = bright_limit.expand()
dark_limit = (wide==false) ? dark_limit1 : dark_limit1 .inflate.deflate.inpand()
bright_limit = (wide==false) ? bright_limit1 : bright_limit1.deflate.inflate.expand()
minmaxavg = special==false
\ ? yv12lutxy(dark_limit1,bright_limit1,yexpr="x y + 2 /")
\ : maskedmerge(dark_limit,bright_limit,tmp,Y=3,U=-128,V=-128)

Str=string(float(strength)/100.0)
normsharp = Smode==1 ? unsharpmask(strength,radius,0)
\ : Smode==2 ? sharpen(float(strength)/100.0)
\ : yv12lutxy(tmp,minmaxavg,yexpr="x x y - "+Str+" * +")

OS = string(overshoot)
Lmode == 1 ? yv12lutxy( bright_limit, normsharp, yexpr="y x "+OS+" + < y x "+OS+" + ?")
\ : yv12lutxy( bright_limit, normsharp, yexpr="y x "+OS+" + < y x y x - "+OS+" - 1 2 / ^ + "+OS+" + ?")
Lmode == 1 ? yv12lutxy( dark_limit, last, yexpr="y x "+OS+" - > y x "+OS+" - ?")
\ : yv12lutxy( dark_limit, last, yexpr="y x "+OS+" - > y x x y - "+OS+" - 1 2 / ^ - "+OS+" - ?")

edgemode==0 ? NOP
\ : edgemode==1 ? MaskedMerge(tmp,last,edge.inflate.inflate.blur(1.0),Y=3,U=1,V=1)
\ : MaskedMerge(last,tmp,edge.inflate.inflate.blur(1.0),Y=3,U=1,V=1)

(ss_x != 1.0 || ss_y != 1.0)
\ || (dest_x != ox || dest_y != oy) ? lanczosresize(dest_x,dest_y) : last

ex=blankclip(last,width=smx,height=smy,color=$FFFFFF).addborders(2,2,2,2).coloryuv(levels="TV->PC")
\.blur(1.3).inpand().blur(1.3).bicubicresize(dest_x,dest_y,1.0,.0)
tmp=clp.lanczosresize(dest_x,dest_y)

clp.isYV12() ? ( exborder==0 ? tmp.mergeluma(last)
\ : maskedmerge(tmp,last,ex,Y=3,U=1,V=1) )
\ : ( exborder==0 ? tmp.mergeluma(last.converttoyuy2())
\ : tmp.mergeluma( maskedmerge(tmp.converttoyv12(),last,ex,Y=3,U=1,V=1)
\ .converttoyuy2()) )

return last
}
#

oo_void
21st October 2004, 01:02
Thanks Didee... looking forward to trying this in place of your previously released and incredibly fast :D IIP function.

------
oo_void

joshbm
21st October 2004, 02:37
Wonderful explaination! :) I've been waiting for the documention for LimitedSharpen(). Now if only we could have an explaination on how to get good input values for IIP :rolleyes: :p.

Regards!
Josh

scharfis_brain
21st October 2004, 05:10
I cannot see the images.
the image-server is terribly slow.

I could host them for you on me arcor-account, which is fast and reliable.

Piper
21st October 2004, 15:21
Thank you very much for this Didée! Your explanation/outline of LimitedSharpen is superb! Well done! *humbled* :D

oo_void
21st October 2004, 20:51
Well, the results are quite nice save one little problem (at least for me) ... the image borders. Would it be possible to add a function similar to IIP's 'exborder' in a future iteration.

------
oo_void

ChronoCross
21st October 2004, 22:24
wow impressive. this might be by far the best documentation I have ever seen. I tested out the filter and all I can say is WOW. The increase in sharpening is amazing. it's scary how effective this is. Keep up the good work.

Teegedeck
22nd October 2004, 07:36
Congrats 1000! :) LimitedSharpen gives very good results, but you know that. Easy to use, safe, fine results.

koszopal
22nd October 2004, 09:59
Originally posted by oo_void
Well, the results are quite nice save one little problem (at least for me) ... the image borders. Would it be possible to add a function similar to IIP's 'exborder' in a future iteration.

------
oo_void
hmm
edgemode=2 didnt help ?
koszopal

oo_void
22nd October 2004, 17:42
Originally posted by koszopal
hmm
edgemode=2 didnt help ?
koszopal
My bad... a bad crop in the source.

------
oo_void

MrTibs
22nd October 2004, 21:19
It would appear that this script could be modified to correct existing overshapened sources... worth looking into.

Soulhunter
22nd October 2004, 23:49
Coooool... :D

PiXuS
23rd October 2004, 13:40
Is it better to pass LimitedSharpen() a clip with a resolution which is, e.g., mod32 x mod16? Or the resolution could be mod1 x mod1?

malkion
24th October 2004, 00:18
yv12 needs at least mod 4 width i believe.

PiXuS
24th October 2004, 15:21
Originally posted by malkion
yv12 needs at least mod 4 width i believe.

I think I didn't explain myself correctly. I wasn't asking for the resolution to pass to XviD (which should be mod16 x mod16 so it can work optimally). I was asking for the filters used by LimitedSharpen.

I know you can't pass whatever resolution to PixieDust. LimitedSharpen doesn't use PixieDust, but it use a library called MaskTools. So the real question was: is there a call to a function of the MaskTools library that require a clip with a resolution which respects a given mod specification (à la PixieDust)?

Didée
24th October 2004, 15:39
Thanks everyone for the warming comments. Always a pleasure to serve the community :)

I have now added the possibility to exclude the borders from processing, as oo_void suggested. It works similar as the same-named parameter in iiP, but allows to control the size of the borders that will be excluded (see updated parameter description).
Tried to implement it in a way that looses as little speed as possible - after all, it means an additional plane copying operation. In case of YUY2 input, also an additional colorspace conversion is needed. That won't affect the output in any way, but makes the operation a little more costly for YUY2 than for YV12 input.
In one respect, the actual implementation is not as smart as it could be: In case that edgemode=1|2 is used, the script will do two separate plane copy operations where the job could be done with only one. It would be not so awful tricky to do it like that ... but I'm currently a little tired of all those "?" and ":"


oo_void:
This function doesn't try to be a replacement for iiP. But I'll implement LimitedSharpen into iiP soon, to make the big boy walk a little faster. In fact, I'm using iiP with this implementation for quite some time now. Only thing is, I'm not sure yet how much LS should be crippled for that purpose, and how much features should be exposed to iiP's function call.

koszopal:
Usage of edgemode=2 is not recommended. At least I don't see much sense in sharpening everything except detail. It's only there for completeness (perhaps someone wants to use that together with UnSmooth(), you never know)

MrTibs:
Mug Funky had a similar thought of using this principle for halo reduction. Though I follow the general idea, I still can't see how it actually should work out. Perhaps if you two stick together heads, and fiddle it out ...

PiXuS:
Just as malkion said. The script works internally in YV12 colorspace, so MOD4 resolutions are required even for YUY2 input. It were possible to work around that with internal padding - but I'm simply too lazy to do that ;) I think MOD4 for input is fair enough.


I have close to no idea how good or bad LimitedSharpen() works on comic or animee sources, as that's not my world at all. If someone has particular issues with such input, please report them.

Mug Funky
24th October 2004, 15:58
anime looks fine with limitedsharpen, don't you worry (wasn't one of the test images in the original thread from chobits? hehe... that little robot girl is so cute).

the halo reduction looks like it'll be easier thanks to the new slew of median filters (and hopefully the speed arms-race that competing plugins would create. hmm... competition doesn't work the same for free stuff, though). i've aleady tried using median filtered clips to get cleaner motion-vectors from MVtools, though to be honest i haven't checked to see if they actually work better.

ChronoCross
25th October 2004, 03:43
only thing I can say about anime sources is that it makes lines super huge. easily countered with a line thinning script.

lamer_de
25th October 2004, 08:17
only thing I can say about anime sources is that it makes lines super huge. Huh, you sure you're not confusing this script with fastlinedarken()? Haven't encountered a broadening of lines in the anime I encoded.

http://s01.imagehost.org/0305/without_limitedsharpen_jpg.t.jpg (http://s01.imagehost.org/view.php?image=/0305/without_limitedsharpen.jpg)http://s02.imagehost.org/0579/with_limitedsharpen_jpg.t.jpg (http://s02.imagehost.org/view.php?image=/0579/with_limitedsharpen.jpg)
(oversharpened, just to show the sharpening effect)

CU,
lamer_de

Soulhunter
25th October 2004, 16:43
Originally posted by ChronoCross

only thing I can say about anime sources is that it makes lines super huge.

@ Didée

Nope, I havent sent ChronoCross LimitedDarken... http://img14.exs.cx/img14/4389/2844.gif


Bye

Didée
25th October 2004, 17:34
PSSSSST - secret! :D

Mug Funky
25th October 2004, 17:41
*hears a strange noise, comes into this thread to investigate*

ChronoCross
25th October 2004, 23:35
I was using it on Rurouni kenshin Episode 1 and near the end of the episode during the main fight scene the lines in kenshins hair become much bigger than the original.

To counter this I use Fastlinedarken() to shrink the lines back to their original size which points back to



only thing I can say about anime sources is that it makes lines super huge. easily countered with a line thinning script.

FastlineDarken() is what I was referring to when I said line
thinning script. =) Hopes this clarifies things.

I love limitedsharpen() on anime sources is because it works better than awarpsharp() without the side effects. Thanks again for such a kickass script.

Anyone want to contribute to the ChronoCross needs a new PC fund? lol

malkion
26th October 2004, 00:43
Didee, just finished pass 1 of a non-resized 720x480 Kill Bill v2 using a custom matrix. Just gosta say, beau-ti-ful!

mpeg2source("e:\project\bill2.d2v",cpu=0,idct=3)
converttoyuy2()
pixiedust(2)
converttoyv12()
limitedsharpen()
colormatrix()
dctfilter(1,1,1,1,1,1,.5,0)

smode=3 also yields the lowest file size compared to smode=1 or smode=2.

I gave up on multiple calls of limitedsharpen with smode=1 on resolution @ 1280x720, since end file sizes ended up higher than a dvd's storage capacity.

Much obliged for a very nice function.

Chainmax
26th October 2004, 14:53
ChronoCross: have you tried LimitedSharpen(ss_x=2.0,ss_y=2.0,Smode=2) instead of LimitedSharpen()? Does it make lines bigger as well?

ChronoCross
26th October 2004, 20:45
nope. that's just the 2x ssxsharpen speedy version. it doesn't porduce the bigger lines but it's not as good IMO at sharpening as didee's special Sharpening Function.

MrTibs
26th October 2004, 21:42
I'm trying the filter but AVS is reporting "there is no function named yv12lutxy". I have Masktools loaded. Any ideas?

Here's the line it is compainning about:


minmaxavg = special==false
\ ? yv12lutxy(bright_limit,dark_limit,yexpr="x y + 2 /")
\ : maskedmerge(dark_limit,bright_limit,tmp,Y=3,U=-128,V=-128,useMMX=true)

Manao
26th October 2004, 22:00
Get the latest version of the masktools, yours is outdated :

http://jourdan.madism.org/~manao/MaskTools-v1.5.4.zip

MrTibs
26th October 2004, 22:55
Yea, now it works.

Strange...my UnZip program wasn't overwriting the DLL when it should have. I was confused because it did expand the readme which had the documentation for the yv12lutxy filter.

PiXuS
26th October 2004, 23:42
Originally posted by Manao
Get the latest version of the masktools, yours is outdated :

http://jourdan.madism.org/~manao/MaskTools-v1.5.4.zip

The version of MaskTools.dll says v1.5.1.0 and MaskTools.htm says v1.4.16. But I guess it is v1.5.4 anyway. (?)

PiXuS
27th October 2004, 00:38
Originally posted by ChronoCross
nope. that's just the 2x ssxsharpen speedy version. it doesn't porduce the bigger lines but it's not as good IMO at sharpening as didee's special Sharpening Function.

I agree. I think Smode=3 gives more detail (I mainly looked at faces of people in movies).

Didée
27th October 2004, 10:14
Originally posted by ChronoCross
... the lines in kenshins hair become much bigger than the original.

the 2x ssxsharpen speedy version ... doesn't porduce the bigger lines but it's not as good IMO at sharpening as didee's special Sharpening Function.
When saying "special sharpening function", do you refer to Smode=3, or to special=true ?

Special=true is, as said, a pretty simple trick, considered experimental, and not really recommended for regular use. While it may have nice effects on dark & bright image areas, there are also some strange side effects, such as warpsharp-alike shifts of edges and boundaries, thinning or widening of narrow features, or even haloing when certain level ranges lie next to each other.
(For overall contrast enhancement, I've another more serious approach in the works. I dare to say it delivers already spectacular results ... but the noise is totally out of control, yet. So the forced bitrates are awesome, to not say mayhem - "through the roof" is a too weak term to describe it. Even PixieDust is hardly able to hold it.)

While in contrast Smode=3 is pretty safe, occasionally it may also deliver results a little different from what one expects, when looking very close. Reason is that mode 3 works only in relation to the present range of a given area. It does not care for the overall distribution in the area, like modes 1 & 2 do. (Throwing around with terminology, mode 3 is sort of a range filter, whereas modes 1 & 2 are domain filters.) Consequently, the effect of mode 3 on detail's edges is not always fully symmetric.

For natural sources, me too prefers Smode=3. For animated content, I simply don't know. That's why I asked about that some posts above.

Soulhunter
27th October 2004, 10:55
Hmm, LimitedSharpen + Denoise3dHQ = Time for a new version of Reloaded HQ !?!

Btw, a new eye-riddle for Didée... :D

http://img97.exs.cx/img97/3642/Eyes.th.png (http://img97.exs.cx/my.php?loc=img97&image=Eyes.png)


Bye

Chainmax
27th October 2004, 12:27
Is Denoise3dHQ that good?

PiXuS
27th October 2004, 12:40
Originally posted by Didée
For natural sources, me too prefers Smode=3. For animated content, I simply don't know. That's why I asked about that some posts above.

I noticed something strange regarding the results of Smode=2 and Smode=3. On one test I made (my Blade Runner -- Director's Cut DVD) Smode=2 looks definitively sharper WHEN noise is added on playback. If NO noise is generated to compensate for the macro-blocks, I can easily observe Smode=3 retains more detail (can't say if it is sharper).

Weird!

Soulhunter
27th October 2004, 13:30
Originally posted by Chainmax

Is Denoise3dHQ that good?

Imo its nice to reduce floating-noise n' ring-crawling effects !!!

Try disabling the denoising and use it as temporal-stabilizer... ;)


Bye

ChronoCross
27th October 2004, 14:16
Originally posted by Didée
When saying "special sharpening function", do you refer to Smode=3, or to special=true ?

Special=true is, as said, a pretty simple trick, considered experimental, and not really recommended for regular use. While it may have nice effects on dark & bright image areas, there are also some strange side effects, such as warpsharp-alike shifts of edges and boundaries, thinning or widening of narrow features, or even haloing when certain level ranges lie next to each other.
(For overall contrast enhancement, I've another more serious approach in the works. I dare to say it delivers already spectacular results ... but the noise is totally out of control, yet. So the forced bitrates are awesome, to not say mayhem - "through the roof" is a too weak term to describe it. Even PixieDust is hardly able to hold it.)

While in contrast Smode=3 is pretty safe, occasionally it may also deliver results a little different from what one expects, when looking very close. Reason is that mode 3 works only in relation to the present range of a given area. It does not care for the overall distribution in the area, like modes 1 & 2 do. (Throwing around with terminology, mode 3 is sort of a range filter, whereas modes 1 & 2 are domain filters.) Consequently, the effect of mode 3 on detail's edges is not always fully symmetric.

For natural sources, me too prefers Smode=3. For animated content, I simply don't know. That's why I asked about that some posts above.

yeah I was referring to Smode=3. your description of range to that frame is correct. I pulled out a few other episodes and gave them a whirl and it didn't do anything out of the ordinary to his hair. It seems to me that it only happens when it's a darker scene such as at night. I'm gonna fool around with the other modes and see if I get similar results.

Didée
27th October 2004, 15:02
Originally posted by Soulhunter
Imo its nice to reduce floating-noise n' ring-crawling effects !!!

Crawling rings or crawling-in-a-ring? Hmh, never have seen such a thing in my sources. Except for crawling Gollum, hunting after a certain ring :D

Seriously, has anyone a description about Denoise3D's principle of operation? Is it similar to Convolution3d, or is it using weightening à la SmartSmoothHiQ, or is it choosing the "best" diagonal from a 3x3 cube like STMedianFilter, or ...
Only having some vague "strength" options without explanation makes me feel like being in free fall ;) , even if it works nicely. Which it does, without doubt.

Soulhunter
27th October 2004, 16:48
Originally posted by Didée

Crawling rings or crawling-in-a-ring? Hmh, never have seen such a thing in my sources. Except for crawling Gollum, hunting after a certain ring :D

Lol, I meant ringing that crawls !!!

Dont try to detract from the eye-riddle...

tedkunich
27th October 2004, 21:30
Didée

Did I hear you correctly when you said that you plan on integrating LimitedSharpen into iip? Do you have an estimate when you would have something ready to share?


T

DeepDVD
3rd November 2004, 23:17
It would be very nice if you gonna integrate limitedsharpen into iiP...

There's surely the problem about the encoding speed and how to merge some funktions to get more FPS of the encoding.... but I'm not an advanced so i can only imagine that there would be more problems someone wanna solve ;)


PS: LimitedDarken? :rolleyes: Let me imagine what that can be ;)

Does it perhaps go in direction of Mf's Toon-function? Maybe to control the darkening of lines and avoid thick lines?...

It also could be a controled color-correcting function??

Give us some hints please :D

Soulhunter
4th November 2004, 07:59
@ DeepDVD

Yes/Ok/Maybe/Probably/Opposite/Wrong/Done... :D


Bye

Didée
4th November 2004, 15:33
Okay. For all the impatient people, a little preview: "The quick hack" (www.spselectronic.com/english/~temp/preview_iiPv06.rar).

No guarantees, no claims, no responsibilities.

No support.

No need to report any bugs.

oo_void
4th November 2004, 18:34
Thanks Didee... Now time to fire off another 34 hour render ;).

------
oo_void

tedkunich
4th November 2004, 20:43
Originally posted by Didée
Okay. For all the impatient people, a little preview: "The quick hack" (www.spselectronic.com/english/~temp/preview_iiPv06.rar).

No guarantees, no claims, no responsibilities.

No support.

No need to report any bugs.


:D I'll give it a try tonight some time....


Many thanks!

T

kingmob
8th November 2004, 13:14
Just wanted to say this looks very promising. Need to get me some vids to try it out on now ;).

mateo4x4
11th November 2004, 12:33
LimitedSharpen works really pretty but it's very slow. It slowed down my encodings about 5 x.

PiXuS
11th November 2004, 15:00
Originally posted by mateo4x4
LimitedSharpen works really pretty but it's very slow. It slowed down my encodings about 5 x.

Funny thing is, one of LimitedSharpen's main appeal compared to the other sharpening methods is it's speed!

mateo4x4
11th November 2004, 15:39
This is my script:
Import("C:\PROGRA~1\GORDIA~1\AviSynthPlugins\limitedsharpen.avsi")
LoadPlugin("C:\PROGRA~1\GORDIA~1\AviSynthPlugins\dgdecode.dll")
LoadPlugin("C:\Program Files\GORDIA~1\AviSynthPlugins\MaskTools\MaskTools.dll")

mpeg2source("D:\My Documents\My video\Mind\Mind.d2v", idct=0)
crop(4,6,712,562)
LimitedSharpen()
LanczosResize(592,320)

Any ideas why it is so slow ?

Didée
11th November 2004, 16:18
Originally posted by mateo4x4
LimitedSharpen [...] slowed down my encodings about 5 x.
Well, there are scripts out there that slow down the encoding by factors 10x ~ 30x, or even more ...

Before you get too disappointed, try the following:

--------------------------------------------
crop(4,6,712,562)
Lanczos4Resize(712*4,562*4).XSharpen(255,255)
LanczosResize(592,320)
--------------------------------------------

After trying *that*, tell again how slow LimitedSharpen really is ... :D


However there are two or three steps to make it faster:

1.
Use crop(4,6,712,562,true) because of memory related Avisynth-internal details.


2.
You are doing one resizing step too much. Try

--------------------------------------------
crop(4,6,712,562,true)
LimitedSharpen(dest_x=592,dest_y=320)
--------------------------------------------

This won't give you the real breaktrough either, but it will be faster.


3.
Reduce supersampling (but quality as well). Try

-----------------------------------------------------------------------------
crop(4,6,712,562,true)
LimitedSharpen(ss_x=1.0,ss_y=1.0,dest_x=592,dest_y=320,Smode=2,strength=40~~80)
-----------------------------------------------------------------------------


Rule of thumb: The better the result, the longer it takes.

(The reverse conclusion is not necessarily true, however)

mateo4x4
11th November 2004, 17:02
Thank You Didée :)

DeepDVD
12th November 2004, 14:43
I took a look at the alpha some hours ago and it looks cool ATM.

The speed is approx 2-3 FPS (Athlon XP 2600+ @ 2300 MHz on nForce 2 Dual Channel 521 MB RAM)

I think that could be the best quality improving filterfunction ever posted in this forum ... but i'm beginner :D

Chainmax
13th November 2004, 16:46
I am trying to use LimitedSharpen on a new encode I'm trying but for some reason warpsharp.dll can't be loaded. Does LimitedSharpen need it if it's going to be called like this: LimitedSharpen(ss_x=2.0, ss_y=2.0)?

PiXuS
13th November 2004, 17:54
Originally posted by Chainmax
I am trying to use LimitedSharpen on a new encode I'm trying but for some reason warpsharp.dll can't be loaded. Does LimitedSharpen need it if it's going to be called like this: LimitedSharpen(ss_x=2.0, ss_y=2.0)?

No because then you are using Smode=3 (the default mode). If you use that mode, you only need MaskTools.dll.

BTW.. warpsharp.dll loads normally here.

Chainmax
13th November 2004, 20:12
I had inspected the avs and didn't catch any warpsharp calls except for unsharpmask, but I wanted to make sure. BTW, warpsharp usually loads without problems :confused: Has anyone else had any issues trying to load it?

malkion
13th November 2004, 23:56
if you reformated, you have to check if you have the msvcp71 and msvcr71 dlls in the system dir. other than that, no other loading problems for the japanese version of warpsharp I'm aware of.

Socio
14th November 2004, 04:03
LimitedSharpen washes out the color?

First of all if you have read my thread on using Avisynth in ffdshow for DVD playback you know I am using LimitedSharpen in an unorthodox manner for on the fly DVD viewing.

Here are the settings I use:

LimitedSharpen(ss_x=1.0,ss_y=1.0,Smode=3,strength=40)

If you look at the before and after pics you can see I get a much sharper image but the colors are faded compared to the original. So now I am wondering if there is a way to automatically compensate for that with little overhead and without having to mess with Hue & Saturation settings?

Thanks for any input

Here are the pics;

Before

http://img23.exs.cx/img23/2497/OPEN_RANGE-normal.jpg

After Limited Sharpen

http://img23.exs.cx/img23/2402/OPEN_RANGEuber.jpg

Didée
14th November 2004, 04:44
That's not the fault of LimitedSharpen: It does not process chroma at all :) (the last step in the function is the merging of the unprocessed original color planes).

In these two pictures here it's a luma problem - there is much contrast missing, it looks like a gray haze was layed over the 2nd one.
Also note that none of your screenshots in the other thread actually show this problem, so ... dunno what it is, but something went wrong here.

Socio
14th November 2004, 06:48
I figured it out!

I was using VMR9 as a renderer when I switched to Overlay it fixed the color problems.

Chainmax
15th November 2004, 00:47
Originally posted by malkion
if you reformated, you have to check if you have the msvcp71 and msvcr71 dlls in the system dir. other than that, no other loading problems for the japanese version of warpsharp I'm aware of.
I forgot about those DLLs, I'll install them and report back.

Chainmax
15th November 2004, 18:10
Of course, installing the DLLs solved the issue :o.

lancer
18th November 2004, 20:11
Didee,

I'm having a problem with limited sharpen I hope you can help with.

when I run this script below, virtualdubmod throws up the following error message.

avisynth open failure.
script error: there is no function named "limitedsharpen"

I am running avisynth version 255
and I have mask tools version 1.5.4

#Star Wars Episode IV : A New Hope Master Script

#Plugins


LoadPlugin("h:\avsfilters\sangnom.dll")
LoadPlugin("h:\avsfilters\asharp.dll")
LoadPlugin("h:\avsfilters\atc.dll")
LoadPlugin("h:\avsfilters\MPEG2Dec3.dll") # because Avisynth 2.5 didn't support Autoloading yet
LoadPlugin("h:\avsfilters\msharpen.dll")
LoadPlugin("H:\avsfilters\stmedianfilter.dll")
LoadPlugin("H:\avsfilters\warpsharp.dll")
LoadPlugin("D:\Program Files\AviSynth2\plugins\masktools\MaskTools.dll")
Loadplugin("H:\avsfilters\removedirts.dll")
Loadplugin("H:\avsfilters\de.dll")
Import("D:\Program Files\AviSynth2\plugins\limitedsharpen.avsi")


#Source Files

v1 = AviSource("p:\anh_source.avi").crop(0,45,0,-73).ConvertToYV12().Lanczos4Resize(720,600)
v2a = v1.SangNom(order=0).Lanczos4Resize(720,270)
v2b = v1.SangNom(order=1).Lanczos4Resize(720,270)

v3 = v2a.overlay(v2b, opacity = 0.5, mode="darken").tweak(bright=-12,cont=1.05,sat=1.30).LimitedSharpen()
v4 = v3.AddBorders(0,36,0,36)
#v4 = v3.AddBorders(0,52,0,52)
#v5 = v4#.DeDot(50,5,5,25)
#v6 = v5.Subtitle("Going somewhere, Solo?", first_frame=70640, last_frame=70680, x=-1, y=334, font="BD Hanover", size=20, text_color=$ffFFff, spc=5).Subtitle("It's too late.", first_frame=70808, last_frame=70847, x=-1, y=334, font="BD Hanover", size=20, text_color=$ffFFff, spc=5)
#v7 = v6.Subtitle("You should have paid him when you had the chance.", first_frame=70855, last_frame=70913, x=-1, y=334, font="BD Hanover", size=20, text_color=$ffFFff, spc=5).Subtitle("Jabba's put a price on your head so large...", first_frame=70924, last_frame=70994, x=-1, y=334, font="BD Hanover", size=20, text_color=$ffFFff, spc=5)
#v8 = v7.Subtitle("...every bounty hunter in the galaxy will be looking for you.", first_frame=71006, last_frame=71073, x=-1, y=334, font="BD Hanover", size=20, text_color=$ffFFff, spc=5).Subtitle("I'm lucky I found you first.", first_frame=71081, last_frame=71119, x=-1, y=334, font="BD Hanover", size=20, text_color=$ffFFff, spc=5)
#v9 = v8.Subtitle("If you give it to me, I might forget I found you.", first_frame=71191, last_frame=71270, x=-1, y=334, font="BD Hanover", size=20, text_color=$ffFFff, spc=5).Subtitle("Jabba's through with you.", first_frame=71349, last_frame=71394, x=-1, y=334, font="BD Hanover", size=20, text_color=$ffFFff, spc=5)
#v10 = v9.Subtitle("He has no time for smugglers who drop their shipments...", first_frame=71418, last_frame=71506, x=-1, y=334, font="BD Hanover", size=20, text_color=$ffFFff, spc=5).Subtitle("..at the first sign of an Imperial cruiser.", first_frame=71514, last_frame=71550, x=-1, y=334, font="BD Hanover", size=20, text_color=$ffFFff, spc=5)
#v11 = v10.Subtitle("You can tell that to Jabba. He may only take your ship.", first_frame=71640, last_frame=71730, x=-1, y=334, font="BD Hanover", size=20, text_color=$ffFFff, spc=5).Subtitle("That's the idea.", first_frame=71787, last_frame=71818, x=-1, y=334, font="BD Hanover", size=20, text_color=$ffFFff, spc=5)
#v12 = v11.Subtitle("I've been looking forward to this for a long time.", first_frame=71826, last_frame=71912, x=-1, y=334, font="BD Hanover", size=20, text_color=$ffFFff, spc=5)
#v13 = v12.Lanczos4Resize(720,480)
return v4

#total running time is
#
#1:52:15s

PiXuS
18th November 2004, 20:29
@lancer

Import("D:\Program Files\AviSynth2\plugins\limitedsharpen.avsi")

Is the extension really .avsi or should it be .avs?

lancer
18th November 2004, 20:46
sorted. it seems I was using an incorrect version of masktools.

Wilbert
18th November 2004, 21:46
Is the extension really .avsi or should it be .avs?
avsi files are loaded automatically when they are in the autoloading plugin dir.

Didée
19th November 2004, 09:21
lancer:

You have it running now, yes?

One more tip: Currently your clip undergoes two resize operations where only one would be sufficient (due to LS's internal supersampling.

Adapt your script like this:
ss_factor = 1.5

v1 = AviSource("p:\anh_source.avi").crop(0,45,0,-73).ConvertToYV12().Lanczos4Resize(720,600)
v2a = v1.SangNom(order=0) .Lanczos4Resize(720,round(270*ss_factor/4)*4)
v2b = v1.SangNom(order=1) .Lanczos4Resize(720,round(270*ss_factor/4)*4)

v3 = v2a.overlay(v2b, opacity = 0.5, mode="darken").tweak(bright=-12,cont=1.05,sat=1.30)
\ .LimitedSharpen(ss_x=ss_factor,ss_y=1.0, dest_x=720,dest_y=270)

And since you have loaded Masktools anyways, you could also replace the "overlay" command with something that does the same work a little faster ... like :
v3 = logic(v2a,v2b,"min",Y=3,U=2,V=2).tweak(bright=-12,cont=1.05,sat=1.30)
\ .LimitedSharpen(ss_x=ss_factor,ss_y=1.0,dest_x=720,dest_y=270))

Is there a special reason why you are first downsizing the two SangNom's again, before averaging them? Theoretically it would be better, IMO, to average them without downsizing. Then the sequence would look like that:
ss_factor = 1.5
v1 = AviSource("p:\anh_source.avi").crop(0,45,0,-73).ConvertToYV12().Lanczos4Resize(720,600)
v2a = v1.SangNom(order=0)
v2b = v1.SangNom(order=1)

v3 = logic(v2a,v2b,"min",Y=3,U=2,V=2).tweak(bright=-12,cont=1.05,sat=1.30)
\ .LimitedSharpen(ss_x=ss_factor,ss_y=round(270/600*ss_factor/4)*4,dest_x=720,dest_y=270)

Oh, and I could image you want to use a vertical size of 272, not 270 ...

Happy restauration ;)

Chainmax
19th November 2004, 12:01
Yeah, apparently the DLLs were not installed (the machine I'm working on is not mine):o.

lancer
20th November 2004, 16:47
didee,

I'm resizing down again because then I add black bars and put in subtitles which are then all stretched anamorphic before being passed to TMPGenc.

if it wasn't for the subtitles I wouldn't have to size it down again.

Didée
20th November 2004, 19:02
lancer,

in some sense you got me wrong ... and in some sense I got you wrong ;)

I did not see that you resize to anamorphic aspect ratio at the very end :o

But that's not the point I was referring to. Your actual chain is doing the following:upsize -> Sangnom^2 -> downsize -> average(Sangnom) -> LimitedSharpen(upsize->sharpen->downsize)Whereas my scriptlets suggestions do

1st one:upsize -> Sangnom^2 -> average(Sangnom) -> downsize -> LimitedSharpen(upsize->sharpen->downsize)2nd one:upsize -> Sangnom^2 -> average(Sangnom) -> LimitedSharpen(sharpen->downsize)

See the differences? My suggestions use more information (from upsizing/interpolation) as long as it can be hold available, and discard information (through averaging/resizing) as late as possible. Also, the 2nd scriptlet uses as few resizing steps as possible.

Regarding the anamorphic step: in respect to picture quality, it would be much better to perform LimitedSharpen at the very end, and let LS do the anamorphic resizing during doing its work.
But it could be that the subtitles get a little un-beautyfied through LS (I suppose not, but it could be). Just try to use LS at the very end, with (dest_x=720,dest_y=480). In case the subtitles get aliasing, try again with (ss_x=2.0,ss_y=2.0,dest_x=720,dest_y=480).

Alternatively, one could produce an anamorphic frame through LS, create the subtitles on a fake clip where they seperately would be resized to anamorphic, and then transfer the subtitles from the fake to the real clip. No big deal to do that, but it would lead a little too far for this thread ;)

flib
21st November 2004, 01:10
Ugh, probably just me being crap .. but when I try to get this to work it get errors, mostly being:

LoadPlugin: unable to load "C:\dodo\MaskTools.dll"

This is the script:

Import("C:\dodo\limitedsharpen.avsi")
LoadPlugin("C:\dodo\dgmpgdec\DGDecode.dll")
LoadPlugin("C:\dodo\MaskTools.dll")
LoadPlugin("C:\dodo\UnFilter.dll")
LoadPlugin("C:\dodo\Decomb521.dll")

mpeg2source("sample.d2v", idct=5)
Crop(0,4,-0,-4)
Unfilter(40,40)
LanczosResize(640,352)
LimitedSharpen(ss_x=1.0,ss_y=1.0)

And yes, MaskTools in is C:\dodo\ :P .. and it's version 1.5.1.0.

Any clues? :)

Manao
21st November 2004, 08:58
Let me guess... You have a P4 with hyperthreading ?

Fetch this version, it should work : http://manao4.free.fr/MaskTools-p4-5.dll

Second solution : disable hyperthreading.

Mug Funky
21st November 2004, 10:28
IMHO hyperthreading is more trouble than it's worth. i never had it explained to me: what benefit is to be gained by simply "pretending" to have 2 processors, considering most apps aren't all that good with multi-proc anyway?

things are less stable with hyperthreading, that's for sure.

Leak
21st November 2004, 18:21
Originally posted by Mug Funky
IMHO hyperthreading is more trouble than it's worth. i never had it explained to me: what benefit is to be gained by simply "pretending" to have 2 processors, considering most apps aren't all that good with multi-proc anyway?

things are less stable with hyperthreading, that's for sure.

For me, it's the difference between getting skipping sound from Foobar2000 when I'm playing UT2k4 and not, since with Hyperthreading the other virtual CPU allows Foobar2k to decode MP3s while I'm playing; with HT off I get skips in sound when my graphics card gets textures uploaded...

Anyway, the same bugs that plague a Hyperthreading system will bite you if you've got a dual-CPU system, so if more bugs get fixed by HT getting popular that's fine with me.

flib
22nd November 2004, 15:56
Originally posted by Manao
Let me guess... You have a P4 with hyperthreading ?

Fetch this version, it should work : http://manao4.free.fr/MaskTools-p4-5.dll

Second solution : disable hyperthreading.

Thanks mate, works fine now :]

Didée
26th November 2004, 10:54
A small update to LimitedSharpen:

Limiting with "wide=true" was b0rked, giving rather coarse results (braindead error with variable names).

This is fixed now. (I wonder why nobody has complained about that yet. Everybody using the defaults and nothing else? Lame ... ;) )

The function script on page 1 is updated.

There are a few more refinements coming, amongst them a custom unsharp masking, targeting at "uneven" x/y sharpening, e.g. for VHS captures. Perhaps an easy halo reducer will also find its way in ... let's see.

E-Male
26th November 2004, 15:00
i think i could put a very simplyfied version of the script into a plug-in
just these lines:

dark_limit = inpand()
bright_limit = expand()
minmaxavg = yv12lutxy(dark_limit,bright_limit,yexpr="x y + 2 /")
Str=string(float(strength)/100.0)
normsharp = yv12lutxy(minmaxavg,yexpr="x x y - "+Str+" * +")
OS = string(overshoot)
yv12lutxy( bright_limit, normsharp, yexpr="y x "+OS+" + < y x "+OS+" + ?")
yv12lutxy( dark_limit, last, yexpr="y x "+OS+" - > y x "+OS+" - ?")

i wonder if that would speed it up
maybe someone with mroe experience on that can tell

Manao
26th November 2004, 19:20
In that very specific case, it will speed things up, because you'll be able to use mmx & isse. It will become almost as fast as inpand().expand()

Heini011
27th November 2004, 12:35
@Didée:

Limiting with "wide=true" was b0rked, giving rather coarse results (braindead error with variable names). This is fixed now. (I wonder why nobody has complained about that yet. Everybody using the defaults and nothing else? Lame ...

ohh, it seemed, that i had used 'wide=true' so far, just because of this 'bug'. together with a low strength value (10..20) it give me a nice amount of details. could it be, that this 'bug' had some unintentional sense ??

@E-Male:

i tried it. performance is exactly the same.

a very little improvement could be the follow line-replacement at the ending:

tmp=clp.lanczosresize(dest_x,dest_y)
->
tmp= (dest_x != ox || dest_y != oy) ? clp.lanczosresize(dest_x,dest_y) : clp

greetings.

lancer
1st December 2004, 16:03
didee,

I've been using limited sharpen smode=3 for a few days and I am wondering at times if it is even there.

there seems to be little improvment unless I ramp up the strength to some ridiculous level and then end up with ugly line artifacting.

do you think I should be adjusting the overshoot to give it something more to bite with.

also, having seen that picture of the eyes and the different modes, I think I might give Smode=1 a try as this seemed to capture the texture of the better and ehance the lines in this area.

at the moment I can't see much improvement which is a shame considering how much people rave about it.

script will be posted when I get home.

Didée
1st December 2004, 17:07
lancer, perhaps it's your expectations, and not the script ... ;)

LS is meant more as a "refinement" sharpener, not so much as a "contrast booster". That means, you won't get "blown away" by the effect - at least not with the defailt settings. For more contrast enhancement, try (strength=200,wide=true,Lmode=2) as a start. This is most probably way too strong, and you'll have to reduce the strength ... but you need to have the noise-level already very low, and you'll likely to get some edge-halos again, with those settings.

***

Next version of LimitedSharpen is almost ready. Late Yesterday (very late), it produced things like this (http://forum.doom9.org/showthread.php?s=&postid=575765#post575765) ... when chaining two instances of it, and denoising in-between them ;)

lancer
1st December 2004, 17:42
maybe,

the thing is, I'll tell you where I'm coming from on this, perhaps you can make a suggestion because I am flailing a bit.

I think I got spoiled by MSU smart sharpen.

you see, that on my file produces some nice results, but I object on principle to a filter that isn't even remotely optimised.

the rest of the script prior to the application of MSU in vdub yields 10-12fps. as oon as MSU is applied it drops to 1-2 fps and that is just unacceptable when I've got 180,000 frames to process.

now before someone says its because of the switch to RGBmode in vdub, no it isn't I tested that and it is entirely down to the MSU smart sharpen filter.

what I'm trying to do then is accomplish the same 'look' as MSU smart sharpen but by using other filters so the outputting is quicker. the creators say it is basically a warpsharpen filter with some routines of their own running. there's definitely some form of contrast running in their somewhere but I've dealt with that.

I've used asharp and that is nice, but the very fine line detail on faces and clothing is not as good as msu. so I'm thinking perhaps limited sharpen in combination with asharp and maybe unfilter may deliver for me.

the noise level is low on my source file so I'm not worried about halo's but I am trying to avoid edge enhancment delineation on the edges.

when you say chaining two instances, I take it you mean something like

limitedsharpen()
denoiser here
limitedshapren()

I was considering this, perhaps trying one mode on first pass and another mode on the second. In combination therefore I might do quite well.

what do you think?

Socio
1st December 2004, 19:06
Lancer,

Better yet, look for the IIP/LimitedSharpen combo in this thread and give it a try. I have been using it and has yielded the best the images out of anything I have ever tried it is simply amazing.

lancer
2nd December 2004, 10:50
thanks for that didee, I'll give iip a try tonight.

few things about ltd sharpen that went wrong last night.

when I tried smode=1 it said it couldn't because it couldn't find unsharpmask.dll

anyone got a link for this?

oops, just realised my version of warpsharppackage might be out of date.

second

smart contrast sharpening didn't work. when made special=true vdubmod popped up with a message saying line 56 or thereabouts(not in front of my computer so working from memory here) of limitedsharpen.avsi in the avisynth plugins directory was missing a flag for MMX.

I'm getting better results. still not as good as MSU smart sharpen is but it is faster and maybe iip will cure the final bits I'm looking for.

hartford
2nd December 2004, 14:50
You are using an old version of the script. Latest is 11.26.2004, start of thread.

Heini011
2nd December 2004, 17:02
Hi,

has someone tried the older version of this script with 'wide=true' and a low strength value ? i still use it and i'am very satisfied with the results!

for example: LimitedSharpen(strength=20,ss_x=1.5,ss_y=1.5,wide=true)

here is the slight modified older code again:
---
# LimitedSharpen(): A multi-purpose sharpener by Didée

function LimitedSharpen( clip clp,
\ float "ss_x", float "ss_y",
\ int "dest_x", int "dest_y",
\ int "Smode" , int "strength", int "radius",
\ int "Lmode", bool "wide", int "overshoot",
\ bool "soft", int "edgemode", bool "special",
\ int "exborder" )
{
ox = clp.width
oy = clp.height
ss_x = default( ss_x, 1.5 )
ss_y = default( ss_y, 1.5 )
dest_x = default( dest_x, ox )
dest_y = default( dest_y, oy )
Smode = default( Smode, 3 )
strength = Smode==1
\ ? default( strength, 160 )
\ : default( strength, 100 )
strength = Smode==2&&strength>100 ? 100 : strength
radius = default( radius, 2 )
Lmode = default( Lmode, 1 )
wide = default( wide, false )
overshoot= default( overshoot, 1)
overshoot= overshoot<0 ? 0 : overshoot
soft = default( soft, false )
edgemode = default( edgemode, 0 )
special = default( special, false )
exborder = default( exborder, 0)
#radius = round( radius*(ss_x+ss_y)/2) # If it's you, Mug Funky - feel free to activate it again
xxs=round(ox*ss_x/8)*8
yys=round(oy*ss_y/8)*8
smx=exborder==0?dest_x:round(dest_x/Exborder/4)*4
smy=exborder==0?dest_y:round(dest_y/Exborder/4)*4

clp.isYV12() ? clp : clp.converttoyv12()

ss_x != 1.0 || ss_y != 1.0 ? last.lanczosresize(xxs,yys) : last
tmp = last

edge = logic( tmp.DEdgeMask(0,255,0,255,"5 10 5 0 0 0 -5 -10 -5", divisor=2)
\ ,tmp.DEdgeMask(0,255,0,255,"5 0 -5 10 0 -10 5 0 -5", divisor=2)
\ ,"max").levels(0,0.86,128,0,255,false)

bright_limit = (soft == true) ? tmp.blur(1.0) : tmp
dark_limit = bright_limit.inpand()
bright_limit = bright_limit.expand()
dark_limit = (wide==false) ? dark_limit : dark_limit .inflate.deflate.inpand()
bright_limit = (wide==false) ? bright_limit : bright_limit.deflate.inflate.expand()
minmaxavg = special==false
\ ? yv12lutxy(bright_limit,dark_limit,yexpr="x y + 2 /")
\ : maskedmerge(dark_limit,bright_limit,tmp,Y=3,U=-128,V=-128)

Str=string(float(strength)/100.0)
normsharp = Smode==1 ? unsharpmask(strength,radius,0)
\ : Smode==2 ? sharpen(float(strength)/100.0)
\ : yv12lutxy(tmp,minmaxavg,yexpr="x x y - "+Str+" * +")

OS = string(overshoot)
Lmode == 1 ? yv12lutxy( bright_limit, normsharp, yexpr="y x "+OS+" + < y x "+OS+" + ?")
\ : yv12lutxy( bright_limit, normsharp, yexpr="y x "+OS+" + < y x y x - "+OS+" - 1 2 / ^ + "+OS+" + ?")
Lmode == 1 ? yv12lutxy( dark_limit, last, yexpr="y x "+OS+" - > y x "+OS+" - ?")
\ : yv12lutxy( dark_limit, last, yexpr="y x "+OS+" - > y x x y - "+OS+" - 1 2 / ^ - "+OS+" - ?")

edgemode==0 ? NOP
\ : edgemode==1 ? MaskedMerge(tmp,last,edge.inflate.inflate.blur(1.0),Y=3,U=1,V=1)
\ : MaskedMerge(last,tmp,edge.inflate.inflate.blur(1.0),Y=3,U=1,V=1)

(ss_x != 1.0 || ss_y != 1.0)
\ || (dest_x != ox || dest_y != oy) ? lanczosresize(dest_x,dest_y) : last

ex=blankclip(last,width=smx,height=smy,color=$FFFFFF).addborders(2,2,2,2).coloryuv(levels="TV->PC")
\.blur(1.3).inpand().blur(1.3).bicubicresize(dest_x,dest_y,1.0,.0)
tmp= (dest_x != ox || dest_y != oy) ? clp.lanczosresize(dest_x,dest_y) : clp

clp.isYV12() ? ( exborder==0 ? tmp.mergeluma(last)
\ : maskedmerge(tmp,last,ex,Y=3,U=1,V=1) )
\ : ( exborder==0 ? tmp.mergeluma(last.converttoyuy2())
\ : tmp.mergeluma( maskedmerge(tmp.converttoyv12(),last,ex,Y=3,U=1,V=1)
\ .converttoyuy2()) )

return last
}

greetings.

Didée
2nd December 2004, 17:38
Well, I could easily integrate that "old" behaviour again. Most probably I'd change the type of the "wide" parameter from "bool" to "integer", so that a selection can be made through it.

The "old" method for wide=true was not really "wrong" ... it simply wasn't the way I wanted it to be: wide=true is meant to gather the hi & lo limits from a wider neighborhood, but to get the average (against which a pixel gets sharpened) still from a narrow neighborhood. The old method did the former correctly, but not the latter - the average was also build from a wide neighborhood. This gave an effect with characteristics quite similar to unsharp masking, which isn't what I wanted to have.
(All of which refers to Smode=3 exclusively.)

Heini011, if you so much like the way it was done formerly, did you try to use Smode=1 instead, together with wide=true? Because that mode *is* unsharp masking, and should be very similar to the abandoned old behaviour ;)

Next version makes steady progress. Can't say if I'll get it baken 'til this week's end ... but I think it's worthwile waiting for it. Although I'm not sure if the current name still will be suited ... it gets more in the direction of "Sharpening Suite", or something like that ... :)

Stay tuned, but don't hold your breath until.

E-Male
2nd December 2004, 22:09
i made an experiment with the limited sharpen formula (fixed strength and overshoot) vs. a lookup table
and the lookup table is noticably slower

but i see a possible way for optimizing it:
we have three values: pixel, maximum and minimum (max and min of the pixel and it's 3x3 neighborhood)
now since the minimum can't be bigger than the pixeland the maximum is never smaller we have many unused values in the table
i don't know if i'm anywhere near able to take advantage of that now, but i'll have another look tomorrow

Socio
4th December 2004, 00:04
Originally posted by Didée

Next version makes steady progress. Can't say if I'll get it baken 'til this week's end ... but I think it's worthwile waiting for it. Although I'm not sure if the current name still will be suited ... it gets more in the direction of "Sharpening Suite", or something like that ... :)

Stay tuned, but don't hold your breath until.

I hope you are planning a version of this "Sharpening Suite", that includes IIP like the IIP/LimitedSharpen combo you made!

VictorD
28th December 2004, 14:17
Didée
Exellent script. Thanx to U and Socio I can use it with ffdshow.

Can I ask you about^
1. Can you recomend denoiser(s) with parameters for light, medium and strong dvd noise, that are not so CPU intensive ? Can it be in your script ?
2. Can "autocrop" can be done by script ? Autocrop plugin do not work with ffdshow. Can it be in your script ?
3. Is the splitting luma and chroma for denoising, resizing and sharpen by different algorithm good idea ?
4. Is adding to the end of you script a little "wow effect" edge contrast enhancement is good ? And what is your recomendations ?

Thankx again.

DeepDVD
28th December 2004, 16:15
Originally posted by Didée
Next version makes steady progress. Can't say if I'll get it baken 'til this week's end ... but I think it's worthwile waiting for it. Although I'm not sure if the current name still will be suited ... it gets more in the direction of "Sharpening Suite", or something like that ... :)

Stay tuned, but don't hold your breath until.

As i see it on my calendar the weekend was veeeery long ... 26 days til now ^^

Didee, i'm begging... please give us your new version ;)

Didée
29th December 2004, 02:19
Welcome to our little forum, VictorD.

It's not fully clear to me if all your questions belong to realtime usage through ffdshow - however:

1. Uh, I never bothered too muc about realtime denoising. From ffdshow's internal filters, 'temporal', 'gradual', and 'mplayer temporal' should be fast enough to run along LimitedSharpen. Of the avisynth filters, 'FluxSmooth', 'Convolution3D'(yv12) and good old 'temporalsoften' should be appliable. And probably some more that currently don't come to my mind.

2. Autocrop in realtime? Don't think that's possible - Firstly autocropping needs some analysis that obviously can't be done in realtime. Secondly, cropping alters the frame size, and the framesize gets fixed during the creation of the DirectShow graph, and AFAIK can only be altered again by recreating the graph.
For not-realtime encoding, there are autocrop filters that do their job - but I haven't used such a one once.

3. Yes.

4. If you like, you can add so much EE as you want. I'll cry murder, then. The whole aim of LS is to sharpen without EE - if you're going to add it afterwards, you can completely drop LS out, and enjoy the effect of a simple 'sharpen()' ;)
The "wow effect" is included in the next version. But bad news, the wow will d.e.f.i.n.e.t.l.y will not run in realtime ...


DeepDVD:

Mind you, I know. Developping problems. Of all new features, the cores themselves were working, but the integration in LS, the integration :devil:
And the special feature (greetings to MSU ;-) ) drove me crazy: Had it running, broke it, had it running ... broke it more than hundred times, repaired it same often ... wondered on which of the past five 5-junctions another way would've been the right one instead of the chosen ... and finaly took a footpath instead of any way. See, the script is a chain of inter-knotted knots ...
It's all up'n'running now. One additional knot, and some finetuning ... with alittle luck, within the old year.

From a two weeks old intermediate version: (1) This (http://img148.exs.cx/my.php?loc=img148&image=1323o8fz.jpg) to that (http://img148.exs.cx/my.php?loc=img148&image=1323ls29tl.jpg), (2) this (http://img148.exs.cx/my.php?loc=img148&image=1500o3gn.jpg) to that (http://img148.exs.cx/my.php?loc=img148&image=1500ls21uq.jpg), (3) this (http://img148.exs.cx/my.php?loc=img148&image=3525o0oq.jpg) to that (http://img148.exs.cx/my.php?loc=img148&image=3525ls26ed.jpg), and (4) this (http://img148.exs.cx/my.php?loc=img148&image=4935o3ho.jpg) to that (http://img148.exs.cx/my.php?loc=img148&image=4935ls25xh.jpg).
(Orig: encoded@712*424(original) / screenshot lanczos-resized. LS-EX: encoded@720*544 / screenshot lanczos-resized.)

In the meantime it has become more graceful, sharper, and the EE artefacts have vanished.

VictorD
29th December 2004, 10:56
Thanx. Yes all questions about only realtime usage.

"Is the splitting luma and chroma for denoising, resizing and sharpen by different algorithm good idea ?"

3. Can you (or it's allready done by your script ?) tell me about it more:
a) how can I split luma & chroma in right way:
- luma (proceed) -
clip - - clip
- croma (procced) -
b) what is good (or need to know) for denoising luma / croma ?
c) can luma & chroma be resized by different chains & how ?
d) what is good (or need to know) for sharpen luma / croma ?

Can you provide some good startup example ? I'm just the beginer and want to know what can be done.


"""4. If you like, you can add so much EE as you want. The whole aim of LS is to sharpen without EE - if you're going to add it afterwards, you can completely drop LS out, and enjoy the effect of a simple 'sharpen()'"""

I understand, but for "all in one" script can you did like: 1)EE, 2)LS, 3)99% LS + 1% EE. I realy like your script and looking forward for your next version. I think it's can be revolution#2 (#1 is ffdshow) for realtime DVD show.

Didée
29th December 2004, 15:22
to a) and c) :

Exactly speaking, a true "splitting" into Luma/Chroma is not possible in AviSynth2. A YUV clip always has three planes, a single plane (greyscale) colorspace does not exist.
But one can build a clip by mixing together the planes of other clips, and that is one way how individual plane treating usually is done. The other way is to use filters that can be explicitely told to work only on certain planes.

E.g. to use sharp luma resizing together with soft chroma resizing, one would do:

source = last

soft = source.bilinearresize(x,y) # soft
#soft = source.bicubicresize(x,y,1,0) # very soft
sharp = source.lanczosresize(x,y)

sharp.MergeChroma(soft)


to b) :

There are hundreds of different denoising filters out there, for a reason: denoising is not a trivial task, and all depends on noise characteristics, personal taste, and available processing time. For realtime usage, the ones mentioned in previous post should be the ones to try first (plus denoise3Dhq, but that probably draws too much CPU cycles to run along LimitedSharpen in realtime).


If you're watching your DVDs on a PC monitor, you might try out the YlevelsG/S/C (http://forum.doom9.org/showthread.php?s=&threadid=79898) functions - they might give a little "wow" effect, too ;)
(Note: these are also to find in recent ffdshow versions - but the port seems to have been a little buggy: the effect of ffdshow's Ylevels is not the same as when using my functions - pity ...)

dvwannab
30th December 2004, 18:15
Didee' and others, whoever you may be, THANK YOU for this filter. I am still a somewhat newby to avisynth and last week and again yesterday I used the limitedsharpen filter and the results yesterday were astounding. NOW THATS SHARP!!!! :D

I have used:

LimitedSharpen(ss_x=2,ss_y=2,Smode=3) SHARPness increased slightly

LimitedSharpen(ss_x=2,ss_y=2,Smode=3,strength=100) REAL SHARPENING and no visible artifacts

Great job!

Backwoods
31st December 2004, 01:01
Originally posted by Didée
The "wow effect" is included in the next version. But bad news, the wow will d.e.f.i.n.e.t.l.y will not run in realtime ...

Happens, for quality I can wait. Looking forward to it.

State of Mind
31st December 2004, 01:06
I don't really think a source can be sharpened without having edgy looks everywhere...making the image look like a sheet of glass with small cracks everywhere...well, bad way of putting it, but I'd have to see some screenshots. Plus, using the maximum strength of a filter such as sharpening IMO would make the image too sharp. Is this filter really different? I am unable to try it since I am waiting for a new mobo and my current one doesn't detect hardware such as my firewire so I am unable to access the videos on my external HD or upload video. Anyway... I'll give this a shot when things return to normal for me.

State of Mind
31st December 2004, 01:12
On another note, I _personally_ don't care much about the speed of a plugin. I mean, if it is truly the best of its kind, then it should be well worth such a wait, I think. As long as it doesn't take 24 hours to render a 5 minute clip, you know. But if people refer to 3, 4 or 5 fps as slow, then I have to disagree with them. I remember when I first dealth with video rendering in Ulead VideStudio and it would take all night to do a 15 minute clip with my videocard (at the time it was a Voodoo 4 4500 AGP), and that didn't bother me.
I am still pretty new to this stuff, but me and my friends did backyard wrestling today and I know the source video of my DVC isn't going to be perfect. There will be noise, I might want to sharpen, enhance the colors, etc... but I'd rather use the plugins and codes you people use than use some All-In-One application that does a crap-ass job.

Cheers to all and Happy New Year,
Jeremy

ObiKenobi
31st December 2004, 03:02
Here are some shots for you:

Source (notice the major haloing):

http://img159.exs.cx/img159/5422/original5gr.png

After BlindDeHalo2(2.5,2.5,100) & HQDering(255):

http://img159.exs.cx/img159/7864/blinddehalohqdering5xt.png

After LimitedSharpen(ss_x=2.0,ss_y=2.0,Smode=3,strength=100):

http://img159.exs.cx/img159/4273/limitedsharpen0fn.png

While I won't say that no artifacts are introduced to the picture, cause that would be untrue, but the sharpening artifacts are significantly less then that in the source and the picture is very sharp looking.

Didée
31st December 2004, 03:39
Nice example, ObiKenobi.

StateOfMind's doubts have some ground, though. In digital images, "sharpness" cannot get beyond a certain limit: the aliasing limit. Beyond "sharpness", there's nothing but aliasing to come. That's "geometric" sharpness, if I can say so. "Perceptual sharpness" is more about contrast than about edge sharpness - but there arise other problems: edge halos, loss of gradient shades, and so on.
So, a source that is rather clean, but is soft or blurry, is a perfect target for sharpening. If OTOH one takes a source with good sharpness and contrast, and tries to further enhance this one, than there is big danger of doing more harm than good - if sharpness and contrast are already @ MAX, then the story has reached its end. Unless one is going to upsize the source, since that gives additional headroom for sharpening.


LOTR TTT, original:
http://img98.exs.cx/img98/8906/84464source2wn.png

Trying something, despite all doubts:
http://img98.exs.cx/img98/3237/84464lsex3wp.png

;)

ObiKenobi
31st December 2004, 04:36
Just for fun, here's another example for you.

Original:

http://img83.exs.cx/img83/4342/original24rw.png

LimitedSharpen(ss_x=2.0,ss_y=2.0,Smode=3,strength=100):

http://img83.exs.cx/img83/7195/limitedsharpen25rh.png

State of Mind
31st December 2004, 11:20
Wow...I saved the images and compared by looking back and forth about 50 thousand times in IrfanView, LOL...and I can say that I'll definitely be using this filter with my DV sources if necessary. Experimentin will sure be fun for a kid at heart like me!

Didée, good points. :)

Thank you all for the screenshots. Muchly appreciated.

Cheers,
Jeremy

Soulhunter
2nd January 2005, 01:12
*cough (http://forum.doom9.org/showthread.php?s=&threadid=87514)*

Didée
2nd January 2005, 02:42
/*hands over cough syrup to plagued Soulhunter*/ ;)

ADLANCAS
16th January 2005, 03:18
Hi,

In interlaced sources, do you recommend to use limitedsharpen between separatefields and weave or is there a better way to use it ?

thanks,

Alexandre

Mug Funky
16th January 2005, 03:46
good question. i'd say bob first then limitedsharpen. interlaced sources should be kinda blurry in the vertical direction, otherwise you're driven mad by bouncing lines when you watch it on a TV.

i'm too lazy to look through the source right now, but is there a way to limit limitedsharpen (hehe) to the horizontal axis only? that would allow interlaced processing without bobbing, and would also be useful for those annoying half-size-upscaled DV cameras out there, where horizontalreduceby2 + lanczos(720,height) actually makes them look better, and limitedsharpen finishes the job.

Didée
16th January 2005, 16:42
That's a problem. I suggest waiting for LS-EX to get finished.

First point is that most sharpeners can't be restricted to work in one direction only. In fact, "sharpen()" is the only one that offers that possibility. LS-EX will additionally offer a custom unsharp masking, that can work in only one direction - aiming mainly at sharpening VHS captures, but probably also for those DV sources Mug Funky mentioned.

Second point is that getting the neighbor's extrema is currently done by "inpand()" and "expand()", which is reasonably cheap and fast. Building an according functionality that works on only one axis is cumbersome, and would be rather slow, in comparison.

What's generally better for the interlaced case - well, I just can't tell you. Either seperate/weave, or dumb|smart bobbing + re-weaving. I never aim for interlaced output, and very seldom deal with interlaced input at all. So try for yourself, and share your findings ;)

For the time being, there are two possibilities to sharpen only (or ~mostly~) horizontally:

1) use double or triple as much vertical supersampling than horizontal. This gets pretty slow, though.

2) Use "Smode=2", and make yourself the following change to the function:
normsharp = Smode==1 ? unsharpmask(strength,radius,0)
\ : Smode==2 ? sharpen(float(strength)/100.0 ,0)
\ : yv12lutxy(tmp,minmaxavg,yexpr="x x y - "+Str+" * +")

I don't want to make much changes or additions to the current LimitedSharpen, as it is a rather compact, small and straightforward function. The upcoming LS-EX function will be, again, one of the monumental ones :eek: :)

Mug Funky
16th January 2005, 16:56
hehe, i'd already made that hack earlier today. couldn't say how successful it was - i simply discovered how vertically unsharp my DV source was as well.

man, consumer-level DV will be the death of me. if i have to do any more editing of some guy's crappy handheld-in-the-crowd of some gig or other, i'll scream. people should be required to get a license to use a DV cam (and there should be a way to turn the compressor off and set a manual recording level).

oh, and there should be a ban on LP mode enforced with heavy sack beatings.

xriderbc
18th February 2005, 21:58
Any new updates?

Leo 69
7th March 2005, 21:21
Please someone help me... Through all day long I can't load it at all !!!

I have MaskTools.dll (1.5.1), Warpsharp.dll from 2003.11.03 package,
and limitedsharpen.avsi script from the first page of this thread.

This is my script:

-------------------------------------------
LoadPlugin("C:\PROGRA~1\GORDIA~1\AviSynthPlugins\dgdecode.dll")
LoadPlugin("C:\PROGRA~1\GORDIA~1\AviSynthPlugins\Loadpluginex.dll")
LoadPlugin("C:\1\Warpsharp.dll")
LoadPlugin("C:\1\MaskTools.dll")
LoadPlugin("C:\1\limitedsharpen.avsi")

mpeg2source("C:\Cradle\Cradle.d2v")

crop(10,0,694,570)


Lanczos4Resize(688,400)
Deen()
YlevelsS(0,1.5,255,0,255)

-----------------------------------------
What am I doing wrong ? I am at a loss :( I have ALL possible msvcr's & msvcp's in my windows\system32 directory. And still:
Avisynth open failure... etc.

Ark
7th March 2005, 23:57
.avsi?

LM is simply a script, not a plugin, so you have to rename it to .avs, then do:

Import("C:\1\limitedsharpen.avs")

Leo 69
8th March 2005, 00:04
It doesn't work, Ark. Any ideas ? I tried so many ways of loading this
script... Gouch.. Can anyone upload his folder with all the stuff somewhere ? I would be extremely grateful :)

L'il Jerry
8th March 2005, 00:14
Originally posted by Ark
.avsi?

LM is simply a script, not a plugin, so you have to rename it to .avs, then do:

Import("C:\1\limitedsharpen.avs")

Actually naming it to .avsi means you don't have to use import as it will just autoload it.

L'il Jerry
8th March 2005, 00:15
Originally posted by Leo 69
It doesn't work, Ark. Any ideas ? I tried so many ways of loading this script...

How do you know this has anything to do with LimitedSharpen? Have you tried removing it to see if the script then loads, or if maybe its one of the other plugins causing a problem? Try isolating the problem by removing plugins or commands to see what exactly is causing the problem, then we can help you. I'm also wondering why you are loading it since its not even being used in the script itself, unless you just haven't posted your complete script.

Leo 69
8th March 2005, 00:35
L'il Jerry, I can't use it until I load it properly. OK, I removed ALL plugins from autoload directory.This is the script which works OK but it doesn't work without # before LoadPlugin("C:\1\limitedsharpen.avs"), I get a message "Avisynth open failure":

------------------

LoadPlugin("C:\PROGRA~1\GORDIA~1\AviSynthPlugins\dgdecode.dll")
LoadPlugin("C:\PROGRA~1\GORDIA~1\AviSynthPlugins\Loadpluginex.dll")
LoadPlugin("C:\1\Warpsharp.dll")
LoadPlugin("C:\1\MaskTools.dll")
#LoadPlugin("C:\1\limitedsharpen.avs")
mpeg2source("C:\Cradle\Cradle.d2v")
crop(10,0,694,570)
Lanczos4Resize(688,400)

------------------

L'il Jerry
8th March 2005, 04:20
Try upgrading to the newest MaskTools (http://manao4.free.fr/MaskTools-v1.5.6.zip) the newest version is 1.5.6 and see if that helps at all.

jrsdsl
8th March 2005, 05:30
Originally posted by L'il Jerry
How do you know this has anything to do with LimitedSharpen? Have you tried removing it to see if the script then loads, or if maybe its one of the other plugins causing a problem? Try isolating the problem by removing plugins or commands to see what exactly is causing the problem, then we can help you. I'm also wondering why you are loading it since its not even being used in the script itself, unless you just haven't posted your complete script.

Might not solve your problem, but I was having difficulty in loading the LimitedSharpen script also. I copied and pasted the script into wordpad and then save it as LimitedSharpen.avsi. I tried loading VirtualDubmod and it wouldn't. It had been loading prior to my placing the LimitedSharpen script in my plugins folder.

Removed LimitedSharpen.avsi from the plugin folder and then Vdudmod would load. Hmm. Copied and pasted the script again in wordpad but saved it as text not RTF as I had originally done. LimitedShapen autoloads and manually loads when I changed it to LimitedSharpen.avs as a test.

Leo 69
8th March 2005, 09:10
Upgrading to the latest MaskTools didn't help... Can anyone copy n' paste a working script of limitedsharpen ? Actually I never had problems with Avisynth like this before...

Zom-B
8th March 2005, 14:35
How about opening your avs file in Media Player Classic!
If there is some problem with the plugins or whatever the Player
showes you some information where exactly the problem is (but this doesn't help allways!).
Great for debugging!

Hope I could help...

Leak
8th March 2005, 23:09
Originally posted by Leo 69
This is the script which works OK but it doesn't work without # before LoadPlugin("C:\1\limitedsharpen.avs"), I get a message "Avisynth open failure":

This really is to be expected - LoadPlugin will only load windows DLL files that are AviSynth plugins, *NOT* script files like LimitedSharpen.

Either use Import("C:\1\limitedsharpen.avs"), or rename it to limitedsharpen.avsi and put it in your plugin directory, but stop trying to load something with LoadPlugin that isn't a plugin...

np: Up, Bustle & Out - Los Locos Cubanos (Snowboy Mix) (Xen Cuts (Disc 2))

kingmob
10th March 2005, 15:46
Is it expected that upping ss_x and ss_y actually makes the output softer? somehow this is counterintuitive for me...

Didée
10th March 2005, 16:18
That's the behaviour to be expected. Nothing wrong with that. The bigger the used supersampling, the smaller the range of the fixed 3*3 (default) or 5*5 (wide=true) neighborhood window gets, wich consequently lessens the maximum possible change for a pixel.

For ss values > 1.5~1.75, you could use wide=true, and bigger strength as well.

Leo 69
13th March 2005, 12:23
At last I managed to load this script ! In fact I saved the script in Unicode format before so it became unusable. Now I saved in UTF-8 and
everything's okay. Thanks to those who tried to help me :)


Cheers

leonid_makarovsky
14th March 2005, 18:32
Do you happen to have the script or do you have any plans to make limitedsharpen in YUV colorspace? Thanks

--Leonid

Didée
15th March 2005, 08:52
Sorry, I dont't understand your question. Please rephrase.

leonid_makarovsky
15th March 2005, 15:40
Currently you convert the clip in YV12 colorspace inside your script. Do you have plans to do LimitedSharpen in YUV colorspace?

Thanks.

--Leonid

Didée
15th March 2005, 16:02
YV12 *is* a YUV colorspace. You probably mean LS should support YUY2 ...

This is not directly possible. The internal transformations are done with the command "YV12LUTxy()" -- the name speaks for itself.

However, if you feed a YUY2 clip to LS, then you get back the original, fully untouched YUY2 color planes - not the ones downsampled by ConvertToYV12 (since I copy back the color planes of the input clip at the very end).

3ngel
25th March 2005, 07:34
@Didée
Wow..! It's very very impressive even at default mode!
Very very compliments! :)
Now, can you suggest me a setting to enhance only those little details like a small beard on a face straight in front the camera, or little visage lines, in other words, those small details that makes a look more photorealistic-like rather than film-like? I don't mind Cpu time.
Thanks for now :)

leonid_makarovsky
25th March 2005, 08:11
Originally posted by Didée
However, if you feed a YUY2 clip to LS, then you get back the original, fully untouched YUY2 color planes - not the ones downsampled by ConvertToYV12

I see. Great. Thanks. So you weren't doing the YUY2->YV12->YUY2 conversion, right?

--Leonid

Didée
25th March 2005, 21:01
Originally posted by 3ngel
can you suggest me a setting to enhance only those little details [...]
Enhancing only these is a tricky task. You could try setting "wide=true", and see if that's more to your liking. Eventually with another Smode, probably "=1".

However, digging out faint detail is not the job where LS is best at. For such purposes, I would rather try iiP -- the intention for iiP was exactly this: enhance faint detail (but not the noise).

The upcoming big brother of LS will offer good alternatives to both of them. Alas the gestation progress is quite problematic. Let's hope the best ;)


Originally posted by leonid_makarovsky
I see. Great. Thanks. So you weren't doing the YUY2->YV12->YUY2 conversion, right?
Yes. No. Both. ;)

I must do the conversion, to be able to process YUY2 input at all.

So, at first the YUY2 color planes are "parked". Then the input gets converted & the luma processed. At the end, the parked chroma planes are copied back, and the output contains the sharpened luma plane plus the virgin color planes.

VictorD
29th March 2005, 15:33
Do we still have to looking for new version ?

Thanx.

kingmob
19th April 2005, 14:21
Currently a code like this one:

Limitedsharpen(ss_x = 1.5, ss_y = 2,dest_x = 720, dest_y = 480,strength = 200, exborder = 4)

runs at 0.18 relative speed for me in cce. What should i generally tune (besides ss_x and ss_y) to make it faster?
I guess what i'm asking is, which of the options gets you a speed boost by turning it on/off, lower/higher?
I get the trade-off between supersampling and strength, are there any others?

Didée
19th April 2005, 15:02
- Smode=3 (default) is the slowest. Smode=1 is somewhat faster. Smode=2 is the fastest.

- Processing a YUY2 clip is slower than processing a YV12 clip.

- Using "exborder=true" slows down the process (one additional MaskedMerge() is done).

- Processing a YUY2 clip +plus+ using "exborder=true" is the slowest possible combination ...


So, activate "exborder" only if it is absolutely unavoidable. If it's possible to get clean borders by some minor additional cropping, this would be preferable.

Smode=2 is the fastest, but doesn't allow as strong sharpening as the modes 3 and 1 do. Therefore, you should try "Smode=1" together with "radius=1".

It would be possible to integrate kassandro's "limitchange" into the script, to increase performance. However, in its current form this one allows only "hard clipping". All the neat stuff like "overshoot", "Lmode=2" and "wide=true" would not be available, and usage of Smode=3 would cut the possible benefit immediately to half again.

The biggest braker is the supersampling, anyways.

kingmob
19th April 2005, 15:38
Thx, gonna do some extra tweaking :)
Btw, i thought radius was ignored for smode=3?

Didée
19th April 2005, 16:02
Yes indeed, that was a typo. While typing the post, meself lost track of all the modes & parameters :D

- Corrected, thanks.

Capirossi
28th April 2005, 20:49
incredible :cool:

TiaoMacaleh
2nd May 2005, 18:19
Use a denoiser beforehand.


Which one you recommend?

unskinnyboy
2nd May 2005, 19:14
Originally posted by TiaoMacaleh
Which one you recommend?
If you can afford the encoding time, I'd recommend PixieDust().

communist
8th May 2005, 20:06
Slightly OT - Didée you dont somehow work for Sony do you?
I was looking for something when I came up to this (http://bssc.sel.sony.com/BroadcastandBusiness/docs/brochures/bvp900_50.pdf) (direct link to PDF, look at page 5) and I thought I've seen this somewhere.. ;)
Adaptive Detail Control on the one side and 'Electronic Soft Focus' on the other. Their graphs do illustrate how to do 'smart blurring'.

Oh and nice job on your original illustrations :)

leonid_makarovsky
15th June 2005, 03:16
I have the following question. I wanted to convert some footage from PAL to NTSC and apply limitedsharpen. My plan was to replace the LanczosResize function with limitedsharpen right in the middle of conversion. Here's what I had in mind:
AVISource("pal.avi")
AssumeFrameBased()
AssumeTFF()
SeparateFields()
PixieDust() # clean VHS
fft3dFilter() # more noise reduction
Weave()
TDeint(mode=1,order=1,type=2)
LimitedSharpen(dest_x = 352, dest_y = 480)
ConvertFPS(59.94)
AssumeFrameBased()
AssumeTFF()
SeparateFields()
SelectEvery(4,0,3)
Weave()

So is it a good idea to stick limitedsharpen in the middle of all this. Or should I do it either before or after?

Thanks.

And by the way, inside LimitedSharpen, I replaced LanczosResize with Lanczos4Resize.

--Leonid

leonid_makarovsky
28th June 2005, 21:07
The default ss_y parameter which is equal to 1.5 gives HORRIBLE results. I used it with all the modes for PAL video 704x576. Changed to ss_y = 1.

--Leonid

Didée
29th June 2005, 09:20
The default ss_y parameter which is equal to 1.5 gives HORRIBLE results. I used it with all the modes for PAL video 704x576.
You're funny. I assure you that ss_y=1.5 delivers much better results than ss_y=1.0. Unless a PEBCAK error takes place, that is. ;)

The wording "PAL video" suggests you're dealing with interlaced footage. Applying LimitedSharpen to interlaced footage is a big NO-NO.

LS is for progressive content only. For your interlaced source, put it between SeparateFields() and Weave(), as you did for the other progressive filters.
Moreover, sharpening after deinterlacing generally might give problems -- a smart deinterlacer usually is set up let minor combing sneak through. Without sharpening, that's okay. But when sharpening afterwards, the weak residual combing will bite you back...
Plus, almost all deinterlaces produce line shimmering. Some do more, some do less ... but they all do. Sharpening doesn't exacly help on the shimmering problem.

Last time I had to deinterlace and (strongly!) sharpen a combed source, I switched to double-height deinterlacing plus additional post-supersampling (by ELA) to bring the shimmering down.



@ communist

Ooops, completely forgot to answer on that one :o

No. Regarding video processing, neither I work for Sony, nor for any other company. Perhaps I should, but contract offers so far sum up to zero ...

However, similar ideas may coincidentially appear simultaneously. E.g. it is said that another man invented the long-glass at about the same time than DaVinci did. In fact, this is a common phenomenon. History is full of examples where the same kind of thing suddenly was inventend almost simultaneously, but fully independend, by different minds. (Think about Sheldrake's idea of Morphogenetic fields...)

This doesn't exclude the possibility that some of the ideas I have posted in this forum might have appeared in commercial products. Someone told about a PhotoShop plugin containing a sharpener which results looks pretty similar to LimitedSharpen. Lately I've stumbled over several DVD releases (doodad in TV illustrates) with very little noise and pretty good sharpness, where the overall characteristics strongly reminded me of iiP(). And a week ago, I captured a snip of (the original, old) "War of the Worlds" by DVB, which contained a form of "textured" noise, almost exactly like what is generated by the premature "noise factory" I posted here (http://www.neuron2.net/board/viewtopic.php?p=5622#5622).

Coincidences or not - what I can assure you of is that everything I have, do and will post about video processing, has grown in my own grey cells. And in cases I make use of ideas brewed by other people, sure as anything I give credit.
(I couldn't sleep well when selling other's ideas as my own.)

psme
29th June 2005, 09:52
Hi Didee,

Someone posted a strip down version of the LimitedSharpen at AVSForum HTPC forum LimitedSharpen discussion here http://www.avsforum.com/avs-vb/showthread.php?p=5816796&&#post5816796

Maybe you can comment if it's the right way to work! :)

regards,

Li On

Soulhunter
29th June 2005, 10:13
...the premature "noise factory" I posted here (http://www.neuron2.net/board/viewtopic.php?p=5622#5622).
Nice, this could become very useful for some of this "uber smooth (TM)" sources... ^^

Now I wait for this "more noise to smooth areas / less noise to detailed areas" thing !!!


Bye

videoFred
29th June 2005, 10:17
However, similar ideas may coincidentially appear simultaneously. E.g. it is said that another man invented the long-glass at about the same time than DaVinci did. In fact, this is a common phenomenon. History is full of examples where the same kind of thing suddenly was inventend almost simultaneously, but fully independend, by different minds. (Think about Sheldrake's idea of Morphogenetic fields...)


Yes, there must be a Source of good ideas, out there (everywhere?)
And you must have a very good resciever in your mind.
And if you have the attitude not claiming credits for other people ideas, then you always rescieve new ideas of your own.

Paul Mc Cartney always said he just could pick the songs out of the air.. ;)

Fred.

Didée
29th June 2005, 10:30
@ psme

Looks okay so far, nothing false with that.

However, for this kind of coarse realtime processing without any supersampling, why at all make a "mod" of LimitedSharpen, that doesn't really deserve the name anymore?

You can get almost the same, and even faster, by using something like

import(".../RemoveGrain.dll")
import(".../unfilter.dll")

# use either one or the other of the following two lines
# repair(sharpen(.3),last, 1,1,1) # chroma is sharpened, too
# repair(unfilter(30,30),last, 1,0,0) # chroma untouched, even faster)

in ffdshow's AviSynth tab. A one-liner, that's all that's needed ;)

Practically, that script is kassandro's "ModerateSharpen".

Didée
29th June 2005, 10:43
And you must have a very good resciever in your mind.Latent sensitive, yes.

And if you have the attitude not claiming credits for other people ideas, then you always rescieve new ideas of your own.
Huh, adresses this to me?

Sure, mind & memory play a big role. Time back, you saw or heard something, but immediately "forgot" it again. Then, weeks or months later, all of a sudden you have a brilliant "idea" ... ;)
True forgetting, in the sense of "loosing/erasing information" is almost impossible to human's brain. ( edit :devil: )


@ Soulhunter:

Take an edgemask in your left hand. Take the differently noised clips in your right hand.

Then clap hands.

videoFred
29th June 2005, 10:52
True forgetting, in the sense of "loosing/erasing information" is almost impossible to human's brain. haha, EDIT quote :devil: But I understood...

Maybe the DOS command 'format b:' (b=Brain) :D

Fred ;)

Soulhunter
29th June 2005, 11:02
@ Didée

Differently noised clips...

Smells already like ~1fps !!!


Bye

Didée
29th June 2005, 12:59
C'mon, no ...

s = source
n = o.MakeMuchNoise()
e = o.MakeEdgeMask() .expand .MakeBlurry(much)

MaskedMerge(o,n,e)
where the gain of 'e' controls how much of the generated noise is applied to edges. If max.luma of 'e' is 128 --> hard edges get 50% of the noise. Difficult like tieing shoes. ;)

Soulhunter
29th June 2005, 15:05
C'mon, no ...

s = source
n = o.MakeMuchNoise()
e = o.MakeEdgeMask() .expand .MakeBlurry(much)

MaskedMerge(o,n,e)
where the gain of 'e' controls how much of the generated noise is applied to edges. If max.luma of 'e' is 128 --> hard edges get 50% of the noise. Difficult like tieing shoes. ;)
Shouldnt it be...

O = TheSource()
N = O.AddMuchNoise()
E = O.MakeEdgeMask().Expand.UberSmooth()
MaskedMerge(O,N,E)


No matter, with "smells like 1fps" I meant the denoising...

Coz you have to use a smart (so very slow) denoiser to get it work (in a proper way) no?


Bye

Didée
29th June 2005, 15:08
A denoiser? For adding noise?

leonid_makarovsky
29th June 2005, 15:45
You're funny. I assure you that ss_y=1.5 delivers much better results than ss_y=1.0. Unless a PEBCAK error takes place, that is. ;)

The wording "PAL video" suggests you're dealing with interlaced footage. Applying LimitedSharpen to interlaced footage is a big NO-NO..

I didn't know that. And I also don't know what PEBCAK error is. But when I had ss_y = 1.5, the image was blurry and had some sort of duplicated objects shifted. I can post the images later on when I come back home.


LS is for progressive content only. For your interlaced source, put it between SeparateFields() and Weave(), as you did for the other progressive filters.

I will try that tonight. From what I remember I did try it on the single field, but wasn't happy with results so I carried out sharpen after Weave.

Now, do you recommend Smode = 1, 2 or 3?

Moreover, sharpening after deinterlacing generally might give problems -- a smart deinterlacer usually is set up let minor combing sneak through. Without sharpening, that's okay. But when sharpening afterwards, the weak residual combing will bite you back...
Plus, almost all deinterlaces produce line shimmering. Some do more, some do less ... but they all do. Sharpening doesn't exacly help on the shimmering problem.

Last time I had to deinterlace and (strongly!) sharpen a combed source, I switched to double-height deinterlacing plus additional post-supersampling (by ELA) to bring the shimmering down.

I don't intend to de-interlace the footage? Why? All I am doing is creating the interlaced PAL DVD out of interlaced PAL VHS.

--Leonid

Soulhunter
29th June 2005, 15:54
A denoiser? For adding noise?
Erm, for the "Smooth" EdgeMask...

Guess I understood ya idea wrong !?!


Bye

Karyudo
1st July 2005, 03:30
I also don't know what PEBCAK error is.

'Problem Exists Between Chair And Keyboard'

TheKolkster
20th July 2005, 02:55
Sorry guys, I'm lost here. Is this an actual plugin or just a script?

unskinnyboy
20th July 2005, 02:58
Sorry guys, I'm lost here. Is this an actual plugin or just a script?
It is a *function* which you should import into your avs script and then invoke by passing arguments. You can also call it a script if you want. It is not a plugin per se in that it is not a DLL.

TheKolkster
20th July 2005, 03:05
It is a *function* which you should import into your avs script and then invoke by passing arguments. You can also call it a script if you want. It is not a plugin per se in that it is not a DLL.

Okay, I see. I was getting help with this earlier and thats what I've been doing, but I thought it was weird that it wasnt a plugin. Also, it doesnt work for me. When I try to load my avs script in vdub, I get an error saying "There is no function named LimitedSharpen". Do I import a blank avs script named "LimitedSharpen.avs"?

unskinnyboy
20th July 2005, 03:11
Okay, I see. I was getting help with this earlier and thats what I've been doing, but I thought it was weird that it wasnt a plugin. Also, it doesnt work for me. When I try to load my avs script in vdub, I get an error saying "There is no function named LimitedSharpen". Do I import a blank avs script named "LimitedSharpen.avs"?
If you import a blank LimitedSharpen.avsi (it is avsi btw), then what are you calling in your script? :confused: Of course, it is not able to find that function. In the first page of this thread, you will find the function. Save that as LimitedSharpen.avsi, import and invoke that.

If you haven't read this thread yet properly, please do that first.

TheKolkster
20th July 2005, 03:20
lol, sorry, I didnt know what that was. When I was directed to this thread, I was looking for a download link. I didnt realize it was the function. (Even though I read over it a couple of times) Now it makes sense, thanks :)

Chainmax
20th July 2005, 06:19
...(it is avsi btw)...import and invoke that.
If he uses it as an avsi he doesn't have to import it. And it can be an avs for manual loading.


/obnioxious nitpicking mode off ;)

videoFred
12th August 2005, 12:07
Many old 8mm filmscenes where taken out of focus.
And even good focused 8mm filmframes are not that sharp.
For several reasons a projected film looks a lot sharper.

So for my captured 8mm film files I need a very good and strong sharpener.
It took a while before I realised how good limitedsharpen() realy is!
For my purpose I need smode=1 , and strenght above 500!


Here is a result:
(I also use overlay() with a BW/reversal mask to bright up the dark parts)
Not bad for 8mm film, hug? :D

http://users.telenet.be/ho-slotcars/testmap/erik3.jpg


Now this looks wonderful both on computer and on TV.
But if I enlarge the picture and if I modify brightness I see these artifacts:

http://users.telenet.be/ho-slotcars/testmap/artefacts.jpg


The question is: what are these artifacts and how to prevent/remove them?
The artifacts are not caused by the overlay, I see them on the (sharpened)original, too.
Maybe limitedsharpen() amplifies something that is already in the original?

Thanks!
Fred.

Mug Funky
12th August 2005, 14:04
looks like you're sharpening so much that it's running into quantization noise.

looks to me like you need more than 8 bits to sharpen that hard. there may be an elegant way to prevent sharpening of edges that are 1/255 apart. not sure how much it would complicate and slow down the script though (Didee?).

[edit]

btw, that looks really good. film might need a bit of colour adjustment though - grass looks a bit aqua

videoFred
12th August 2005, 14:36
looks like you're sharpening so much that it's running into quantization noise.

Thank you for the fast answer! :p
What is quantization noise, and is there a way to remove it from the original to begin with? :confused:

Here's another example of the power of limitedsharpen(),
it also proves of the quality of real film.
The dog Bessy way back in.... 1968!!
Wait a moment... do I hear music? :cool:

http://users.telenet.be/ho-slotcars/testmap/bessy.jpg


Fred.

Didée
12th August 2005, 15:27
not sure how much it would complicate and slow down the script though

For Smode=1, it would require quite some operations .. at least

- one inpand
- one expand
- four yv12lutxy's:
* 1x getting local detail strength (A)
* 1x producing difference(orig, sharpened) (B)
* 1x modifying (A) with (B) --> (C)
* 1x applying (C) to input

Would be rather slow when done on the supersampled source, and not very fast when done at the original resolution ...

The better news is that Smode=3 can be modified to do almost the same, with >zero< speed penalty. :)
(That "sharpen2"-function surely is floating somewhere on my HD's ... perhaps I'll manage to retrieve it ;) )


@ videoFred:

Did you also try Smode=3? Is it suitable in your case, generally?

And: what's the exact script you used for the B/W reversal? For this operation it is *very* important to blur the mask. This will suppress lots of small fluctuations, which else may lead to artificial amplifications. (Check >>histogram(mode="levels")<< before and after the operation!)
I'd suggest to use at least blur(1.58) (better RemoveGrain(11) or (19) ), or even a small gaussian blur on the B/W mask.

***

There are also some small-but-efficient tricks that can be done by limiting, which turn simple blurring operations into something like "noise downshifters" - especially when linked into the middle of the sharpening chain. But that's rather specific, one has to try a few possibilities to find the one that really bites.
Example: A basic one I use rather frequently (as a preparation for moderately noisy DVB captures, prior to sharpening) is this:
SmoothLimit = 3 # 1 to ??? (5? 9? 11?) # (Change no pixel by more than +/- this value)

#---------------
o = last
SL1 = string(SmoothLimit)
SL2 = string(SmoothLimit*1.67)
yv12lutxy(o, o.removegrain(4),
\ "x "+SL2+" + y < x "+SL1+" + x "+SL2+" - y > x "+SL1+" - x 49 * y 51 * + 100 / ? ?",U=2,V=2)

videoFred
12th August 2005, 15:51
Did you also try Smode=3? Is it suitable in your case, generally?

And: what's the exact script you used for the B/W reversal? For this operation it is *very* important to blur the mask.

Hello Didée,
Thank you for supporting this exellent function.

Yes, I tried it.. Smode=3 works also, but Smode=1 is better.

Here is the mask script:
mask2=Greyscale(invert(clipD2)).tweak(bright=-80,cont=1.5)

Thank you also for the hint to blur the mask! I try it.

I should have mentioned I also use degrainmedian() and fft3dfilter() before limitedsharpen(). I use these because otherwise limitedsharpen() amplifies filmgrain too much. I tried several denoisers in the past and these two are the best for my purpose. But I used the others without limitedsharpen(). Maybe I should try them again. MVdenoice() was very good, I remember.

I'm very shure by now the artifacts are not caused by limitedsharpen().

I'm afraid I must do more tests :scared: again!! At my age! :D

Fred.

Didée
12th August 2005, 16:21
Another thing you can try is the following tweak inside of LS:

...
Str=string(float(strength)/100.0)
normsharp = Smode==1 ? unsharpmask(strength,radius,0)
\ : Smode==2 ? sharpen(float(strength)/100.0)
...
Instead of the "0" (zero), try "1" or even "2". This will cause UnsharpMask to not sharpen pixels with differences equal to or below that threshold.
Downside is, that with strong sharpening values a "cutoff" effect may become visible. That's why for LS-EX (which I fear will never get finished...) there's also a custom unsharp mask function implemented, providing a soft threshold of similar kind, almost completely avoiding the ugly cutoff effect.

I'll try to prepare some of the small tweaks & tricks you could try additionally, this WE.
(Cry "no" if I should not ;) )

Chainmax
12th August 2005, 17:59
videoFred, you should probably reduce your strength settings. In the locomotive pictures, I can clearly see aliasing in the red strips or the iron beams that join the wheels. Also, will you be watching your captures enlarged and with modified brightness? Probably not, therefore you shouldn't worry too much about removing those artifacts, whatever they are.

BTW, I concur with Mug Funky. Your results blow the originals out of the water, except for the colors, which look less vibrant.

videoFred
16th August 2005, 08:09
I'll try to prepare some of the small tweaks & tricks you could try additionally, this WE.
(Cry "no" if I should not ;) )

YES! :D Please do so!
And thank you for thinking with me.

It was a long weekend, here in Belgium.
So I had time to do lots of tests.

Remember the artifacts I mentioned above?
It looks like limitedsharpen() not only is the best sharpener I know of, but it is also a very good tester for denoisers, because with (abnormal) high settings, it makes the artifacts of the denoisers visible.

The artifacts mentioned above where caused by fft3dfilter(), but at the same time fft3dfilter() still is the best denoiser for my purpose.
With other denoisers I get strange moving objects, I do not have this effect with fft3dfilter(). Sometimes I even use degrainmedian() before fft3dfilter(), to have even stronger denoising, without too much blurring or artifacts.


Some first results: Fuji Single-8 film, 1972.
Please keep in mind a 8mm filmframe is only 6x4mm,
and film has a different -awesome!- look than digital.
I want to preserve this special film look,
so sharpening must be not too heavy.
And these are very compressed jpeg files also.

http://users.telenet.be/ho-slotcars/testmap/horse.jpg

http://users.telenet.be/ho-slotcars/testmap/suzuki1.jpg



:D a happy Fred :D

videoFred
16th August 2005, 08:33
videoFred, you should probably reduce your strength settings. In the locomotive pictures, I can clearly see aliasing in the red strips or the iron beams that join the wheels. Also, will you be watching your captures enlarged and with modified brightness? Probably not, therefore you shouldn't worry too much about removing those artifacts, whatever they are.

BTW, I concur with Mug Funky. Your results blow the originals out of the water, except for the colors, which look less vibrant.

I'm happy you like my results! :p
Maybe a short explenation of my system for those who are interested in real film. Here we go:

I use a 1024x768 fire wire machine vision camera and a 35mm lens with extention tubes. The camera is looking straight at the 6x4mm filmframe. I capture frame-by-frame: on my projector is a swith connected to an old computer mouse. With special software I create a growing AVI-file, each time the mouse gets a trigger one more frame is added to the file. It runs at 4fps, but the frame rate of the AVI file is taken over by the frame rate of the machine cam: 15fps.


Here is my system:

http://users.telenet.be/ho-slotcars/testmap/system3.jpg

As you see, there are no settings on the camera, it's just a square box. All settings must be done with software. Normal camcorders have all kinds of things already build-in: DV codec, sharpening etc...

With a machine camera it is possible to change these settings independent from each other and manual : white balance, hue, saturation, contrast, sharpness etc etc... Even the iris of the lens is set manual. So the end result depends strongly on these settings.

But to give you a better idea, here you can download the original bitmap of the lokomotive picture. I agree the artifacts are almost not visible on TV.

http://users.telenet.be/ho-slotcars/testmap/erik3.bmp

As you see, the original was taken very out of focus, limitedsharpen() realy did a miracle, in this case! :p . Colors are less vibrant because I use a brighter overlay to get back all the info hidden in the darker parts of the picture. I must do this, because there is more contrast in film. A digital camera can not capture this contrast. So maybe I tweaked gamma and offset of this overlay a little too much.

Fred.

JoergS
17th August 2005, 11:20
Hello, I'm trying to use your LimitedSharpen Filter and downloaded warpsharp_2003_1103.cab as a required component. But they say in http://forum.doom9.org/showthread.php?p=188451#post188451 that it's only for YUY2 colorspace, and LimitedSharpen uses YV12 only. Can I use warpsharp anyway or should I use a different warpsharp file?

br Joerg

Didée
17th August 2005, 12:42
Just use it, it's fine. That post of Sh0dan is from 2002 ...

But be sure to have those msvcr70/msvcr71/msvcp70/msvcp71 DLLs in your system root. (Actually only one DLL pair is needed, but I can never remember which is needed for which version of WarpSharp ... having them all is the paranoid's safety strategy ;) )

JoergS
17th August 2005, 14:39
Dear Didee, thank you for your answer. So I will go ahead!

videoFred
18th August 2005, 12:00
Another thing you can try is the following tweak inside of LS:

...
Str=string(float(strength)/100.0)
normsharp = Smode==1 ? unsharpmask(strength,radius,0)
\ : Smode==2 ? sharpen(float(strength)/100.0)
...


Yes, this works fine.. The artifacts are gone already with a setting of "1".
But then sharpness is not so "crisp" anymore, and this "crispness" is what makes limitedsharpen() so nice... :cool:

However, I posted the artifacts in the FFT thread also, maybe someone knows how to tweak FFT3Dfilter().

Fred.

communist
6th September 2005, 14:50
Big thanks from one more happy LS-User :)

Didée
6th September 2005, 15:33
Always a pleasure :)

You might try to postprocess LimitedSharpen with Soothe() (http://forum.doom9.org/showthread.php?t=99679) - should give a more calm and bitrate saving result. Perhaps I'll implant it directly into LimitedSharpen, let's see if there is positive feedback.


@ videoFred: If there are temporal fluctuations in the artefacts you're getting, Soothe() could be helpful, too.

buzzqw
6th September 2005, 15:43
Hi All !

i have i umble request is possible to post a link (or attachment) to a full working LimitedSharpen (and IIP btw...) package ? Just all dll/script and a mini how to.. :stupid:

a big thanks !

BHH

videoFred
6th September 2005, 16:27
@ videoFred: If there are temporal fluctuations in the artefacts you're getting, Soothe() could be helpful, too.

Thank you for the suggestion.. I try it.

In the meantime: here are some first results.
OK, maybe I oversharpened it a bit :D
And I must learn to configure the WMV files, too.

http://users.telenet.be/ho-slotcars/s8_video3.htm

Fred.

Didée
6th September 2005, 16:31
@ buzzqw

I pretty much dislike the habit to make "packages" or "bundles" for each and every thing. The same plugins are downloaded hundreds & thousands of times, where one download per user is fully sufficient. Moreover, bundling "naked" DLLs in many cases is a violation of licenses - for the case of "script packages" usually this is tolerated, but a violation is a violation nonetheless. And distributing the "full" original DLL archives is even more overhead.

For LimitedSharpen, you need the MaskTools (currently v1.5.8 (http://manao4.free.fr/MaskTools-v1.5.8.zip), and the big WarpSharp (http://www.avisynth.org/warpenterprises/files/warpsharppackage_25_dll_20031103.zip) package.

A basic script could look like this:
LoadPlugin("path\to\dgdecode.dll")
LoadPlugin("path\to\MaskTools.dll")
LoadPlugin("path\to\warpsharp.dll")

mpeg2source("path\to\yoursource.d2v")

crop( whatever )
orig = last
sharp = orig.LimitedSharpen()
sharp

# stacked comparison:
# stackvertical( orig.subtitle("orig"), sharp.subtitle("LimitedSharpen") )

# interleaved comparison:
# interleave( orig.subtitle("orig"),sharp.subtitle("LimitedSharpen") )

The how-to's are to find on page 1 of this thread, as is the script itself.

Basic knowledge about AviSynth is simply presumed. :)

buzzqw
6th September 2005, 19:16
Thanks Didèe !

BHH (now surfing on all this huge thread...)

Shinigami-Sama
7th September 2005, 06:30
wow
I was wondering what everyone was going on about in the threads, nice one mate
I'll defenatly use this next time, which may not be long seeing as how I have this nice shiny new slayer consert dvd <.<

zambelli
9th September 2005, 04:06
Didée, I notice that on YUV video with compressed luma (TV range), LimitedSharpen breaks the TV range by adding luma values outside the 16..235 range. Have you noticed this? I've verified this by using ColorYUV(analyze=true) on a clip with interleaved raw and sharpened frames.

One could argue that this is to be expected because sharpening requires intensifying edges which often means making whites whiter and blacks blacker. However, this seems like an undesirable side effect in TV and DVD production. What are your thoughts?

Mug Funky
9th September 2005, 04:12
if you set "overshott=0" then this will not happen :)

but it will change the sharpening effect as well.

i wouldn't worry about edges being outside the acceptable ranges though - the limited bandwidth of a TV will effectively make the overshoot cancel on playback (and reverse some of the sharpening effect as well).

Boulder
9th September 2005, 05:02
And some (most?) commercial DVDs don't respect the limits either.

Mug Funky
9th September 2005, 05:57
hehe. hell no - we just put on whatever's on the tape, except the very rare black/white point adjustments when things look wrong.

Didée
9th September 2005, 09:01
@ zambelli

Like Mug Funky and Boulder said - the output range of LS will be the same as that of the input, -[overshoot] on the dark and +[overshoot] on the bright end. And yes, most sources we usually deal with already come along with pixel values outside of CCIR-601 specs - at least after decoding.

This is one of the topics one could debate about endlessly ... similar like resizing issues of +/- 1 or 2 pixels to achieve a *correct* aspect ratio ;)

I think this is not what LS should take much care of, and decided to just stay with the small range expansion +-[overshoot], and leave it up to the user to apply Limiter() or Levels() corrections themselves. :)

zambelli
9th September 2005, 09:39
@ zambelli
I think this is not what LS should take much care of, and decided to just stay with the small range expansion +-[overshoot], and leave it up to the user to apply Limiter() or Levels() corrections themselves. :)Thanks for the replies.
Does compressing luma to TV range, applying LimitedSharpen (with overshoot=1) and then clamping the luma range at 16..235 sound like a reasonable idea? That way the luma compression and the overshooting would cancel each other out a little bit, IMO.

Didée
9th September 2005, 10:03
Does compressing luma to TV range, applying LimitedSharpen (with overshoot=1) and then clamping the luma range at 16..235 sound like a reasonable idea?
NOOOOO!!! ;)

I've some pics in preparation ... waiting for lunch break.

Boulder
9th September 2005, 10:18
hehe. hell no - we just put on whatever's on the tape, except the very rare black/white point adjustments when things look wrong.
Noooooooo... :)

This is getting OT, but anyway:

ColorYUV frame 1 (http://www.saunalahti.fi/sainki/coloryuv.jpg)
Limiter frame 1 (http://www.saunalahti.fi/sainki/limiter.jpg)
ColorYUV frame 2 (http://www.saunalahti.fi/sainki/coloryuv_2.jpg)
Limiter frame 2 (http://www.saunalahti.fi/sainki/limiter_2.jpg)

I often wonder why they don't stick to the TV range. The borders (that I've cropped off) even contained values as low as 6 for luma.

Didée
9th September 2005, 12:56
There's a general issue I am having with compressions or expansions of colorrange: the output is no more smooth, but contains "hill ridges": on expansion, there are "holes" in the created spectrum; on compression, there will be "spikes" due to melting-together formerly differnt values to identical new values. This is caused by the linear way in that the operation is usually done, like e.g. by ColorYUV. *)

Problem is, that these stairsteps actually are an artificial sort of "detail" (the "holes" of expansion), or are a sort of detail loss (the "spikes" of compression).
When doing plain range conversions, this usually is not a problem. However, if one is planning to perform a sharpening operation afterwards, things look different: in this case, the introduced artificial detail (which would be sharpened as well), or the loss of detail (which could not be sharpened anymore), very well might become an issue.

Some time ago, I created some small functions that try to produce a more smoothe output for these conversions. Actually, they are very dirty - the operation done is not fully "correct" in the way it should be ... but the result at least is closer to what one would like to have.

*) Making a "fully correct" smooth range conversion is not trivial, but pretty computanional intensive instead.


Look at these pictures:

( source | PC->TV | TV->PC )

http://img32.imageshack.us/img32/5762/pctvsource5wl.th.jpg (http://img32.imageshack.us/my.php?image=pctvsource5wl.jpg) http://img32.imageshack.us/img32/3779/pc2tv9gz.th.jpg (http://img32.imageshack.us/my.php?image=pc2tv9gz.jpg) http://img32.imageshack.us/img32/5512/tv2pc1db.th.jpg (http://img32.imageshack.us/my.php?image=tv2pc1db.jpg)


Personally, I would not do a colorrange conversion prior to sharpening (if you call me pedantic, it's okay ;) ).
But of course you can do whatever you like. :)

function pc2tv_smooth(clip clp)
{
pc2tv = clp.coloryuv(levels="PC->TV")
pc2tvd=yv12lutxy(clp,pc2tv,"x y - 4 * 128 +","x y - 4 * 128 +","x y - 4 * 128 +",U=3,V=3)
yv12lutxy(clp,pc2tvd.removegrain(19),"x y 128 - 4 / -","x y 128 - 4 / -","x y 128 - 4 / -",U=3,V=3)
}

function tv2pc_smooth(clip clp)
{
tv2pc = clp.coloryuv(levels="TV->PC")
tv2pcd=yv12lutxy(clp,tv2pc,"x y - 4 * 128 +","x y - 4 * 128 +","x y - 4 * 128 +",U=3,V=3)
yv12lutxy(clp,tv2pcd.removegrain(19),"x y 128 - 4 / -","x y 128 - 4 / -","x y 128 - 4 / -",U=3,V=3)
}

zambelli
9th September 2005, 14:12
Awesome! That function works great! I made one change though: I replaced ColorYUV with Levels because it allows me to specify my own mapping.

A note to anyone else who wants to try it: you'll need the 1.0 prerelease of RemoveGrain in order to use mode 19.

Didée
9th September 2005, 14:43
@ zambelli:

Fine. :)

Still, you should make sure what your out-of-range pixels are. For example, in Boulders screenshot #4 above ("Limiter frame 2"), it is very obvious that the outliers derive from DCT/iDCT - errors. In this case, you would *not* want to keep those (and perhaps even sharpen them - ouch!), but rather clamp them instead ...


To also give a vizualisation of the problem's practical side:

In the following example, first a double conversion PC -> TV -> PC was done, then some (insane) sharpening was applied. In fact this is hoplessly exaggerated, but it makes the basic problem easily visible. In practice, the effect is of course much smaller ... but often it's those very small glitches that escape the eye at first glance, but bite you somewhen later - when it's too late. :devil:

http://img313.imageshack.us/img313/1719/pctvsharpen1ev.th.jpg (http://img313.imageshack.us/my.php?image=pctvsharpen1ev.jpg)

zambelli
10th September 2005, 02:28
@ zambelli:

Fine. :)

Still, you should make sure what your out-of-range pixels are. For example, in Boulders screenshot #4 above ("Limiter frame 2"), it is very obvious that the outliers derive from DCT/iDCT - errors. In this case, you would *not* want to keep those (and perhaps even sharpen them - ouch!), but rather clamp them instead ...
How exactly did Boulder do those Limiter frames? He didn't mention in his post.

Anyway... I've been using the Histogram function to tweak my Levels values. One of the sources that I'm working with has very hot whites that go well above 235 and they don't look like noise, while on the other end of the luma range the blacks seem to comply with CCIR.601 and stay above 16. Simply applying LimitedSharpen(overshoot=1) to this source expands the luma range, which I think effectively clamps some of the superwhite information beyond 255 (255 + anything = 255, right?), and pushes the low luma values below 16. Doing a simple ColorYUV("PC->TV") compression unnecessarily pushes the low range too high, so I think doing a custom Levels() adjustment is the right thing to do here. Through some trial and error (see pics below), I decided that the following mapping worked best:

Levels(1, 1, 255, 6, 227, coring=false)

I rewrote your function like this:

function Levels_Smooth(clip clp, int min_luma, int max_luma)
{
pc2tv = clp.Levels(1, 1, 255, min_luma, max_luma, coring=false)
pc2tvd=yv12lutxy(clp,pc2tv,"x y - 4 * 128 +","x y - 4 * 128 +","x y - 4 * 128 +",U=3,V=3)
yv12lutxy(clp,pc2tvd.removegrain(mode=19),"x y 128 - 4 / -","x y 128 - 4 / -","x y 128 - 4 / -",U=3,V=3)
}

In my script I then call:
sharp = dull.Levels_Smooth(6,227).LimitedSharpen( ss_x=1.5, ss_y=1.5, strength=200, overshoot=1 )

Here are the samples:
Original source (http://www.citizeninsomniac.com/images/Histogram-Orig.png)
Just LimitedSharpen (http://www.citizeninsomniac.com/images/Histogram-LimitedSharpen.png)
ColorYUV then LimitedSharpen (http://www.citizeninsomniac.com/images/Histogram-ColorYUV-LimitedSharpen.png)
Levels_Smooth(6,227) then LimitedSharpen (http://www.citizeninsomniac.com/images/Histogram-PC2TV_Smooth-LimitedSharpen.png)

As you can see, the Levels_Smooth(6,227) image has a lot more white detail than the original, which is apparent in the face and bright costume, but it's not as washed out as the ColorYUV version or as hot as the version without any levels pre-adjustment.

Boulder
10th September 2005, 07:47
How exactly did Boulder do those Limiter frames? He didn't mention in his post.


It was just a simple script:

MPEG2Source("path\clip.d2v",idct=4) # reference iDCT used to minimize errors
#ColorYUV(analyze=true)
Limiter(show="luma") # shows all out-of-range luma in red

zambelli
10th September 2005, 09:25
It was just a simple script:

Limiter(show="luma") # shows all out-of-range luma in red
Which version of Avisynth are you using? My 2.55 version doesn't support that parameter for Limiter.

Boulder
10th September 2005, 09:27
The latest release candidate, dated 4.9.2005.

Didée
10th September 2005, 16:03
zambelli -

looking at that histogram, you are doing fully right. No more to say.

Some small notes:

1. (this one doesn't matter here, just for clarification)
A smooth version for levels I had made, too ... but one has to be careful. If gamma values != 1.0 are used, then the "4" multipliers and divisors in the LUTs (".. 4 * .." and ".. 4 / ..") should be reduced. The formers are providing more of "free room" where the smoother can put values in, the latters normalize the result again. It depends on the maximum pixel change being done, which should be spread as far as possible to fit into 0..128. For PC<-->TV, the maximum change is 255-235=20, hence the 4-multiplyer is okay. But on arbitrary levels adjustments, changes could be much bigger, and the multiplier should be reduced. "2" should be safe for most sane operations.

2.
Levels() changes luma and chroma simultaneously. While you have too wide luma, chroma seems fine, and must not be reduced in the same way as luma. You could replace the levels() call with a YV12Lut() that's working only on luma ... or simply copy chroma back at the end.

3. Lastly,

>> sharp = dull.Levels_Smooth().LimitedSharpen()

still is not optimal.

dull = dull.Levels_Smooth()
sharp=dull.LimitedSharpen()
Soothe(sharp,dull)

is better. With your call, Soothe() might undo some changes of the range conversion, too.
To make it clear once more: When using Soothe(a,b), then the *only* difference between a and b should be a sharpen operation, nothing else.

zambelli
10th September 2005, 23:25
zambelli -
looking at that histogram, you are doing fully right. No more to say.
I can't thank you enough for helping me out! You've been a real life saver.

Levels() changes luma and chroma simultaneously. While you have too wide luma, chroma seems fine, and must not be reduced in the same way as luma. You could replace the levels() call with a YV12Lut() that's working only on luma ... or simply copy chroma back at the end.
Good call, I totally forgot about that. How does this sound:

chroma = last

# Compress luma range
Levels_Smooth(6,227)

MergeChroma(chroma)


still is not optimal.

dull = dull.Levels_Smooth()
sharp=dull.LimitedSharpen()
Soothe(sharp,dull)

is better. With your call, Soothe() might undo some changes of the range conversion, too.
Good call on that too. Looking at my script I used for last night's conversion (it's become a nightly process! ;) ), I actually did do the right thing. I was probably just using shorthand in my post. But it's good to know it for sure.

THANK YOU!

shaolin95
12th September 2005, 00:13
Didee I think I saw some YUY12 to YUV12 back and forth conversions in the LimitedSharpen script I have...is that needed? I ask cause it ends up converting to YUV12 which is the format I am outputting from my decoder too.
Regards

Didée
12th September 2005, 07:55
Didee I think I saw some YUY12 to YUV12 back and forth conversions in the LimitedSharpen script I have...is that needed? I ask cause it ends up converting to YUV12 which is the format I am outputting from my decoder too.
Regards
You feed YUY2 in, you get YUY2 out.

You feed YV12 in, you get YV12 out.

If you start with YUY2 and in the end want to have YV12 anyways, then ConvertToYV12() yourself before LS.

Surfinette
16th October 2005, 02:03
Sorry to ask, but where is the link to download LimitedSharpen ????
I can't seem to find it

Surfinette :confused:

hartford
16th October 2005, 02:32
LimitedSharpen is a script. Look at post #3 in this topic. Copy and save
the code to LimitedSharpen.avs

You will need these filters to to use it: MaskTools-1.51 or higher
Warpsharp (03Nov03) <- MUST HAVE

Go to http:/www.avisynth.org/warpenterprises

Get warpsharppackage_25_dll_20031103.zip

Extract warpsharp.dll from that.

From the same site, get masktools_25_dll_20050808.zip
and extract Masktools.dll


Do the ususal LoadPlugin("..."), import ("LimitedSharpen.avs")

unskinnyboy
16th October 2005, 03:06
You will need these filters to to use it: MaskTools-1.51 or higher
Warpsharp (03Nov03) <- MUST HAVE

MaskTools alone is enough. WarpSharp is not needed.

Didée
16th October 2005, 03:34
WarpSharp.dll is not absolutely necessary, but is required for Smode=1. (too lazy to construct "catch()" safety checks for al pssible plugins to inform the user about missing ones ...)

Apart from that, I'd bold, underline and make red the "MUST HAVE" for both WarpSharp.dll and MaskTools ;)


Edit: Oh, I wanted to say "welcome to the forum, Surfinette", but now I see ...

did it really take you 2 1/2 years to make your first post?! Congratulations! ;)

hartford
18th October 2005, 02:35
Totaly off-topic:

Didée:

Some time ago, I posted help to someone reguarding
"cleaning" a clip. I suggested PixieDust and LimitedSharpen,
but I warned about using PixieDust in certain situations, ie,
that it could cause "halos" in gradients. You posted an address
to me to view some pics, and I was flippent; I said something
stupid, like, "I don't know about that." (Casa Blanca, ring a bell?).

I apologize for that remark. I don't know why I said it.

RE: over-doing gradients: I ran across some
terminology and thought that it described best what I tried to
express: turning grandients into "contours."

Well, perhaps it will "catch," perhaps not.

Again, I apologize for my stupid remarks.

DJ_OXyGeNe_8
23rd October 2005, 13:07
thanks

Didée
1st November 2005, 21:17
Because of multiple requests, I've attached a modded version (http://home.arcor.de/dhanselmann/_stuff/LimitedSharpen_(modded-27Nov2005).rar) of LimitedSharpen. It adds a new Smode, a new Lmode as well, allows a seperate "undershoot", and handles the "soft" option completely different.

I don't want to call this one "official", there is some more stuff that should go in before that.

However, feedback is of course welcome. Whether you like it or not, or perhaps I've broken something ...

... have fun with toying. ;)


edit 29 Nov:
The small bug in Smode=4 was only fixed in the version for MaskTools 2.0alpha. Now corrected this version for old MaskTools, too.

Pookie
2nd November 2005, 08:23
RemoveGrain Prerelease 1.0 - http://home.arcor.de/kassandro/RemoveGrain/RemoveGrain.rar

I've only tried a few test encodes so far, and it looks quite nice - I like the edgemode=-1 option you added for previewing the areas to be processed - example:

http://www.uploadhouse.com/images/169200231lsz.png (http://www.uploadhouse.com/)

What else can one say, except thanks for making my encodes look so damned good :)

FredThompson
2nd November 2005, 09:01
Didée:

...I said something stupid...
I apologize for that remark. I don't know why I said it.
...
Again, I apologize for my stupid remarks.Prove it, wash his car :P

RE: over-doing gradients: I ran across some
terminology and thought that it described best what I tried to
express: turning grandients into "contours."

Well, perhaps it will "catch," perhaps not.Good term. I think the graphic arts people call this posterizing.

Chainmax
2nd November 2005, 15:18
RemoveGrain Prerelease 1.0 - http://home.arcor.de/kassandro/RemoveGrain/RemoveGrain.rar

I've only tried a few test encodes so far, and it looks quite nice - I like the edgemode=-1 option you added for previewing the areas to be processed - example:

http://www.uploadhouse.com/images/169200231lsz.png (http://www.uploadhouse.com/)

What else can one say, except thanks for making my encodes look so damned good :)


Wow, can a movie be encoded this way (i.é: can this effect be used as filtering, not just previewing)? I'd love to see a LOTR movie with only white outlines :). Why hasn't kassandro posted about this?

buzzqw
2nd November 2005, 17:27
@Chainmax
WOW ! Awesome !

Would be very very cool to encode a movie in this way !!

Hope too Kassandro will post an useful script/filter !!!

BHH

Leak
2nd November 2005, 19:39
Wow, can a movie be encoded this way (i.é: can this effect be used as filtering, not just previewing)? I'd love to see a LOTR movie with only white outlines :). Why hasn't kassandro posted about this?
Well, it's not quite the same, but I'm looking forward to this (http://www.apple.com/trailers/warner_independent_pictures/a_scanner_darkly.html)...

np: David Holmes - Minus 61 In Detroit (This Film's Crap, Let's Slash The Seats)

sleekychap
3rd November 2005, 01:41
With what resizer does this go best.....smooth or sharp?

I am talking about 29.97 fps interlaced NTSC source!

Didée
3rd November 2005, 02:14
Neither, nor. First you must

deinterlace !

:)


And using Smode=4,strength=300,overshoot=16 will show if you did it good...

FredThompson
3rd November 2005, 03:05
What about separating the fields then weaving afterwards? How about breaking the source into 2 streams, running the entire filter chain, then weaving at the end?

I have to tell you, LimitedSharpen is a joy. I played with the overshoot paramter and found it made my noisy, complex animation look noisier. It's probably nicer for more simple source, though.

Pookie
3rd November 2005, 06:49
Hey Chainmax, I believe the "edgemode=-1" is a Didee creation rather than kassandro's doing (although I could be wrong, and have been many times). I was just linking to the latest RemoveGrain package to make it easier for all to try out the latest LimitedSharpen.

Socio
5th November 2005, 19:13
Because of multiple requests, I've attached a modded version (http://home.arcor.de/dhanselmann/_stuff/LimitedSharpen_(modded-29Oct2005).rar) of LimitedSharpen. It adds a new Smode, a new Lmode as well, allows a seperate "undershoot", and handles the "soft" option completely different.

I don't want to call this one "official", there is some more stuff that should go in before that.

However, feedback is of course welcome. Wether you like it or not, or perhaps I've broken something ...

... have fun with toying. ;)

Hey Didee,

I have been using this new version of LS for a couple days now, mostly for real-time DVD movie viewing and I have to give it the proverbial two thumbs up! :thanks:

I don't know what all has changed but it is faster than previous versions as I am able to enable better more powerful denoisers in ffdshow prior to LS which would when used with older versions of LS would slow down the process to much to use in real-time. Also with my testing it appears that the new Smode 4 gives near the same high quality as Smode 3 and is slightly faster which is great for real-time viewing.

I will test is out with some actual encoding this weekend see what I can do with it but in the meantime I can't wait to see what the "some more stuff that should go in before that." is going to be.

Socio
6th November 2005, 20:19
I got the new Limitedsharpen working with new Masktools alpha (2.0a7) (http://manao4.free.fr/masktools-v2.0a7.zip)

You can download this version of Limitedsharpen here (http://savefile.com/files.php?fid=8421661)

Didee,

Along with subbing out some function names I had change some parameters and remove the divisors=4 under "edge" to get it to work, and it seems to work ok but you might want to check it out.

I seem to get less CPU overhead when using this in real time as much as 30% less however it takes several seconds like 20 seconds for it to initialize. I am not sure if it is something I changed in LS or if it is just that the new Masktools takes longer to fire up.

Didée
6th November 2005, 21:07
Seems fully okay, glancing over it. However the edgemask will be way too dark now . To get the divisor thingy working, IIRC you'll have to put the divisor value into the string as last value:
ESTR="8 16 8 0 0 0 -8 -16 -8 4" # the last "4" is the divisor
mt_edge(thY1=0,thY2=255,ESTR)
The speed increase was to be expected, mostly because of expand/inpand/inflate/deflate being relatively slow in v1.5.x.

For the delay on script loading, I've no idea. Have to actually try it myself.


Edit: wait, something is fishy ...

Manao
6th November 2005, 21:10
There should be no reason for additionnal delay at start up.

Didée
6th November 2005, 21:42
But there is. confirmed on a Celeron2600, XP SP1, Avisynth v2.56a. Its varying, mostly between 10 and 20 seconds.

Socio
6th November 2005, 21:44
Seems fully okay, glancing over it. However the edgemask will be way too dark now . To get the divisor thingy working, IIRC you'll have to put the divisor value into the string as last value:
ESTR="8 16 8 0 0 0 -8 -16 -8 4" # the last "4" is the divisor
mt_edge(thY1=0,thY2=255,ESTR)
The speed increase was to be expected, mostly because of expand/inpand/inflate/deflate being relatively slow in v1.5.x.

For the delay on script loading, I've no idea. Have to actually try it myself.


Edit: wait, something is fishy ...

Ok I think I got it now:

LS fixed (http://www.savefile.com/files/8905176)

Didée
6th November 2005, 21:56
Smode=4 is broken. Exchange Line 85 with

\ : mt_lutxy(tmp,tmpsoft,"x y == x x x y - abs 16 / 1 2 / ^ 16 * "+Str+" * x y - 2 ^ x y - 2 ^ "+Str+" 100 * 25 / + / * x y - x y - abs / * + ?")
After that, for realtime PB try "LimitedSharpen(ss_x=1.0,ss_y=1.0,Smode=4,strength=150,soft=34)" ;)

Manao
6th November 2005, 22:10
You forgot maskedmerge --> mt_merge, and inflate --> mt_inflate.

Indeed, the script is slow to open. Dunno why, I'll investigate

Socio
6th November 2005, 22:35
Ok I fixed the Smode 4 and changed the maskmerge and inflate functions

Get this version here (http://www.savefile.com/files/3872085)

Socio
6th November 2005, 23:43
Here is a before and after pic I know it is "NOT" the exact same frame but it still gives you a good idea of the LS Smode 4 effect and looks pretty freaking good too!

I used this call as per Didee's suggestion:

LimitedSharpen(ss_x=1.0,ss_y=1.0,Smode=4,strength=150,soft=34)

http://img224.imageshack.us/img224/31/warriorsnormal7cx.jpg
http://img204.imageshack.us/img204/797/warriorsnewsmode44ys.jpg

Shinigami-Sama
7th November 2005, 00:49
wow
it turned what was supposed to be hair into hair o.O
though it looks a little over done thats still impressive
good work didee

Audionut
7th November 2005, 00:56
The delay issue is there for me.
But once up and running, it's heaps fast.

Didée
7th November 2005, 01:27
It seems either the normalization or the thresholding of mt_edge() is not working: if a divisor is given in the string, everything except 0 becomes 255. Also, mt_merge() seems to do nothing. Hence, all edgemodes except 0 are not working correctly in this version of LimitedSharpen.

( That's why it takes a little longer until I come out with "new versions" ;) )

Socio
7th November 2005, 03:16
A temporary fix for the mt_merge part one could probably just change back the mt_merge calls to maskmerge and use Masktools 1.58 for maskmerge stuff and masktools 2.0 for the rest thus keeping the speed of 2.0

foxyshadis
7th November 2005, 05:45
I'd assume the slowdown is due to the generation of lutxy value tables? And the other functions' tables if they use the same, if those generations aren't optimized.

Aside, I never knew this could be a realtime playback filter, awesome. :o

Didée
7th November 2005, 09:10
Yup, quite possible that that's the price to pay for all those cries "down with postfix notation , we need infix." :rolleyes:

Manao
7th November 2005, 09:21
For mt_edge, there's a bug in with custom kernels in mmx, so use mmx = false and it'll work ( and it'll be as fast as with the old MaskTools ).

For mt_merge, I didn't have time yet to check, but I find it strange that it doesn't work ( because there's little room for mistake in this case, and I remember checking it )

For the lut table initialization : parsing the expression takes no time at all ( that part hasn't changed ). Once the expression is parsed, however, I must admit that I made a nice but slow OO scheme to fill the lut. I didn't think it would be that slow, so I'll see how to speed that up a little bit.

I'll fix the mmx version of mt_edge tonight, and check mt_merge.

Didée
7th November 2005, 09:49
Sorry, mt_merge seems to work fine. Probably I was fooled because a too dark mask was used in LS - made a syntetic test, and it works as expected.

However the startup delay due to filling up the LUTs really is a PITA ... and LS doesn't even use _that_ much of lut/xy. My HD holds scripts with tenfold numbers of lut/xy calls.
Erh, what about using the respective code from 1.5.x versions? That one was pretty fast :)

Manao
7th November 2005, 09:59
It was fast, but it was ugly :). No really, it'll be easy to make it faster. I just woudln't have thought it would take that much time, so I really didn't care at all about speed. But, for example, I overchecking the validity of the expression ( overchecking <-- at each steps in fact ) which makes the algorithm O(n²) where it could be simple O(n)...

Basically, i just forgot to remove the development checks I put when I first implemented it :)

puffpio
7th November 2005, 10:25
going from polynomial to linear time would be an awesome optimization :)

Manao
7th November 2005, 10:31
Not that much : it's only done during initialization ( that's why I didn't care in the first place ). And the optimization itself doesn't even deserve to be named optimization : I work on list, and I checked at each iteration the size of the list, which is dumb ( but easy while checking for mistakes ) --> O(n²) instead of O(n), where n is the size of the list ( the number of token in the expression ).

Manao
7th November 2005, 23:09
Follow the link to my signature : mt_edge is fixed, mt_lutxy delays are lowered.

Socio
7th November 2005, 23:18
Awesome Mano going to test it out now!

Audionut
8th November 2005, 01:46
That's better, loads much faster now.

Thanks.

Socio
8th November 2005, 02:12
I still get a delay but only lasts half as long as before, considering this version is faster than the old masktools, a ten second delay before is starts flying is nothing.

Thanks for the fast work Mano!

Didée
8th November 2005, 10:24
For script development, this still means you've to mix old and new MaskTools ...

Example: Soothe(LimitedSharpen()) on a P3-800:
v2.0a7: ~46 seconds loading time
v2.0a8: ~21 seconds loading time

Even if those numbers cuts into half on a recent machine, that's not how I'd like to build & tweak my scripts ... The Soothe+LS combo contains a whole of "only" 16 lut/xy calls. Imagine, my current denoiser project holds around ~50 different lut/xy calls ...

It's not a big issue at the moment, since one can perfectly work around it by using the "old" YV12Lut/xy. However before going v2.0 final (or even integrating into Avisynth), something more should happen.

Manao
8th November 2005, 10:36
Strange, I thought the speed gain was bigger than that. I'll have a deeper look tonight then.

Audionut
8th November 2005, 12:58
With just limitedsharpen() and v2.0a8 of masktools, i'm getting a 3 second load time.

edit: although that is against the almost instant load time with v1.5.8.

Manao
8th November 2005, 21:48
Try the new version in my signature. Hopefully, speed should be ok this time.

Socio
8th November 2005, 22:32
Try the new version in my signature. Hopefully, speed should be ok this time.

Can't download it and does not show up on your site list.

Shinigami-Sama
8th November 2005, 22:49
confirmed alpha 2.0a9 is missing
the other three are still there

Socio
9th November 2005, 00:07
He must have ran into a problem with that new alpha build.

Shinigami-Sama
9th November 2005, 00:28
or free.fr did a roll-back
but I'm in no rush

Manao
9th November 2005, 05:25
Or simply, he must have mistyped his username without checking :) Fixed

raquete
9th November 2005, 06:18
thank you Manao,the link is working now.

starting to use LimitedSharpen.
all i need is masktools.dll in avisynth plugins folder and this script
http://forum.doom9.org/showthread.php?p=559994#post559994
(or new),nothing more?

thank you.

Audionut
9th November 2005, 07:02
Download the alpha version of masktools in Manao sig.

And use this version.
http://forum.doom9.org/showpost.php?p=734246&postcount=226

raquete
9th November 2005, 08:16
all right,i got the script :-)

in the .bat file have
del build\masktools.ncb
rmdir /s /q build\Release
rmdir /s /q build\Debug
copy "C:\Program Files\Avisynth 2.5\plugins\mt_masktools.dll" .

the default avisynth plugins folder in my sYstem(BR) is in C:\Arquivos de programas and was change but don't know if the others lines from the .bat had worked(not an expert here)

i need to change some more in the .bat?

thank you so much.

Manao
9th November 2005, 08:56
You do not need that .bat, it's only there for my need at the moment ( to clean up files that were created during the building process ).

Socio
9th November 2005, 13:40
Could be my imagination but not only does masktools alpha 9 shorten the start up delay considerably, it seems the whole thing is speeded up a bit.

Nice work Mano thanks!

3ngel
9th November 2005, 15:03
@Didée
I'm a little bit confused :)
From what i've understood LimitedSharpen() and Iip(), are quite similar, so at this point i don't know clearly what to choose.
I want the best possible quality regadless the cpu usage, so what you suggest me LimitedSharpen() or Iip()?
Thank you :)

Didée
9th November 2005, 15:35
From what i've understood LimitedSharpen() and Iip(), are quite similar
No, they aren't.

LimitedSharpen is, basically, a plain sharpener that does hardly care about what might be noise, artefacts, or real detail. It just takes the input and sharpens everything, while avoiding oversharpening.

iiP is a combined solution that offers noise reduction, halo removal, some contrast enhancement, detail sharpening & and refinement.

See how similar they are? :)

So, everything depends on the quality of the source you're starting with, and of course on your personal taste. There are clean sources that hardly need any processing at all, and there are sources so crappy that even iiP is "too weak" to get a nice result.


Therefore, same answer as if you were asking me which of two women to marry:

"The one you like more." ;)

Manao
9th November 2005, 15:45
I would have said "both" :p

Anyway, Socio, the speed up you're observing isn't my fault. I only sped up the loading time.

3ngel
9th November 2005, 15:48
Ok thanks, it's more clear now :)
So LimitedSharpen is kinda basically compared to Iiip, but Iip is more suggested for Good Source (and it does more things).
I hope i've understood :)

Anonymouses
10th November 2005, 06:14
Ok thanks, it's more clear now :)
So LimitedSharpen is kinda basically compared to Iiip,

LimitedSharpen isn't compared to iiP at all. LimitedSharpen is nothing but a straight sharpner. iiP is a complete package of to clean and enhance the source.

but Iip is more suggested for Good Source (and it does more things).

It doesn't have to be used on good sources, in fact if you have a good source you probably wouldn't want to use iiP on it. He was just saying that on really, really poor sources iiP may not be able to make the end result good.

So if all you need to do is just sharpen the source you will only want to use LimitedSharpen. If on the other hand you need to do denoise, sharpen, etc. then you will want to go to iiP.

JnZ
13th November 2005, 16:48
Hi all.

I used old Didée version LS, but found, you improve that guys. So today I tested new version, but got this error: there is no function named "mt_edge".

I agonize my brain some time :), but nothing think out. Script still not working :confused:

Used last Manao Masktools 2.0a9. Or I missed something like: some more AVS dll's are needed to work? Any help?

Thx.

Didée
13th November 2005, 17:09
The alphas of MaskTools 2.0 will only run with AviSynth v2.56 (or former betas, not all recommended). Not sure at which point exactly the cut occured - just fetch the latest version (2.56a) from sourceforge download page (http://sourceforge.net/project/showfiles.php?group_id=57023).

JnZ
13th November 2005, 17:11
...just fetch the latest version (2.56a) from sourceforge download page (http://sourceforge.net/project/showfiles.php?group_id=57023).
Thx. I'll try.

EDIT: Now it's working, but I had to use RemoveGrain 1.0 instead 0.9. Thx a lot Didée.

So this is recap of needed things:
- MaskTools 2.0a9
- RemoveGrain 1.0
- Avisynth 2.5.6
- LimitedSharpen moded script

Socio
25th November 2005, 18:48
Hey Didee

I thought you might get a kick out of this, I have limitedsharpen working beautifully with live TV from my HTPC. :)

Here is a link to a thread where I just posted about it with a couple pic's:

http://www.avsforum.com/avs-vb/showthread.php?t=608161

raquete
25th November 2005, 19:50
excuse me Socio, i read there: image quality is subjectiveright but when have minimal quality.everybody is fat in that movie? :p
the pictures are differents and the source is horrible and when the source is horrible using that filters the result will be....best than horrible.
why not the same picture from good source and with filters?!?

Socio
25th November 2005, 20:04
excuse me Socio, i read there: right but when have minimal quality.everybody is fat in that movie? :p
the pictures are differents and the source is horrible and when the source is horrible using that filters the result will be....best than horrible.
why not the same picture from good source and with filters?!?

The source is the same on both pics and the program I used to view Cable TV and filter with ffdshow and limitedsharpen is the only PCTV QAM compatible program that supports ffdshow that I know of. Also the channel I was on which was AMC movie channel has worst image quality to begin with which is exactly why I chose it as it gives the most dramatic before and results.

raquete
25th November 2005, 20:45
Also the channel I was on which was AMC movie channel has worst image qualityok.my bad....i'm sorry.i understand you now. :)

i mean that you have to use the same picture from the source with and without filters.

thanks.

breez
25th November 2005, 21:11
Socio should capture some content uncompressed / with lossless compression to get a better comparison.

Didée
26th November 2005, 03:54
@ Socio

Heyhey, for *realtime* processing of *720p* content, that's a result, isnt it!
(What processor did you say you are running ...) :dreams:

The still has some of that "plastic" look, okay ... but there's a considerable amount of interference noise to be removed, and everything is done with simple and basic filtering - in RT. Good result, I'd say.

It's just that with the used settings, you almost reduced LimitedSharpen() to ModerateSharpen(). Which indeed could be a way to free some CPU cycles for another task.
Give a try on

repair(last.sharpen(0.6),last,1,3)

instead of LimitedSharpen, and see if there's much of a difference. This could also allow you to ease the croma settings of another filter (most probably: ditch the chroma part of the gaussian blur, and/or reduce HQDN3D's spatial chroma setting).

Another thing to try: seeing there're still leftover noise from the interference, try if you can afford to put something like

mergeluma( removegrain(2,-1), 0.25 ~ 0.50 ) (weak), up to
mergeluma( removegrain(4,-1), 0.08 ~ 0.16 ) (strong)

before the sharpening. Could work out with the simplified sharpening from above.
(It's hard to judge from here how much of an issue the leftover noise really is, if at all. But you have the experience with toying around, I guess ;) )

A pity there's no time to reduce the haloing ...

Egh
26th November 2005, 05:35
@ Didée:

May I use some of your expert sharpening knowledge? :P

What could you advise to use for sharpening in scenes where anime producers apply sorta blur + halo filtering? An example of such scene follows. I tried several interesting things for such scenes sharpening [including sledgehammer approach :P], but they have some drawbacks.

Actually, the biggest problem is those halos around egdes... After strong sharpening they just look too dirty...

An example of anime with scenes processed like that would be HiMM (he's my master). In each episode around half of the scenes is heavily blurried, and the rest is pretty sharp. I would like some sharpening settings which could make them more or less similar.

Here is screenshot example from negima (in himm it is similar). I couldn't find anything really good to sharpen such scenes and thus can't release that anime :( It's the only serious thing delaying actual release :)

http://img358.imageshack.us/img358/1949/negimasample4do.png

Didée
26th November 2005, 15:50
@ Egh

Cheap stuff, basically. A Gaussian Blur of very big radius (or s-th similar) was applied with some percentage. Same Effekt as used in soap operas. Obviously, you need to apply the reverse effekt of gaussian blurring, which is called "Unsharp Masking". A mini script like
lft=crop(0,0,8,0)
rgt=crop(width-8,0,-0,-0)
crop(8,0,-8,-0)
o=last
ox=o.width
oy=o.height
blur1=o.bicubicresize(m4(ox/20.0),m4(ox/20.0)) .bicubicresize(ox,oy,1,0)
yv12lutxy(o,blur1,"x x y - 1.5 * +","x x y - 1 * +","x x y - 1 * +",U=3,V=3)
mergeluma(blur1,0.16)
stackhorizontal(lft,last,rgt)
leads to this result (http://img457.imageshack.us/img457/744/negimasampleusm2hj.png), showing in which direction the train is running. It's not all that nice, since any even so small artefact gets enhanced, too. For that you'll need additional filtering - perhaps: highpass the effect, filter the HP accordingly, mix back, then apply.

Of course it needs quite some more fiddling around ... should be no problem. Since you're one of the big boys releasing things, you know what you're doing. :)

Chainmax
26th November 2005, 16:56
Mmm, I like what I see...

......

...the sharpening, I mean ;) :p

Egh
26th November 2005, 21:39
@ Egh

For that you'll need additional filtering - perhaps: highpass the effect, filter the HP accordingly, mix back, then apply.

Of course it needs quite some more fiddling around ... should be no problem. Since you're one of the big boys releasing things, you know what you're doing. :)

OK, i'll later also show similar (but not exactly same) pictures from HiMM as well. In fact what I like in your approach, is that characters look OK. In my approach I made perfect backgrounds (especially stills), but characters look a bit messy.

Btw, even in your example I can still notice halo around egdes. Is it possible to completely remove it?

As for artefacts, haven't tried yet, but almost sure RemoveGrain+DeGrainMedian will do the job there.

P.S. Why bicubic resizer was used in the script btw?

Didée
26th November 2005, 23:32
OK, i'll later also show similar (but not exactly same) pictures from HiMM as well.
Please make up an own thread for that. Unsharp masking is a basic procedure, and has not that much to do with this thread's topic.


In fact what I like in your approach, is that characters look OK. In my approach I made perfect backgrounds (especially stills), but characters look a bit messy.
Btw, even in your example I can still notice halo around egdes. Is it possible to completely remove it?
Consider that script and result were a matter of just a couple of minutes. As said, there's lots of room for improving. You see what one single step of rather primitive unsharp masking can do here. Imagine what can be achieved when one comes into fiddling. :)


P.S. Why bicubic resizer was used in the script btw?
Because bicubic resizing is a rather fast and mostly accurate enough method to simulate gaussian blurring, the reversal of which is unsharp masking. There are filters out there doing a more accurate gaussian blur, needing the x-fold time for computing ... only that in the end you can hardly see a difference. :)

JoeBG
26th November 2005, 23:56
@ Didee

I´ve heard many good topics about Limited Sharpen but I don´t know anyone who knows how to use it (max knows it). Is this also a project for noone like your "Logoskript" which is impossible to get used by the normal user? So please stop making anything in the way you do - the normal (but skilled) user would be much happier if you just make internal posts and we don´t see what you do.

charleski
27th November 2005, 00:15
If you can't understand it, use the more basic tools and deal with it. Didee and the other script writers have contributed a huge amount to this forum.

DigitalDeviant
27th November 2005, 01:12
@ Didee

I´ve heard many good topics about Limited Sharpen but I don´t know anyone who knows how to use it (max knows it). Is this also a project for noone like your "Logoskript" which is impossible to get used by the normal user? So please stop making anything in the way you do - the normal (but skilled) user would be much happier if you just make internal posts and we don´t see what you do.

What the... Well, I for one am very happy Didée posts his functions here and LimitedSharpen works fine for me and I am far from an expert with avisynth. If you don't want to see, just don't read the posts. Better yet, why not take your time, read slowly, ask questions to what you don't understand.

Chainmax
27th November 2005, 01:45
@ Didee

I´ve heard many good topics about Limited Sharpen but I don´t know anyone who knows how to use it (max knows it). Is this also a project for noone like your "Logoskript" which is impossible to get used by the normal user? So please stop making anything in the way you do - the normal (but skilled) user would be much happier if you just make internal posts and we don´t see what you do.

Just because whatever limited number of videophiles you know has no clue on how to make an avisynth function works does not mean that it's impossible to use. Pretty much everyone around here knows how to use it and would gladly teach you provided you were a little more polite and didn't assume everyone knows as little as you do. Please think things through before criticising free pies (http://forum.doom9.org/showthread.php?t=7770&highlight=free+pies).

Pookie
27th November 2005, 01:54
JoeBG - Sounds like you're frustrated. Nothing of value comes without a struggle.

If you want the easy way, just add this to your script:

Sharpen(0.1)

It won't look very good, but it will be very simple to use.

Didée
27th November 2005, 02:08
@ JoeBG

Oh come on. What's your problem, what's your problem with LimitedSharpen, and who is "max"?

Backwoods
27th November 2005, 04:20
He speaks for himself. Ignore him and he'll go away and hopefully learn on his own.

Pookie
27th November 2005, 05:35
BTW, Smode=4 . Wow.

Original
http://www.uploadhouse.com/images/817904939orig.png (http://www.uploadhouse.com/)

Smode=4
http://www.uploadhouse.com/images/120876719smode4.png (http://www.uploadhouse.com/)

Didée
27th November 2005, 12:17
Yep, Smode 4 has ... something. ;)
However on it's own, it has this tendency to give some small crumbling ... for real encoding, I'd recommend to Soothe() it.

Aaargh ... I corrected that small buglet only in the version for MT_alpha, not the normal one. /*slaps forehead*/
Under work ...

Edit: The preview version of LimitedSharpen for "old" MaskTools v1.5.x is corrected. (this thread (http://forum.doom9.org/showthread.php?p=731909#post731909)) Smode=4 is calmer now. Formerly it did enhance small&weak noise somewhat more than it should.

Chainmax
28th November 2005, 01:30
So, is there a new official version out or not? If so, will the script in the 1st page be updated?

Didée
28th November 2005, 01:35
You're still encoding with the official "v1.0" version of XviD? :D

I'll update the first page when all things are in that should be in. Which will not be during the next week, definetly.

psme
28th November 2005, 02:28
Hi Didée,

Your post said:
"edit 29 Nov:
The small bug in Smode=4 was only fixed in the version for MaskTools 2.0alpha. Now corrected this version for old MaskTools, too."

So where is this "the version for MaskTools 2.0alpha" with the Smode=4 fix? Thanks in advance.

regards,

Li On

Jcubed04
28th November 2005, 08:25
I've been using this script since shortly after it was released and I love it. Thanks a lot, Didée.

I just recently tried out the modded version and wanted to offer some feedback on "a separate "undershoot" parameter, to allow for some line darkening in comic or Anime." The line darkening effect seems very light to me. For example, even undershoot=255 has only about 1/10 the effect of FastLineDarken(). In other words, I think that feature needs a bit more work to be useful. Once again, thanks a lot.

Didée
28th November 2005, 09:12
@ psme

Socio was so kind to make the adaption for MaskTools v2-alpha. See this post (http://forum.doom9.org/showthread.php?p=734246#post734246).


@ Jcubed04

"Undershoot" is not meant do force any line darkening. It just allows to do the cutting-off of the sharpening effect "later", in those places where it actually makes pixels darker. To force more darkening, you have to increase the sharpening strength. Try

LimitedSharpen(Smode=1, radius=3, strength=2048, undershoot=255)

and look again whether lines get darker or not ;)
(But heaven help, never use it like this!)

ariga
28th November 2005, 11:24
Nice script Didee. But could you edit the first post with the latest developments. Perphaps add a link to the current version and put the requirements listed in this post (http://forum.doom9.org/showthread.php?p=737437#post737437) into LimitedSharpen.avs itself ?

Then we would see less rants from frustrated users ;)

Chainmax
28th November 2005, 12:17
Wait a minute, LimitedSharpen now does line thinning? :eek:

/keels over and falls to the ground/

Would it be possible to make thinning the way aWarpSharp does?

Didée
28th November 2005, 16:37
Wait a minute, LimitedSharpen now does line thinning? Not that I knew of. Who says so?
Sometimes it may look like that, if a steepy gradient happens to have a certain slope - but that's more of a random side-effect.


Would it be possible to make thinning the way aWarpSharp does? Hmh, the best way to make thinning in the way aWarpSharp does, most probably is ... to use aWarpSharp? :)

Chainmax
28th November 2005, 18:21
Oy, darkening <> thinning. I should make an appointment with my ophthalmologist already :o.

cwk
28th November 2005, 19:23
Howdy guys,

I am unable to download the newest LS with the fixes that Socio made. When I click on the "Download Now" anchor on the savefile web page, nothing happens. Am I the only one to experience this? Am I doing something wrong?

ck

Socio
28th November 2005, 20:40
Yea that place is not doing so good for my downloads but I can't complain too much because it is free after all.

Here is Didees LimitedSharpen that works with Masktools 2.0 versions:



# LimitedSharpen() ( a modded version, 29 Oct 2005 )
#
# A multi-purpose sharpener by Didée
#
#
# Changes in this mod:
#
# - RemoveGrain >= v0.9 IS REQUIRED!!
# ==================================
#
# - Smode=4 / sometimes does the magic ;-)
# - a separate "undershoot" parameter, to allow for some line darkening in comic or Anime
# - Lmode=3 / on edges, limited sharpening with zero OS & US. On not-edges, limited sharpening with specified OS + LS
# - "soft" acts different now: no more boolean true/false, but instead integer 0 - 100 (or -1 -> automatic)
# instead of blurring before finding minima/maxima, it now softens the "effect-of-sharpening"
# - edgemode=-1 now shows the edgemask. (scaling still not implemented :p )
#

function LimitedSharpen( clip clp,
\ float "ss_x", float "ss_y",
\ int "dest_x", int "dest_y",
\ int "Smode" , int "strength", int "radius",
\ int "Lmode", bool "wide", int "overshoot", int "undershoot",
\ int "soft", int "edgemode", bool "special",
\ int "exborder" )
{
ox = clp.width
oy = clp.height

Smode = default( Smode, 3 )
ss_x = (Smode==4)
\ ? default( ss_x, 1.25)
\ : default( ss_x, 1.5 )
ss_y = (Smode==4)
\ ? default( ss_y, 1.25)
\ : default( ss_y, 1.5 )
dest_x = default( dest_x, ox )
dest_y = default( dest_y, oy )
strength = (Smode==1)
\ ? default( strength, 160 )
\ : default( strength, 100 )
strength = (Smode==2&&strength>100) ? 100 : strength
radius = default( radius, 2 )
Lmode = default( Lmode, 1 )
wide = default( wide, false )
overshoot = default( overshoot, 1)
undershoot= default( undershoot, overshoot)
softdec = default( soft, 0 )
soft = softdec!=-1 ? softdec : sqrt( (((ss_x+ss_y)/2.0-1.0)*100.0) ) * 10
soft = soft>100 ? 100 : soft
edgemode = default( edgemode, 0 )
special = default( special, false )
exborder = default( exborder, 0)
#radius = round( radius*(ss_x+ss_y)/2) # If it's you, Mug Funky - feel free to activate it again
xxs=round(ox*ss_x/8)*8
yys=round(oy*ss_y/8)*8
smx=exborder==0?dest_x:round(dest_x/Exborder/4)*4
smy=exborder==0?dest_y:round(dest_y/Exborder/4)*4

clp.isYV12() ? clp : clp.converttoyv12()

ss_x != 1.0 || ss_y != 1.0 ? last.lanczosresize(xxs,yys) : last
tmp = last

edge = mt_logic( tmp.mt_edge(thY1=0,thY2=255,"8 16 8 0 0 0 -8 -16 -8 4")
\ ,tmp.mt_edge(thY1=0,thY2=255,"8 0 -8 16 0 -16 8 0 -8 4")
\ ,"max") .mt_lut("x 128 / 0.86 ^ 255 *") #.levels(0,0.86,128,0,255,false)

tmpsoft = tmp.removegrain(11,-1)
dark_limit1 = tmp.mt_inpand()
bright_limit1 = tmp.mt_expand()
dark_limit = (wide==false) ? dark_limit1 : dark_limit1 .removegrain(20,-1).mt_inpand()
bright_limit = (wide==false) ? bright_limit1 : bright_limit1.removegrain(20,-1).mt_expand()
minmaxavg = special==false
\ ? mt_lutxy(dark_limit1,bright_limit1,yexpr="x y + 2 /")
\ : mt_merge(dark_limit,bright_limit,tmp.removegrain(11,-1),Y=3,U=-128,V=-128)

Str=string(float(strength)/100.0)
normsharp = Smode==1 ? unsharpmask(strength,radius,0)
\ : Smode==2 ? sharpen(float(strength)/100.0)
\ : Smode==3 ? mt_lutxy(tmp,minmaxavg,yexpr="x x y - "+Str+" * +")
\ : mt_lutxy(tmp,tmpsoft,"x y == x x x y - abs 16 / 1 2 / ^ 16 * "+Str+" * x y - 2 ^ x y - 2 ^ "+Str+" 100 * 25 / + / * x y - x y - abs / * + ?")

OS = string(overshoot)
US = string(undershoot)
Lmode == 1 ? mt_lutxy( bright_limit, normsharp, yexpr="y x "+OS+" + < y x "+OS+" + ?")
\ : mt_lutxy( bright_limit, normsharp, yexpr="y x "+OS+" + < y x y x - "+OS+" - 1 2 / ^ + "+OS+" + ?")
Lmode == 1 ? mt_lutxy( dark_limit, last, yexpr="y x "+US+" - > y x "+US+" - ?")
\ : mt_lutxy( dark_limit, last, yexpr="y x "+US+" - > y x x y - "+US+" - 1 2 / ^ - "+US+" - ?")


normal=last
OS2 = "0"
US2 = "0"
mt_lutxy( bright_limit, normsharp, yexpr="y x "+OS2+" + < y x "+OS2+" + ?")
mt_lutxy( dark_limit, last, yexpr="y x "+US2+" - > y x "+US2+" - ?")
zero=last

Lmode==3 ? mt_merge(normal,zero,edge.mt_inflate()) : normal

edgemode==0 ? last
\ : edgemode==1 ? mt_merge(tmp,last,edge.mt_inflate().inflate().removegrain(11,-1),Y=3,U=1,V=1)
\ : mt_merge(last,tmp,edge.mt_inflate().inflate().removegrain(11,-1),Y=3,U=1,V=1)

AMNT = string(soft)
AMNT2 = string(100-soft)
sharpdiff=mt_lutxy(tmp,last,"x y - 128 +")
sharpdiff2=mt_lutxy(sharpdiff,sharpdiff.removegrain(19,-1),"x 128 - abs y 128 - abs > y "+AMNT+" * x "+AMNT2+" * + 100 / x ?")

soft==0 ? last : mt_lutxy(tmp,sharpdiff2,"x y 128 - -")

(ss_x != 1.0 || ss_y != 1.0)
\ || (dest_x != ox || dest_y != oy) ? lanczosresize(dest_x,dest_y) : last

ex=blankclip(last,width=smx,height=smy,color=$FFFFFF).addborders(2,2,2,2).coloryuv(levels="TV->PC")
\.blur(1.3).mt_inpand().blur(1.3).bicubicresize(dest_x,dest_y,1.0,.0)
tmp = clp.lanczosresize(dest_x,dest_y)

clp.isYV12() ? ( exborder==0 ? tmp.mergeluma(last)
\ : mt_merge(tmp,last,ex,Y=3,U=1,V=1) )
\ : ( exborder==0 ? tmp.mergeluma(last.converttoyuy2())
\ : tmp.mergeluma( mt_merge(tmp.converttoyv12(),last,ex,Y=3,U=1,V=1)
\ .converttoyuy2()) )

(edgemode!= -1) ? last : edge.lanczosresize(dest_x,dest_y).greyscale

return last
}

cwk
28th November 2005, 20:54
Got it. Thank you Socio.

mg262
28th November 2005, 22:06
I wrote filter equivalents of two script functions:
function scriptclamp(clip main, clip bright_limit, clip dark_limit, int overshoot, int undershoot)
# clamp main to lie between bright_limit + overshoot and dark_limit - overshoot
{
OS = string(overshoot)
US = string(undershoot)
yv12lutxy( bright_limit, main, yexpr="y x "+OS+" + < y x "+OS+" + ?")
yv12lutxy( dark_limit, last, yexpr="y x "+US+" - > y x "+US+" - ?")
return last
}

function scriptsimpleaverage(clip first, clip second)
{
yv12lutxy( first, second, yexpr="x y + 2 /")
return last
}called, respectively, Clamp and SimpleAverage.

LimitedSupport, 28 November 05 (http://people.pwf.cam.ac.uk/mg262/posts/LimitedSupport_28Nov05.dll)
Source (http://people.pwf.cam.ac.uk/mg262/posts/LimitedSupport_28Nov05.zip)

The functions are 5 to 10 times faster than script equivalents; incorporating them gives a measurable but pretty small speed up. OTOH the cost (i.e. loading one more plug-in) is also pretty small...

To do better requires ignoring some options...can I ask:
-- how important are wide and special?
-- is SMode 4 planned to become the new default?

Jcubed04
28th November 2005, 22:54
@Didée: Ah, I understand how undershoot works now, thanks for the explanation. For my purposes definitely better to use LimitedSharpen at sane strength levels then FastLinkDarken afterwards. I'm also liking the development of Smode=4, keep up the good work.

Socio
29th November 2005, 01:09
@ Socio

Heyhey, for *realtime* processing of *720p* content, that's a result, isnt it!
(What processor did you say you are running ...) :dreams:

The still has some of that "plastic" look, okay ... but there's a considerable amount of interference noise to be removed, and everything is done with simple and basic filtering - in RT. Good result, I'd say.

It's just that with the used settings, you almost reduced LimitedSharpen() to ModerateSharpen(). Which indeed could be a way to free some CPU cycles for another task.
Give a try on

repair(last.sharpen(0.6),last,1,3)

instead of LimitedSharpen, and see if there's much of a difference. This could also allow you to ease the croma settings of another filter (most probably: ditch the chroma part of the gaussian blur, and/or reduce HQDN3D's spatial chroma setting).

Another thing to try: seeing there're still leftover noise from the interference, try if you can afford to put something like

mergeluma( removegrain(2,-1), 0.25 ~ 0.50 ) (weak), up to
mergeluma( removegrain(4,-1), 0.08 ~ 0.16 ) (strong)

before the sharpening. Could work out with the simplified sharpening from above.
(It's hard to judge from here how much of an issue the leftover noise really is, if at all. But you have the experience with toying around, I guess ;) )

A pity there's no time to reduce the haloing ...


Thanks for the suggestions!

I like the mergeluma(removegrain) over the denoise3d, I get a much clearer cleaner image. In fact I eliminated ffdshow Denoise3d and swscaler altogether and use your abcxyz dehaloing script that I fixed to run with masktools 2.0. I run it in between the mergeluma(removegrain) and Limitedsharpen ( I prefer Limitedsharpen over the Repair sharpen call) and it runs just fine in real time even re-sized to 780P. :)

Chainmax
29th November 2005, 01:36
Jcubed04, don't you find FastLineDarken to produce slight aliasing even at low settings and with thinning disabled?

Socio, abcxyz is completely pasée now. Didée made a new halo removal function that works wonderfully. It can also be found in the "New halo removers discussion" thread.

ariga
29th November 2005, 10:02
RemoveGrain 0.9 complains that 19 is an invalid mode ! Is it a typo or is there a newer version of RemoveGrain that supports it ?

Didée
29th November 2005, 10:07
Ah, mode 19 is not in the 0.9 version indeed. So it does need the pre-1.0 version of RemoveGrain:

http://home.arcor.de/kassandro/RemoveGrain/RemoveGrain.rar

Socio
29th November 2005, 14:26
Jcubed04, don't you find FastLineDarken to produce slight aliasing even at low settings and with thinning disabled?

Socio, abcxyz is completely pasée now. Didée made a new halo removal function that works wonderfully. It can also be found in the "New halo removers discussion" thread.

You mean DeHalo_alpha,

You know I modified it to work with masktools 2.0 versions and tried it out but found it to slow for real time. However after your post I played with it again. The one thing I forgot to do when previously testing DeHalo_alpha for real time usage was turn off super sampling. I tried it with SS off and it runs great in real time with Limitedsharpen and mergeluma-remove grain calls and the PQ looks awesome. I think abcxyz is very proficient in my real time application of it but so far I am liking the DeHalo_alpha now that I have it running, even more.

Didée
29th November 2005, 17:37
@ Clouded

I wrote filter equivalents of two script functions:

[...Code...]

called, respectively, Clamp and SimpleAverage.

LimitedSupport, 28 November 05 (http://people.pwf.cam.ac.uk/mg262/posts/LimitedSupport_28Nov05.dll)
Source (http://people.pwf.cam.ac.uk/mg262/posts/LimitedSupport_28Nov05.zip)

The functions are 5 to 10 times faster than script equivalents; incorporating them gives a measurable but pretty small speed up. OTOH the cost (i.e. loading one more plug-in) is also pretty small...

To do better requires ignoring some options...can I ask:
-- how important are wide and special?
-- is SMode 4 planned to become the new default?

You forgot an important one: Prewitt() ! :)

(BTW, did you ever post a link to the 17Oct05 version? I seem to only find posts linking to the 08Aug05 version, prior to including "multiplier".)

"wide" I consider rather important, personally ... would not want to miss it. It should be much faster anyway, when using MaskTools 2.0 alpha (with its optimized In/Expand).

"special" I would not consider important. It often produces artefacts, like halos and whatnotelse. It will be ditched, and replaced with something ... pssst ... much more special. :D

"Smode" - the available sharpening modes will be extended and modified. What Smode=4 is now running with some fixed values, will be parametrized & adjustable.
(Here, a filter ala "RemoveGrain(x)^(-1)_plus_Lutxy" would be handy...).

mg262
29th November 2005, 18:54
Oops :D. I added 17-Oct Prewitt to LimitedSupport -- saves hunting down a gazillion DLLs. I may release it separately with a few more options.

LimitedSupport, 29 November 05 (http://people.pwf.cam.ac.uk/mg262/posts/LimitedSupport_29Nov05.dll)

@all: it's just an edge mask; usage is Prewitt(multiplier = 1.0). Chroma is trashed; output luma is scaled by multiplier. More details here (http://videoprocessing.11.forumer.com/viewtopic.php?t=16&highlight=prewitt).

"wide" I consider rather important, personally ... would not want to miss it. MMmm... I'd just figured a way to build a really fast limit = 1, wide = false filter [i.e. inpand and expand and clamp all at once]. 'Standard' LS version spends nearly all time in MT (maybe 85%), split about 33% inpand, 33% expand, 33% in lookups, on both SModes 3 and 4... so a filter as described would give a substantial speedup. I haven't measured with MT 2.0 (currently have v2.5.5 loaded), but it should still be faster. Maybe I'll wait and see how things evolve...

BTW, using Clamp and SimpleAverage should give a bigger speed up to the MT 2.0 version than the main version.

(Here, a filter ala "RemoveGrain(x)^(-1)_plus_Lutxy" would be handy...).Any particular RG modes? By the way, I've noticed that you often use Lutxy to compute things of the form x+f(x-y) ... it might be possible to build a 'DiffLUT' to speed these up...

Socio
29th November 2005, 22:25
mg262,

I am trying to figure out what you are doing and how to implement your dll. :confused:

Are you replacing sections of Limitedsharpen with calls to your dll or trying to make Limitedsharpen a dll plugin?

Also it looks like you are working with the older version of maskedtool functions when the 2.0 versions are faster you, if it is speed you are after you might want to switch to the 2.0 versions.

mg262
29th November 2005, 22:39
I'm trying to speed it up, but not because I need it to be fast... I just wanted to code something useful. When I upgrade to 2.5.6, MaskTools version 2.0 is going to be the first thing moved into my plug-in directory. [I think I have got part of it working in 2.5.5, but I don't want to rely on that.]

I'm writing fragments, mostly intended for use in specific bits of the script but also usable generally. I should probably have written out a modified script...but I didn't like to do that without asking Didée, plus there are at least 4 versions out there... . Sorry if it was confusing.

In your script, try the following changes:
\ ? mt_lutxy(dark_limit1,bright_limit1,yexpr="x y + 2 /")to \ ? SimpleAverage(dark_limit1, bright_limit1)

OS = string(overshoot)
US = string(undershoot)
Lmode == 1 ? mt_lutxy( bright_limit, normsharp, yexpr="y x "+OS+" + < y x "+OS+" + ?")
\ : mt_lutxy( bright_limit, normsharp, yexpr="y x "+OS+" + < y x y x - "+OS+" - 1 2 / ^ + "+OS+" + ?")
Lmode == 1 ? mt_lutxy( dark_limit, last, yexpr="y x "+US+" - > y x "+US+" - ?")
\ : mt_lutxy( dark_limit, last, yexpr="y x "+US+" - > y x x y - "+US+" - 1 2 / ^ - "+US+" - ?")toOS = string(overshoot)
US = string(undershoot)
Lmode == 1 ? 0
\ : mt_lutxy( bright_limit, normsharp, yexpr="y x "+OS+" + < y x y x - "+OS+" - 1 2 / ^ + "+OS+" + ?")
Lmode == 1 ? clamp(normsharp, bright_limit, dark_limit, overshoot, undershoot)
\ : mt_lutxy( dark_limit, last, yexpr="y x "+US+" - > y x x y - "+US+" - 1 2 / ^ - "+US+" - ?")
You could also probably change
OS2 = "0"
US2 = "0"
mt_lutxy( bright_limit, normsharp, yexpr="y x "+OS2+" + < y x "+OS2+" + ?")
mt_lutxy( dark_limit, last, yexpr="y x "+US2+" - > y x "+US2+" - ?")
zero=lasttozero = clamp(normsharp, bright_limit, dark_limit, 0, 0)Do ask here or PM me if anything is unclear.

Jcubed04
30th November 2005, 04:03
@Chainmax: I only use FastLineDarken for anime sources and I use at least some line thinning. Under those conditions I've never had aliasing problems.

Socio
1st December 2005, 00:11
mg262,

This is strange but I can change out the first codes you suggested and the last codes you suggested and LS runs just fine but when I swap out:

OS = string(overshoot)
US = string(undershoot)
Lmode == 1 ? mt_lutxy( bright_limit, normsharp, yexpr="y x "+OS+" + < y x "+OS+" + ?")
\ : mt_lutxy( bright_limit, normsharp, yexpr="y x "+OS+" + < y x y x - "+OS+" - 1 2 / ^ + "+OS+" + ?")
Lmode == 1 ? mt_lutxy( dark_limit, last, yexpr="y x "+US+" - > y x "+US+" - ?")
\ : mt_lutxy( dark_limit, last, yexpr="y x "+US+" - > y x x y - "+US+" - 1 2 / ^ - "+US+" - ?")

For this:

OS = string(overshoot)
US = string(undershoot)
Lmode == 1 ? 0
\ : mt_lutxy( bright_limit, normsharp, yexpr="y x "+OS+" + < y x y x - "+OS+" - 1 2 / ^ + "+OS+" + ?")
Lmode == 1 ? clamp(normsharp, bright_limit, dark_limit, overshoot, undershoot)
\ : mt_lutxy( dark_limit, last, yexpr="y x "+US+" - > y x x y - "+US+" - 1 2 / ^ - "+US+" - ?")

What ever application I am using Limitedsharpen in will crash so there could be a bug in your dll. I am using the November 29 dll by the way

Didée
1st December 2005, 00:22
Syntax error. Replace that "0" (in Lmode==1 ? 0) with "clp", or "last", or "NOP()", or "blankclip" ... or even comment out the whole line if you're not going to use Lmode=2.

mg262
1st December 2005, 00:32
I thought that since both numbers and videos can be stored in an AVSValue, it would be okay... but presumably the interpreter needs to know the type (clip/int) of the expression before its evaluated. It ran fine on my machine -- but it sounds like that's just luck. So either change it as suggested or clean up the messiness I created like this:

OS = string(overshoot)
US = string(undershoot)
mt_lutxy( bright_limit, normsharp, yexpr="y x "+OS+" + < y x y x - "+OS+" - 1 2 / ^ + "+OS+" + ?")
mt_lutxy( dark_limit, last, yexpr="y x "+US+" - > y x x y - "+US+" - 1 2 / ^ - "+US+" - ?")

Lmode == 1 ? clamp(normsharp, bright_limit, dark_limit, overshoot, undershoot) : last

I hope there's no silly mistakes this time... I am not good at writing scripts!

NoodleMaps
1st December 2005, 08:48
Just wanted to say Thank you Didée for these improvments to LS. I am blown away by Smode 4 on my analog conversions.

I was just wondering if you could explain the new Soft function, and how it works now?

Didée
1st December 2005, 11:15
Okay, you asked for it ;)

The "soft" option now works as follows:

- first compute the sharpening
- build the difference map between "input" and "sharpened"
- apply a modified blurring to the difference map
- apply the blurred difference map to the input

The modified blurring works by only allowing pixel values getting closer to 128, not farther away from 128. This is important: a plain blur to the difference map in the end would result in the "fat" look of unsharp masking (ugh!). This sort of "reduction blur" retains the sharp look, because it is more similar to a linear scaling. But then again, it is smarter then just doing linear scaling: where plain scaling would just reduce the effect everywhere by the same amount, this sort of blurring is respecting spatial coherency of the current pixel. (Kind of that ... it's a poor man's method. True spatial "tracing" is not possible to do through an avisynth script.)
So, for a pixel that received sharpening values very different from those of its neighbors, the sharpening will be reduced more (i.e. a pixel that got darker, where all of its neighbors got brighter). For a pixel that received sharpening values rather similar to those of its neighbors, the sharpening will be reduced less.

The idea behind the new "soft" mode were:

- reduce aliasing when using only little supersampling (or none at all)

- try to be detail- and noise-aware. The more neighbor pixels are having similar properties than the current pixel, the more likely it is we're on a detail's edge, and we want to allow sharpening. If current pixel's properties are very different to those of its neighbors, the pixel probably is noisy, and we don't want to sharpen it.


That's basically it. Good values for "soft" depend on the supersampling factors (small ss factors --> small values for "soft", and TOWR), and on the sharpening strength. Or vice versa for strength - if you use e.g. soft=33, increase also the strength ... perhaps by 33% as a start, and make your way from there.

Socio
1st December 2005, 15:03
mg262,

I tried Didees suggestions and your new code but it still crashes and appears to be a bug in your dll perhaps in conjunction with using masktools 2.0 I don't know.

It it was as simple as a syntax error I would get a blurb on my image screen saying " syntax error line xx" however this is typical crash pop up when I try it with any variation of that second set of code:

http://img200.imageshack.us/img200/2055/lssupport8wj.jpg

mg262
1st December 2005, 19:14
Sorry about this. I've loaded version 2.56rc2/2.0a10 and your script but I can't reproduce the error so it may take a bit to hunt down. I don't want to clutter up this thread, so I will PM you if that's okay...

mg262
2nd December 2005, 14:37
Socio found an eeevil assembly bug for particular frame widths. I'll release a fixed version as soon as it's confirmed that it's ok.

The speed up due to LimitedSupport in the MaskTools 2.0 version is considerable -- from 15 FPS to 21 FPS on my box (as measured with AVSTimer; n.b. this excludes time in DGDecode, etc). Looking at where the time is spent (all default params):

http://people.pwf.cam.ac.uk/mg262/posts/lsspeed.png

it seems that the new bottleneck is in AVISynth itself, i.e. upsampling and downsampling. So, if you're playing back DVDs on a fast box, I think real-time LimitedSharpen may be possible by supersampling up to the target resolution (e.g. 1024 x 768) to cut out one resampling step. (Is that sensible, Didée?)

Didée
2nd December 2005, 15:24
Should be like that, yup. But I can't tell for sure, since I'm not on a fast box (Athlon 1800 & Celeron 2600) :)

mg262
2nd December 2005, 18:44
LimitedSupport, 2 December 05 (http://people.pwf.cam.ac.uk/mg262/posts/LimitedSupport_02Dec05.dll)
(+ many thanks to Socio for putting in a lot of work tracking down the problem)

Didée, Socio, I hope it's okay if I post the modified script (if you'd rather I didn't, I'll take it down):
Fast LimitedSharpen version using both MaskTools 2.0 + LimitedSupport (http://people.pwf.cam.ac.uk/mg262/posts/LimitedSharpenFaster.avsi) (hopefully no more silly script bugs :o)

MaskTools 2.0 thread (http://forum.doom9.org/showthread.php?t=98985)
RemoveGrain 1.0 pre-release thread (http://videoprocessing.11.forumer.com/viewtopic.php?t=9)

Edit: NB Didée, I've avoided SSE2 in this (and in fact in nearly everything else I'm coding recently + henceforth), so it should work on your machine.

Socio
2nd December 2005, 19:40
Didée, Socio, I hope it's okay if I post the modified script (if you'd rather I didn't, I'll take it down):


Looks good to me but this is Didees show not mine.

The modified LimitedSharpen and the Limitedsupport.dll do work great by the way!

Didée
3rd December 2005, 02:18
Clouded - Thank you! No objections at all, why should I? (All is fine as long as you don't build in some sort of PoorSharpen(), then sell it as LimitedSharpen34() ... I remember something like that.)
However, the formatting suffered a little. Don't show that to mf! ;)

Oh, and surely you must not avoid using SSE2, and definetly not because of me. It's just that there still are pretty much non-SSE2 Athlons out there ... so you'll simply do a CPU detection, and use uber-optimized code for the respectively available instruction sets, no? /*ducks*/ ;)


Socio: so this means you can now process 1080p in realtime, while doing a couple of encodings in the background? :D

Thanks for testing, and for supporting Clouded!

mg262
3rd December 2005, 04:55
Well, it is your script so I don't like doing anything to it without checking with you. Thank you for letting me poke it :).

However, the formatting suffered a little. Don't show that to mf!:confused: Do you mean the commented section? I've cut that out. Apart from that it's almost the same as the version I modified, I think... although the soft line breaks due to a QUOTE block have disappeared. Shall I put more \s in?

BTW, not in this case but for longer scripts (e.g. iip), it gets tricky to cut/paste all the code out of a CODE block; is there an easier way of extracting it?

CPU: SSE2 typically isn't much faster than SSE, and having two versions makes it twice as hard to track down problems! It's certainly not just you who is affected*... but most of my plug-ins are for scripts rather than direct use, and I'm shooting myself in the foot if you can't use them.**

*turns out to be quite a few people. I'm used to being on the slow-end of things... I had a 7-year-old PC until late '03; now I use a P4/2400. So I had to adjust to not using everything available.

**A few are for direct use. A few I actually use(!); you can tell because they are a little more... complicated.

Edit: I added one more function, for something I have seen you use once or twice ;) :

LimitedSupport, 3 December 05 (http://people.pwf.cam.ac.uk/mg262/posts/LimitedSupport_03Dec05.dll)

Delta(a, b) = mt_lutxy(a, b, "x y - 128 +") = mt_lutxy(a, b, "x y 128 - -")

'Delta' is just a working name, not a permanent one; I thought you might want two different names to correspond to the two different uses, something like Diff and SubtractDiff?

Kador
3rd December 2005, 12:54
LimitedSupport, 2 December 05 (http://people.pwf.cam.ac.uk/mg262/posts/LimitedSupport_02Dec05.dll)
(+ many thanks to Socio for putting in a lot of work tracking down the problem)

Didée, Socio, I hope it's okay if I post the modified script (if you'd rather I didn't, I'll take it down):
Fast LimitedSharpen version using both MaskTools 2.0 + LimitedSupport (http://people.pwf.cam.ac.uk/mg262/posts/LimitedSharpenFaster.avsi) (hopefully no more silly script bugs :o)

MaskTools 2.0 thread (http://forum.doom9.org/showthread.php?t=98985)

Edit: NB Didée, I've avoided SSE2 in this (and in fact in nearly everything else I'm coding recently + henceforth), so it should work on your machine.

Hi,

when I use those versions, I get a mode 19 unsupported error in masktools

normal ?

Kador
3rd December 2005, 12:56
Should we rename the Limitedsupportxxxxxxx.dll to LimitedSupport.dll ?

Could you list the needed dlls and avisynth call to get this stuff working right ?

thanx

ariga
3rd December 2005, 13:01
Hi,
when I use those versions, I get a mode 19 unsupported error in masktools normal ?
http://forum.doom9.org/showthread.php?p=743931#post743931

Kador
3rd December 2005, 13:10
Thanx, but I don't understand : mp262 states that the Faster LS uses Masktools 2.0 and you point me to a older version (pre-1.0 ???)

Kador
3rd December 2005, 13:15
Thanx, but I don't understand : mp262 states that the Faster LS uses Masktools 2.0 and you point me to a older version (pre-1.0 ???)

ok, I should buy other glasses, I mixed up masktools and removegrain

mg262
3rd December 2005, 13:43
Should we rename the Limitedsupportxxxxxxx.dll to LimitedSupport.dll ?If you like... it doesn't make any difference, so long as you load it. If you find it annoying to type out the _02Dec05 bit,Pookie found a really useful utility:Here's a simple app that takes some of the drudgery out of AviSynth (and any scripting app) file creation/modification.

PathCopyEx- A small shell extension that adds "Copy Path to ClipBoard" to your right click menu. Makes it so much easier when you're working on an AVS script and need to point to new files and plugins.

http://www.mlin.net/misc.shtml
I've added a link to the relevant version of RemoveGrain to the post; I think that's all that's needed for that version.

Didée
3rd December 2005, 19:03
However, the formatting suffered a little. Don't show that to mf!
:confused: Do you mean the commented section? I've cut that out. Apart from that it's almost the same as the version I modified, I think... although the soft line breaks due to a QUOTE block have disappeared. Shall I put more \s in?
The tabbing, I was referring to the tabbing ...

before - http://img408.imageshack.us/img408/8825/lsbefore5bf.th.png (http://img408.imageshack.us/my.php?image=lsbefore5bf.png) ... vs. yours - http://img408.imageshack.us/img408/4874/lsafter2ia.th.png (http://img408.imageshack.us/my.php?image=lsafter2ia.png)

The syntax highlighting is the last bit of rescue for readability ...
Well then, my formatting style might not be everyone's taste, too. I know. But I love it ;)


Delta(a, b) = mt_lutxy(a, b, "x y - 128 +") = mt_lutxy(a, b, "x y 128 - -")

'Delta' is just a working name, not a permanent one; I thought you might want two different names to correspond to the two different uses, something like Diff and SubtractDiff?
Aaah! Yes, both instructions are the same, and I only use them differently because of better indication (to myself ;) )what's actually happening.
However there are cases where also the opposite operation is needed. If, perhaps, you could implement "MakeDiff", "SubtractDiff" and "AddDiff", that would be a really nice thing! Also readability of those scripts would be noticeably improved.

However those big mysterious LUTs will stay in, no matter what. (Be afraid of LS's successor.) :D

mg262
3rd December 2005, 19:16
LimitedSupport, 3 December 05 (revised) (http://people.pwf.cam.ac.uk/mg262/posts/LimitedSupport_03Dec05B.dll)

MakeDiff = SubtractDiff = "x y - 128 +" = "x y 128 - -"
AddDiff = "x y 128 - +"

I shall fix the tabs soon! And say a little more on LUTs... if you stopped using LUTs, I think I would send a doctor around, but there are more than two ways to LUT...

Edit: I realised I need to know how many spaces your tabs are set to...
... but one of One (http://people.pwf.cam.ac.uk/mg262/posts/LimitedSharpenFaster_firsttab.avsi), Two (http://people.pwf.cam.ac.uk/mg262/posts/LimitedSharpenFaster_secondtab.avsi) may look right? (Tab-killing wasn't deliberate, by the way... I got the script from a QUOTE block, which had killed the whitespace.)

Didée
3rd December 2005, 21:02
Neither. No way with hard tabs, I use fuzzy tabbing. ;)
(Famous old [now dead] painters didn't use any rulers, too.)

Perhaps it's browser related? I've no problems with preserving whitespaces when copying {code} from a thread and inserting into a text editor.

Thank you very much for the new DLL. Planned deadline for the new monster is in three weeks, not sure if I'll manage that. But the support DLL surely helps. :)

mg262
3rd December 2005, 21:17
{code} is fine but {quote} (see here (http://forum.doom9.org/showthread.php?p=743701#post743701)) kills whitespace, at least in Opera and IE :angry:. But... I just looked at the HTML and it looks ok :). I'll try with that... Edit: done, to match MT2 version (post 295); it's here (http://people.pwf.cam.ac.uk/mg262/posts/LimitedSharpenFaster.avsi).

Writing these things is good fun (and much easier/quicker than writing full filters) so let me know if you think of any more. Or, if you PM me scripts, I'll hunt for filterisable bits myself :sly:.

LimitedSupport has taken up more threadspace than I expected... would you rather I move future stuff to a separate thread?

Edit: In the course of testing, I seemed to find a discrepancy in LimitedSharpen(LMode = 3) between the versions (as of today) in posts 208 (http://forum.doom9.org/showthread.php?p=731909#post731909) (either attached version or linked version) and 295 (http://forum.doom9.org/showthread.php?p=743701#post743701).

I used this (renaming one version, obviously):
subtract( limitedsharpen(lmode =3),limitedsharpen_MT2(lmode =3))
levels(128 - 15, 1,128+15, 16, 235, coring = false)

It's more than likely that I've done something stupid, but could someone please check?

Didée
3rd December 2005, 21:55
Wasn't there a report that mt_merge was not working correctly? Wait ...

edit: It seems mt_merge does the inverse processing of what MaskedMerge does:

MaskedMerge( c1, c2, mask) == mt_merge( c1, c2, mask.invert() )

Seems there's some more work for Manao before MT2 gets really stable ... I remember to have produced some access violations when mt_convolution got the result of a former mt_convolution as input, or something like that ...
I've currently no time for bug hunting and reporting. For the moment I'm just not using MT2, if I can avoid it ... sorry.

Socio
3rd December 2005, 22:12
I thought Mano fixed mt-merge a couple versons ago, I could be mistaken.

mg262
3rd December 2005, 22:25
Didée,

I don't think you need to apologise -- but do be aware that the old Inpand and Expand are so expensive that the speed up from Lut-replacements or anything else is almost invisible. Using mt_in/expand from 2.0 and all the other functions from 1.5 should give a huge speed up, if you didn't consider it too risky.

FredThompson
10th December 2005, 09:50
Would someone bring me up to speed on the current status of LimitedSharpen? I've been using the script-only version from the start of the thread and just noticed there are some helper DLLs and, it appears, some new modes.

Shinigami-Sama
10th December 2005, 10:03
well
clouded has made some of the function in the script in a mathmaical sequance format, so its more effient, and how it's used I've still to figure out, theres seems to be multiple versions of LS floating around, mostly didee and his many betas, the dll version and the script should output the same, the dll'd one is just faster because of it's higher effienicy, and maybe a release or so of LS behind didee or the betas

thats what I gather anyways, the new mode I have no idea

FredThompson
10th December 2005, 10:07
Yeah, that's the way it looks to me. I'm not sure which would be the most recent version using the helper DLLs. I suppose it would be easier if I read French, but I don't. The DLLs look like substitutes for parts of the script.

Shinigami-Sama
10th December 2005, 10:09
that they are, more tightly coded bits of the script, and I've also been trying to figure out which one is newer and non-beta for a couple days now, maybe didee will tell us ^-^

mg262
10th December 2005, 11:46
Edit: In the course of testing, I seemed to find a discrepancy in LimitedSharpen(LMode = 3) between the versions (as of today) in posts 208 (http://forum.doom9.org/showthread.php?p=731909#post731909) (either attached version or linked version) and 295 (http://forum.doom9.org/showthread.php?p=743701#post743701).
As far as I know, Didée has only released one new experimental version (post 208). Socio released an update of that for MaskTools 2.0 (post 295); LMode = 3 doesn't work properly in this version because of problems with mt_merge, but as far as I know everything else is all right. I wrote a DLL (LimitedSupport, 3 December 05 (revised) (http://people.pwf.cam.ac.uk/mg262/posts/LimitedSupport_03Dec05B.dll) ) that speeds up portions of the script; you can use it with either version, but the speedup is only noticeable with the MaskTools 2.0 version. I also released a modified version of the script (http://people.pwf.cam.ac.uk/mg262/posts/LimitedSharpenFaster.avsi) that worked with this version; NB the function is called LimitedSharpenFaster, mainly so that if there are problems you know to poke me not Didée. You also need the 1.0 pre-release of RemoveGrain.

I've yet to see anything in French... and in any case, I think Didée is German, no :confused: ? But anyway, there is something on the new modes at the comments at the start of each script.

None of these modifications are "official" or checked by Didée... . I think he is working on a new official version, so you may want to wait for that.

HTH...
Clouded

Didée
10th December 2005, 17:12
Exactly like Clouded said. The version from page 1 still is the official one, although the modifikation posted in post 208 (http://forum.doom9.org/showthread.php?p=731909#post731909) works 100% reliable, hence is even recommended. Everything works as expected, and the additions Smode=4 and Lmode=3 might enable stronger texture enhancement than what one was used to formerly (however appliance of Soothe() might be better when using these).

For now, I want to keep any "official" version fully backwards compatible regarding the setup. MaskTools v2.0 as a whole is not free of quirks yet, and - more importantly - it *necessarily* requires Avisynth v2.56, which not everyone might be using yet.

So, instead of updating LimitedSharpen with small features or speedups that bring more confusion than benefit to the users (and to me the need of doing much explaining), time is better invested in fiddling with new toys. LimitedSharpen was good and all (and still is, of course), but its possibilities of enhancement are, well, limited. By now, it's time to go beyond what LS can do. I counted carefully, and found all needed puzzle pieces are there. The puzzle is big, and putting it together is very difficult. But then, it's definetly more challenging than doing minor poilshments on old toys, and explaining the change of glance.

Oh, and indeed I speak hardly five words of French. Don't be fooled by the acent. :)

scharfis_brain
10th December 2005, 17:35
Oh, and indeed I speak hardly five words of French. Don't be fooled by the acent. :)

OT:
Is it like: "Voulez vous manger avec moi?" :D

Manao
10th December 2005, 18:15
MaskTools v2.0 as a whole is not free of quirks yetDo you have some in minds ? Because I though I was up to date, bug wise.it *necessarily* requires Avisynth v2.56And rightly so. I don't see the trouble there. Somebody advanced enough to use LS will / should / ought to be up to date with avs, especially when v2.56 has no drawbacks compared to v2.55 ( at least, none that I can remember ). As a filter / script writer, you shouldn't worry about user not having a recent enough version of their tools, especially when the latest is stable. You can even force him to use 2.56 by checking versionnumber().

Shinigami-Sama
10th December 2005, 21:00
OT:
Is it like: "Voulez vous manger avec moi?" :D
isn't it: joues suis ne pas parle french

I can never spell french in french ever <.<


and thanks for the update guys, atleast I know what one to wait for now :)

m.rup
12th December 2005, 22:23
Hi,
I installed Avisynth 2.56, added LimitedSharpenFaster.avsi, MaskTools alpha (2.0a11) and RemoveGrain1.0 pre (SSE2, tried the others also) to plugin directory and tried to run an avs skript in media player classic. This caused the error message 'there is no function named removegrain....line 70' which is exactly the first call of remove grain in LimitedSharpenFaster script. Did I forget something to do or is there another mistake?

scharfis_brain
12th December 2005, 22:49
joues suis ne pas parle french
Even if I had barely four years of french at school which is eight years ago until now, this sentence doesn't look like any correct french grammar :).
I prooves you'll never speak or write french. Maybe only your women may enjoy it :-P .

Besides this your sentence has six instead of 5 words :D

Chainmax
12th December 2005, 22:56
OT:
Is it like: "Voulez vous manger avec moi?" :D

I suddenly want to watch Moulin Rouge :) :p.

Didée
13th December 2005, 08:59
I suddenly want to watch Moulin Rouge :) :p. I tried watching it, 3 times or so. But I never managed it to the end, fell asleep every time ...


@ m.rup

Sounds strange. However I never use plugin autoloading, and seldom run scripts in DS players, except for from within ffdshow.
What happens if you put plugins and scripts in another folder, and explicitely load/import plugins and function? Does this work (it should), or not?

m.rup
13th December 2005, 10:05
@Didee
Well, I use plugin autoloading because DVDrebuilder uses it. Interestingly I can call RemoveGrain directly in the avs script without loading it explicitely! However I will try to load the dll explicitely and see what will happen.

Besides, is RemoveGrain 1.0 pre required? I found the following line in the LimitedSharpen script:
# - RemoveGrain >= v0.9 IS REQUIRED!!

Didée
13th December 2005, 11:09
Better it is, and the note infact should refer to v1.0pre. The features "wide=true" and "soft=something" currently make use of RG modes 19 & 20, which are not available in RG v0.9.

m.rup
13th December 2005, 12:05
Thanks, that makes it clear. However strange that RemoveGrain itself can be used while calling it from inside the script is failing.

m.rup
14th December 2005, 10:29
Well! Uninstalled Avisynth and reinstalled it.
Downloaded again all required components.
Put them into plugin directory.
Learned by loading dll's with LoadPlugin explicitely that only RemoveGrainS is running although CPU-Z tells me I'm having a mobile pentium 4 with SSE2 available.
Ran avs script containing call of LimitedSharpenFaster ... and it worked!!
Seem's to be about three times faster than LimitedSharpen. Nice!
Great work. But there is one little downer: Soothe doesn't seem to work with MaskTools alpha (2.0a11). (blubb...there is no function named yv12lutxy...blah)
Could it lead to some interferenes when I would add also masktools 1.5.8 dll?
Tried to do so and it seemed to work, but ... who knows?
Or, Didee, *duck* would it be possible ...
Anyway, a reduction of duration from about 60 hours to 18 hours for one encode is a great benefit.
Thank you guys

Manao
14th December 2005, 10:34
No interferences. I prefixed all the functions name in the masktools v2 by "mt_" to avoid clashes.

m.rup
14th December 2005, 11:18
Marvellous! Thank you, Manao.

Socio
14th December 2005, 23:45
Great work. But there is one little downer: Soothe doesn't seem to work with MaskTools alpha (2.0a11). (blubb...there is no function named yv12lutxy...blah)

Thank you guys

Just use this version of Didee's Soothe it works fine with the new masktools


function Soothe(clip sharp, clip orig, int "keep")
{
keep = default(keep, 25)
keep = (keep>100) ? 100 : (keep<0) ? 0 : keep
KP = string(keep)
diff = mt_lutxy(orig,sharp,"x y - 128 +", U=1,V=1)
diff2 = diff.temporalsoften(1,255,255,32,2)
diff3 = mt_lutxy(diff,diff2,"x 128 - abs y 128 - abs > x "+KP+" * y 100 "+KP+" - * + 100 / x ?", U=1,V=1)
return( mt_lutxy(orig,diff3,"x y 128 - -",U=2,V=2) )
}

Didée
15th December 2005, 00:00
That's the old b0rked version, Socio :)

This is better: # Soothe - version for MaskTools v2

function Soothe(clip sharp, clip orig, int "keep")
{
keep = default(keep, 24)
keep = (keep>100) ? 100 : (keep<0) ? 0 : keep
KP = string(keep)
diff = mt_lutxy(orig,sharp,"x y - 128 +", U=1,V=1)
diff2 = diff.temporalsoften(1,255,0,32,2)
diff3 = mt_lutxy(diff,diff2, "x 128 - y 128 - * 0 < x 128 - 100 / " + KP
\ + " * 128 + x 128 - abs y 128 - abs > x " + KP
\ + " * y 100 " + KP + " - * + 100 / x ? ?", U=1,V=1)
return( mt_lutxy(orig,diff3,"x y 128 - -",U=2,V=2) )
}

foxyshadis
15th December 2005, 00:41
Didée, one of these days you're going to have to get some webspace to keep the definitive stable and beta versions of your awesome filters. ;)

Thanks for the quick fix, Manao, it works great now. =D

m.rup
15th December 2005, 08:59
Thanks Socio, thanks Didee.

Socio
15th December 2005, 13:36
Didée, one of these days you're going to have to get some webspace to keep the definitive stable and beta versions of your awesome filters. ;)




Dittio that!

Chainmax
15th December 2005, 14:30
What about using something like RapidUpload (http://www7.rapidupload.com/)? If not, maybe I can arrange some 10MBs for Didée.

By the way, I have a request for Didée: could all your filters be updated to use MaskTools 2.0? I only keep 1.5.8 because your filters need it.

Didée
15th December 2005, 15:19
Webspace is no problem. Finding time (and mood) to actually do it, that's the problem ...


By the way, I have a request for Didée: could all your filters be updated to use MaskTools 2.0? Sure, no problem! I'll do that after finishing the hosting page for my Avisynth functions ... :D

Pookie
15th December 2005, 15:41
Just an observation - Didée's Limited Sharpen thread has been viewed almost 60,000 times!

foxyshadis
15th December 2005, 17:05
Actually, I'm an idiot, that's what we have the avisynth wiki for.

http://www.avisynth.org/LimitedSharpen

[Edit]Okay, it got moved. I'm leaving right now, but I can update with the new beta, masktools2, and clouded's faster one later....

mg262
16th December 2005, 18:38
I added one more function, for something I have seen you use once or twice ;) :

LimitedSupport, 3 December 05 (http://people.pwf.cam.ac.uk/mg262/posts/LimitedSupport_03Dec05.dll)

Delta(a, b) = mt_lutxy(a, b, "x y - 128 +") = mt_lutxy(a, b, "x y 128 - -")
Health warning: Didée, looking at some of the functions you have posted more recently, I saw that you have at times used u=2, v=2 or u=3, v=3 ... I will add support for such things at a later date, but the current functions behave exactly like the listed luts (i.e. default u=1, v=1 a.k.a. trash chroma).

In any case, while I think these are safe, it is probably sensible to stick to tried and tested tools like mt_lutxy (as I think you are doing); there are plenty of people capable of following in your wake and speeding things up -- and even more of us capable of testing such things. [I.e. Didée is a finite resource :D.]

I am never completely certain about the Wiki... it doesn't have the community-friendly main page/discussion split of e.g. Wikipedia, and I think that maybe means people are reluctant to make changes. (Or at least, I am! Plus it just doesn't look as nice as Wikipedia... silly, but I think it may make a difference :).) But, to get back on topic, if you wanted it, Didée, it seems like a sensible step would be for us to gather links to all your scripts, either in a forum thread or on the Wiki?

Wilbert
16th December 2005, 22:52
I should ask Wilbert how to move the page to LimitedSharpen, I'm still not sure exactly how this wiki does it. I'm leaving right now, but I can update with the new beta, masktools2, and clouded's faster one later....
I don't know the proper way. I just copied the script to a new page (empty ones will dissappear after 30 days) :) But please do update it!

I am never completely certain about the Wiki... it doesn't have the community-friendly main page/discussion split of e.g. Wikipedia
Richard said that once we will move to a Wikipedia. Perhaps a nice wish for next year :)

Isochroma
18th December 2005, 04:10
Didée, thank you so much for your work! You are certainly a genius of the higher orders... your tool is helping me make my videos so much superior!

I cannot believe such a level of sharpening can be achieved without significant ring or halo... this has got to be a really spectacular achievement!

I mean, what can I possibly say? I've got the damn thing cranked to the max and I still can't make it ring or halo. It is slow as hell which is perfect, you could sell this script to some big software company...

Oh yes, this stuff is more than sweet, it is truly evil! My day is now made, my rear-end is saved, etc.

Your tool is so good that I'm considering paying you, if I get paid well for my computer work. Do you have a PayPal account?

aberforthsgoat
18th December 2005, 08:58
I also released a modified version of the script (http://people.pwf.cam.ac.uk/mg262/posts/LimitedSharpenFaster.avsi) that worked with this version; NB the function is called LimitedSharpenFaster, mainly so that if there are problems you know to poke me not Didée. You also need the 1.0 pre-release of RemoveGrain.

Say - could someone give me some info about how to use this version of the script? I've loaded it into the plugins directory and I'm accessing it now instead of the standard LimitedSharpen. I've also got one of the new versions of mask tools downloaded and copied into the same directory - but somehow, I have the feeling that I'm not doing it right. Something tells me I ought to have renamed stuff and done somethingto make sure I'm actually accessing mg262's script.

Any tips?

Peace,

Mike

Socio
18th December 2005, 16:51
You also need mg262's LimitedSupport_03Dec05.dll (http://people.pwf.cam.ac.uk/mg262/posts/LimitedSupport_03Dec05.dll) in your plug-ins folder.

You do not have to rename anything just use Limitedsharpen calls like normal.

mg262
18th December 2005, 23:22
As Socio says, doesn't need anything clever doing, just the files in the plug-ins directory. Do remember to call LimitedSharpenFaster, though (I renamed the script to reduce version confusion). If you call this and it appears to work, then it really is working... it should run a fair bit faster than LimitedSharpen.

Sorry about all the confusion :o ... things slowly metamorphosed from my original intention of providing filterlets for Didée (promised 4 months ago when there was just one version* ;)) to creating a full-fledged version. With the benefit of hindsight, I would have started a separate thread. In any case, I've built all the things that IMO stand a chance of being reusable, and I'm not planning to confuse matters further...

I have a bad habit of taking on far too much stuff and having a huge backlog. Deep apologies to everyone who has ever been affected by this, including several readers of this thread...

aberforthsgoat
18th December 2005, 23:57
Hey mg - don't you dare start apologizing! I stand in awe of what you guys are doing in your spare time. If I'm not paying for there's no way I'm going to complain! Also, I realized that some problems I'm having are actually being caused by an overheated CPU - it seems that I need to turn my fans a little over the silent level to run all this stuff for the duration of a DVD - the thing was hitting 75C and going into automatic slowdown - but the CPU *usage* is actually in the %60s. And the picture is fabulous.

Thanks for the great work!

Mike

zambelli
20th December 2005, 09:12
I'm having trouble keeping up with this extra long thread, so let me interject for a second and ask the following questions:

1. Where can one find the latest and greatest version of LimitedSharpen? The Avisynth Wiki page or the first page of this thread?

2. Could the page that lists the latest script also list the latest plugin requirements too?

I know, I know, I could read the entire thread, but I'd like to be able to download (or copy+paste) the latest updates from a single location when I come out of hibernation every few months. :)

Audionut
20th December 2005, 11:07
No need to read the whole thread.

The last 6 or so pages will be fine.
I always belive that it's best to read the last few pages atleast, anyway for the information value.

foxyshadis
20th December 2005, 11:33
My apologies for flaking earlier, but I updated the wiki (http://www.avisynth.org/LimitedSharpen). (The first page actually has the same old version as the wiki.) The beta is the newer one, with the other two being sped-up variations. (Latest masktools fixes a bug with Smode=3 in them.) If they change significantly in the future I'll update them again.

I also took the liberty of reformatting them slightly, to wrap a couple of extra long lines. :p

FredThompson
20th December 2005, 13:04
Can you link the helper DLL to that wiki entry?

zambelli
21st December 2005, 01:53
Can you make sure that the Wiki page lists all the plugin requirements for each version? I know all 3 scripts use some form of MaskTools, but that's not really made apparent except for the MT2 version which specifically uses MaskTools v2.
Consider whether someone looking at that page for the first time would know what to download and install.

foxyshadis
21st December 2005, 02:08
Actually, I don't believe there are any special requirements other than masktools, removegrain (which is linked), and warpsharp for the rarely used Smode=1; plus masktools2/limitedsupport (which are already linked in their respective versions). I'll add a link to original masktools and warpsharp.

I was next going to add in Didée's readme, maybe just a link to the first post of this thread would be better (except it doesn't explain smode=4 and lmode=3...).

Mug Funky
21st December 2005, 04:59
could i possibly request a feature?

this would require some hacking the script, but might be useful in some cases (i can think of 2):

allow horizontal-only, or vertical-only modes.

horizontal-only could be useful for ex-analog sources that are vertically sharp but horizontally soft (i get a lot of these).

vertical only could be useful for NTSC-PAL conversions to restore the vertical sharpness lost in the resizing (i get a lot of these too - the bulk of my workload).

it could also be useful for anamorphic sources which have different characteristics in both directions (though i suppose the internal resizing can handle that).

btw, i'm checking out all the new developments in this package, and i'm liking it a lot :)

right now i'm having a go at hacking the script myself - i'll post it if i make something useful without breaking what's there already.

Didée
21st December 2005, 17:48
Quickly, before going home ...

Give a try on this version (http://home.arcor.de/dhanselmann/_stuff/LimitedSharpen_(modded-21Dez2005)-2.rar) of LimitedSharpen, Mug Funky. Think I didn't break anything, but perhaps I forgot something ;) [edit: fixed a variable's name]

New:

"strengthV" parameter, used only when Smode=2. Enables asymetric sharpening, internally it's just "sharpen( strength/100, strengthV/100 ).

Smode=0: "custom" unsharp masking (bicubic resizing approximation). Radii can be given through "radius" (--> x-radius) and "radiusV" (--> y-radius).

It's really a hack, in that the script looks sooo ugly now ;) but it should work. After cleaning, this probably is very close to a "final" of LimitedSharpen. Only possible extention is scaling for the edgemask, and (surely) building the edgemask through Prewitt/LimitedSupport.
Other improvements will go ... into another function. :)

Some suggestions how to make this x/y stuff more consistent, regarding the parameters?

scharfis_brain
21st December 2005, 18:07
Mug Funky: your PM-Box is full.

Chainmax
22nd December 2005, 03:08
Since you say that SMode=4+LMode=3 can enhance a bit too much, I think that Soothe should be a builtin function

Mug Funky
22nd December 2005, 03:15
@ scharfi: fixed :)

@ Didée: i'll give that a try soon (i did a similar hack last night, but only the blur in smode=2 thing). would the asymmetric expand/inpands in masktools 2 help with this?

Socio
22nd December 2005, 18:50
I found a glitch in the new LS script on this line:

\ : Smode==2 ? sharpen(float(strengthH)/100.0,float(strengthV)/100.0)

I changed strengthH to just strength and it seems to work just great.

Didee to you recommend keeping the "strengthV" setting the same as the "strength" setting i.e

LimitedSharpen(ss_x=1.2,ss_y=1.2,Smode=2,strength=40,strengthV=40)

Didée
23rd December 2005, 14:01
Ah, indeed. Thanks for spotting it, Socio. The previous link now points to a corrected version.

Unless specified otherwise, "strengthV" defaults to the setting for "strength", i.e. normal symmetrical sharpening. The scenarios for asymmetrical sharpening are those mentioned by Mug Funky: mostly for analog sources, perhaps for anamorphic sources, or perhaps when blowing non-anamorphic up to anamorphic. For VHS sources, Smode=0 with radius=1.5~3.0 and radiusV=~1.0 could be a good way ... except for if horizontal oversharpening is already present, but that's another story.


Then, in reverse chronological order:


@ Mug Funky:
You meant Smode=3, didn't you? Yes, this one could be made working asymmetric, too. But that indeed requires MaskTools 2.0 ... it could be done with 1.5.x also, but would be rather slow. Plus, for that Smode it would (will) most likely be horizontal-only and vertical-only sharpening. Producing a weightened version for that one is not trivial, and probably not worth the effort.


@ Chainmax:
Soothe will not be implanted into LimitedSharpen. Applying Soothe is easy enough, isn't it.
Something with integrated Soothing is in the works ... but it's not LimitedSharpen. ;)


@ foxyshadis:
Thanks for the service. :)
Seems like I'll have to revise the documentation anyways, so let's wait for that.


@ Clouded:
To whom do you apologize - to me?? Wrong address, as I live in the glass house - making announcements, then let people wait 'til they're blue in the face ...
However, if some of the "support" filters could work on chroma too, it would help indeed. (Top ranking: the "difference" filters.)


@ Isochroma:
Fine if you like LimitedSharpen, but no way to accord me money for it.


***

Happy Xmas everyone - have a good time.

***

JarrettH
1st January 2006, 21:30
Noob entering =p

I'm having some trouble with it. I know I set it up correctly, and results may vary based on signal quality, etc. When I view using GAM the image looks very pastel like, almost cartoonish at medium distance. Up close everything is COMPLETELY smoothed, at medium distance it's cartoonish looking like I said and very aliased as if I were viewing some low quality movie in full screen.

I'll post shots later, werk time =p

JarrettH
2nd January 2006, 06:29
is resizing really necessary when i'm following the tv limited sharpen guide?

Didée
2nd January 2006, 13:09
JarretH:
Please post the parameters you're calling LimitedSharpen with. Also before/after screenshots could help.

Posterization and aliasing is likely to happen with ultra-high values for "strength", or generally when "strength" is set too high for the chosen supersampling factor. If you're using no supersampling (ss_x=1.0 & ss_y=1.0), then aliasing will show up with much lower strength settings already. When no supersampling is used, Smode=4 might be better suited than the others, because of its non-linear response.
The "soft" parameter will help on all Smodes to prevent or reduce the introduction of aliasing and posterization.

JarrettH
2nd January 2006, 19:11
Hey Didee

Are you referring to this?

Import("C:\Program Files\AviSynth 2.5\plugins\Soothe.avs")
Import("C:\Program Files\AviSynth 2.5\plugins\LimitedSharpen.avs")

SetMTMode(2)
mergeluma( removegrain(4,-1), 0.75 )
dull = last
sharp = dull.LimitedSharpen(ss_x=1.0,ss_y=1.0,Smode=4,strength=100,soft=33)
mergeluma( removegrain(2,-1), 0.25 )

Soothe( sharp, dull, 20 )

I hope it's correct...I was just trying to follow some of the advanced options :D

Is there a way I can check if it's hyperthreading? I didn't see two processes using half/half cpu. I'm still tweaking what I like. Been doing some tests on foodtv ;)

I could never figure out how to take captures with GAM.

foxyshadis
2nd January 2006, 19:30
Using a tool like process explorer (from sysinternals) you can check the cpu usage of each thread; there should be two threads that each take ~50%.

Didée
2nd January 2006, 19:31
Could be caused by RemoveGrain. Especially the first one (merge 75% of RG mode4) for my taste is too strong. Comment out both the lines with MergeLuma(RemoveGrain(..)..), and see if it looks better then.

Note: I had suggested those MergeLuma(Removegrain...) thingies to Socio for realtime processing because this works very fast. For "real" processing, I'd rather recommend SPresso (http://forum.doom9.org/showthread.php?p=743559#post743559). Takes somewhat more processing power, but it's more efficient, doing less harm.

JarrettH
2nd January 2006, 20:57
Import("C:\Program Files\AviSynth 2.5\plugins\LimitedSharpen2.avs")

SetMTMode(2)
LimitedSharpen(ss_x=1.0,ss_y=1.0,Smode=3,strength=50,overshoot=7)

I copied that from the tv guide. Is LimitedSharpen2.avs a typo? It should just be LimitedSharpen.avs right? I still don't see two processes anyway.

JarrettH
2nd January 2006, 21:13
I think changing to smode=4 and setting the res to 640x480 solved it. For some reason the res setting was only available using a certain skin theme in GAM.

Socio
2nd January 2006, 23:09
I copied that from the tv guide. Is LimitedSharpen2.avs a typo? It should just be LimitedSharpen.avs right? I still don't see two processes anyway.

Yes Limitedsharpen2 is a typo, should be just LimitedSharpen.avs

JarrettH
3rd January 2006, 06:00
I think I settled on this

Import("C:\Program Files\AviSynth 2.5\plugins\Soothe.avs")
Import("C:\Program Files\AviSynth 2.5\plugins\LimitedSharpen.avs")

SetMTMode(2)
mergeluma( removegrain(4,-1), 0.70 )
dull = last
sharp = dull.LimitedSharpen(ss_x=1.0,ss_y=1.0,Smode=4,strength=100,soft=33)
mergeluma( removegrain(2,-1), 0.25 )

Soothe( sharp, dull, 20 )

I have to play with pictures properties now. Are there any other methods I might use to increase television quality? I noticed the audio clipped every now and then and the picture isn't quite as fluid. It doesn't look like hyperthreading is functioning when I open the processes.

Neil Lee
5th January 2006, 00:46
Thank you Didée for the great idea of LimitedSharpen !
Since It might become a common tool like sharpen, resize etc..
(and it should) People are gonna use it very often. So instead of
scripting, what about writing a plugin just for speed's shake? :)

Backwoods
5th January 2006, 01:41
So instead of scripting, what about writing a plugin just because I think there would be a speed increase but we all know it doesn't :)

Fixed.

Neil Lee
5th January 2006, 02:59
Fixed.
You can try to be a smartASS, but don't forge other's quote
If you think my point is wrong, just say it with you own words.

It's one thing to be sarcastic, another to forge someone's post.

.

foxyshadis
5th January 2006, 03:09
Clouded already did profiling a few pages back and used it to filterize the slowest and hardest hit luts; his half-and-half variation probably includes 80-90% of the speedup of moving to fully optimized C/asm. A good coder must pick one's battles.

However, I just noticed clouded forgot to modify his script to use MakeDiff/SubtractDiff, so you might give the edited version (http://www.avisynth.org/LimitedSharpen#LimitedSharpenFaster) a whirl. (I'll add the latest mods whenever people think they're stable.) The affected lines are:

sharpdiff=MakeDiff(tmp,last)
sharpdiff2=mt_lutxy(sharpdiff,sharpdiff.removegrain(19,-1),
\ "x 128 - abs y 128 - abs > y "+AMNT+" * x "+AMNT2+" * + 100 / x ?")

soft==0 ? last : SubtractDiff(tmp,sharpdiff2)

Backwoods
5th January 2006, 06:39
You can try to be a smartASS, but don't forge other's quote
If you think my point is wrong, just say it with you own words.

It's one thing to be sarcastic, another to forge someone's post.

.

Hey buddy it was a joke. It was brought up before and in other threads where scripts are used. We're all video buddies here, no reason to fly off the handle.

JarrettH
5th January 2006, 07:08
completely random, but I finally figured out how to frameserve with avisynth to vdub...hooray no more vfapi :D :p

Socio
6th January 2006, 02:06
Clouded already did profiling a few pages back and used it to filterize the slowest and hardest hit luts; his half-and-half variation probably includes 80-90% of the speedup of moving to fully optimized C/asm. A good coder must pick one's battles.

However, I just noticed clouded forgot to modify his script to use MakeDiff/SubtractDiff, so you might give the edited version (http://www.avisynth.org/LimitedSharpen#LimitedSharpenFaster) a whirl. (I'll add the latest mods whenever people think they're stable.) The affected lines are:

sharpdiff=MakeDiff(tmp,last)
sharpdiff2=mt_lutxy(sharpdiff,sharpdiff.removegrain(19,-1),
\ "x 128 - abs y 128 - abs > y "+AMNT+" * x "+AMNT2+" * + 100 / x ?")

soft==0 ? last : SubtractDiff(tmp,sharpdiff2)


I tried the version at your link and I get an error " There is no function named MakeDiff " ?

psme
6th January 2006, 04:34
The MakeDiff version needs the latest support dll here:

http://people.pwf.cam.ac.uk/mg262/posts/LimitedSupport_03Dec05B.dll

regards,

Li On

Socio
6th January 2006, 16:09
The MakeDiff version needs the latest support dll here:

http://people.pwf.cam.ac.uk/mg262/posts/LimitedSupport_03Dec05B.dll

regards,

Li On


Thanks that worked, I had the version just prior to that one did not know about that newer one.

JarrettH
8th January 2006, 07:57
If we ever want a settings thread here's mine now =p

Import("C:\Program Files\AviSynth 2.5\plugins\Soothe.avs")
Import("C:\Program Files\AviSynth 2.5\plugins\LimitedSharpen.avs")

SetMTMode(2)
mergeluma( removegrain(4,-1), 0.70 )
dull = last
sharp = dull.LimitedSharpen(ss_x=1.0,ss_y=1.0,Smode=4,strength=100,soft=33)
mergeluma( removegrain(2,-1), 0.25 )

Soothe( sharp, dull, 20 )

The contrast is bumped up 10 and saturation by 5 too. I'll see if I can post some pics comparing ATI TV to GAM+LimitedSharpen.

*Edit...how DO you take screenshots in ATI TV and Got All Media. Why must everything be so difficult!

mg262
8th January 2006, 10:20
BUG fixed: the right-hand side of AddDiff wasn't working correctly. Thank you for spotting it, foxyshadis! (I really hope this wasn't causing you headaches yet, Didée.)

LimitedSupport, 8 January 2006 (http://people.pwf.cam.ac.uk/mg262/posts/LimitedSupport_08Jan06.dll)

The source (http://people.pwf.cam.ac.uk/mg262/posts/LimitedSupport_08Jan06.zip) is also uploaded if anyone feels like checking it.

However, if some of the "support" filters could work on chroma too, it would help indeed. (Top ranking: the "difference" filters.)Doing this should be fairly straightforward. So... why haven't I done it yet :sly: ? Because I'm nervous about breaking things. I do test things for quite a while... but in this case, where these things are going to be put to an important use (and where they are replacing something that clearly works), I'd feel better if a couple of you would test them before Didée uses them.

It isn't technically difficult -- you get two one-line commands, like

yv12lutxy(o,d, "x y 128 - +")

adddiff(o,d)

and you need to check that they have the same output whatever the input clips o and d are. [For example, like this...
a=yv12lutxy(o,d, "x y 128 - +").GreyScale()
b=adddiff(o,d).GreyScale()
suBTRACT(a,b)
]
It isn't technically difficult... the important thing is to try on a wide range of clips. So this is a great opportunity for the average reader to prove helpful :D.

foxyshadis
8th January 2006, 11:34
If it's not too much trouble, then could you create a version with xDiff(o,d,[1/2/3/4]) where the last parameter are similar to the y/u/v parameters to masktools, but always for chroma? (1=>trash, 2=>copy first, 3=>execute, 4=>copy second) Then at least we have something to test out, even if it isn't perfect at first.

mg262
9th January 2006, 00:52
LimitedSupport, 9 January 2006 (http://people.pwf.cam.ac.uk/mg262/posts/LimitedSupport_09Jan06.dll)

All filters have been modified to take an extra argument chroma. chroma can either be be a clip (in which case the chroma of that clip is copied) or one of the following strings:
"ignore"
"process"
"copy first"
"copy second"
"copy third"

The default mode is "ignore". "Copy first", etc. are just for convenience; obviously, you can just repeat the relevant argument. (These strings are case insensitive, so you can also use e.g. "PROCESS".)

I'll edit in a proper summary of the functions tomorrow, but just as a recap:

SimpleAverage(clip, clip, chroma)
MakeDiff(clip, clip, chroma)
AddDiff(clip, clip, chroma)
SubtractDiff(clip, clip, chroma)
Clamp(clip, clip bright_limit, clip dark_limit, int overshoot, int undershoot, chroma)
Prewitt(clip, float multiplier, chroma)

If you pass in clips whose length differs, the output is not guaranteed to be sensible beyond the length of the shortest clip.

*This really hasn't been tested much yet*...

If it's not too much trouble, then could you create a version with xDiff(o,d,[1/2/3/4]) where the last parameter are similar to the y/u/v parameters to masktools, but always for chroma? (1=>trash, 2=>copy first, 3=>execute, 4=>copy second) Then at least we have something to test out, even if it isn't perfect at first.Foxyshadis, I wasn't sure whether you were asking for a quick rough version with the functionality (which you've now got) or for this particular syntax. I'm not a fan of mode = 1, 2, 3, 4, 5, 6, 7,... arguments. But if you reaaalllly want it (or Didée does), I can add it.

Edit: I noticed in other threads (which I'm not going to dig out now) that people are citing issues with LimitedSharpenFaster. If you do run into something like this, please try the earlier versions -- both Didée's versions and Socio's modification for MaskTools 2.0; this will pin down which change is responsible for the issue, *and then we can fix it*:).

Didée
9th January 2006, 02:22
Ah, splendid. :)

It doesn't really matter too much if one hast to type >>,U=3,V=3<< or >>"process"<< instead. Different syntaxes keep the brain from getting rusty. ;)

Just one question, I seem to have a dumb moment:
The default mode is "ignore". "Copy first", etc. are just for convenience; obviously, you can just repeat the relevant argument. Huh? What argument we could just repeat instead of typing e.g. "copy second"?

foxyshadis
9th January 2006, 02:28
No, no, it was only out of deference to compatibility, I like schemes like yours better. I had written my own but left it off as unimportant. Thank you so much, you're the speedy gonzales of avisynth filters. ;)

I tested the first 4 pretty thoroughly with a goofy width and caught no errors. Excellent! I wasn't sure about clamp until I realized it swapped the input clips on each. Copy second gives different results but is meaningless anyway, the rest work fine.

I simply have no idea what to compare prewitt with, although I'm guessing the results of an average of 8-part dedgemask? I'll let you handle that one. :p I'm just curious about how it fits into LimitedSharpen, if it does at all. Is it a replacement for

edge = mt_logic( tmp.mt_edge(thY1=0,thY2=255,"8 16 8 0 0 0 -8 -16 -8 4")
\ ,tmp.mt_edge(thY1=0,thY2=255,"8 0 -8 16 0 -16 8 0 -8 4")
\ ,"max") .mt_lut("x 128 / 0.86 ^ 255 *") #.levels(0,0.86,128,0,255,false)

?

mg262
9th January 2006, 02:30
Didée,

"copy first" behaves like this:
AddDiff(a, b, chroma = a)

"Copy second" behaves like this:
AddDiff(a, b, chroma = b)

Or you can take chroma from a completely different clip, like this
AddDiff(a, b, chroma = other_clip)

The "copy first" and "copy second" have a slight advantage when you are doing some processing inside the function call...
AddDiff(a.Invert(), b, chroma = a.Invert())

will call Invert twice. But
AddDiff(a.Invert(), b, chroma = "copy first")

will only call it once.

Edit + re-edit:
foxyshadis,

I'm extremely grateful for the testing! But I can't reproduce the clamp problem... this is the script I tried:
function scriptclamp(clip main, clip bright_limit, clip dark_limit, int overshoot, int undershoot)
{
OS = string(overshoot)
US = string(undershoot)
oss="y x "+OS+" + < y x "+OS+" + ?"
uss="y x "+US+" - > y x "+US+" - ?"
yv12lutxy( bright_limit, main, yexpr=oss, uexpr=oss, vexpr=oss, u=3, v=3)
yv12lutxy( dark_limit, last, yexpr=uss, uexpr=uss, vexpr=uss, u=3, v=3)
return last
}

a=scriptclamp(o,p,q,1,2).MergeChroma(p)
b= clamp(o,p,q,1,2,chroma="copy second")
subtract(a,b)

Levels(128-15, 1, 128+15, 16, 235)
I forgot to mention that "copy third" also exists, though obviously it only makes sense for Clamp. Maybe I just documented it wrong (with second and third argument swapped)?

Prewitt:
Some time back I found a set of Photoshop scripts that contain huge numbers of edge masks:
http://members.ozemail.com.au/~binaryfx/PSTV_convolcorner.html
(scroll down to Custom_Convolution_Actions_APS5.zip - 298KB)

There were a lot of scripts in there, but they were very quick to try (being one click each)... Prewitt stood out as being much better than the others. Method described here (http://videoprocessing.11.forumer.com/viewtopic.php?p=290&highlight=prewitt#290). Unlike all the other functions in this filter, it's only in C++ (though it could certainly be converted to assembly).

What else?
Source code (http://people.pwf.cam.ac.uk/mg262/posts/LimitedSupport_09Jan06.zip)

I haven't by any means squeezed out all the speed that is possible; the filterlets were chosen to be reusable and quick to assemblify as much as for the potential speedup. (Also replacing two-argument LUTs is something that I'm keen on doing because two-argument LUTs aren't friendly to 15-bit processing.) The next natural speedup would probably be to write a faster upsampling-resizer than the built-in AVISynth one... I'm pretty sure I know how to do it but it's a lot of work. When the LS successor appears and is declared to be in a stable version, then I might look at speedups again... .

foxyshadis
9th January 2006, 03:21
Ah, see, mergechroma(p) is a better idea! I was just using u=2,v=2... on the two mt_lutxys. Obviously that's going to copy chroma of clip #3 instead! (u/v=4 vs "copy first" works perfectly.) Clamp doesn't accept "copy third" however.

I'll give prewitt a try, I'm developing something with sobel but I'd definitely like more fine details. (Another I'm developing just needs rough edges since it'll be blurred anyway.)

If you work on resizing down the line, would it be better just to start with the current avisynth code and optimize that to include in the next version? Or would it be more sensible to just make your own FastResize filter?

mg262
9th January 2006, 03:58
Clamp doesn't accept "copy third" however.
Fixed!

LimitedSupport, 9 January 2006 (revised) (http://people.pwf.cam.ac.uk/mg262/posts/LimitedSupport_09Jan06B.dll)

I'll give prewitt a try, I'm developing something with sobel but I'd definitely like more fine details.I also have a 'thin' version sitting around somewhere (that tries to give you 1 pixel thick edges)... I can dig it out (filter and source if you want it) if it would be of any use.

If you work on resizing down the line, would it be better just to start with the current avisynth code and optimize that to include in the next version? Or would it be more sensible to just make your own FastResize filter?IMO the latter... or at least, I can't speak for anyone else, but I need to understand code completely inside out to work on it, not just what every line does but e.g. why something is a virtual function rather than a template specialisation or vice versa. Reaching that level with someone else's code would take me a lot longer than coding from scratch. (Plus at the moment I have interface issues which make it very hard to work on code unless it is written in a particular way.)

morsa
9th January 2006, 15:07
Sorry guys to tell you but I guess a new thread should be started beginning with the last version of everything.I read the whole thread and it is quite difficult to follow the modifications of scripts and DLLs...
In fact I read it like four times to get things working...(like more than 2 hours)

Backwoods
9th January 2006, 19:06
LoadPlugIn("LimitedSupport_09Jan06B.dll")
LoadPlugIn("MaskTools.dll")
LoadPlugIn("mt_masktooks.dll")
LoadPlugIn("RemoveGrain.dll")
Import("LimitedSharpenFaster.avsi")

AVISource("xxx.avi")
LimitedSharpenFaster()

videoFred
10th January 2006, 10:00
Sorry guys to tell you but I guess a new thread should be started beginning with the last version of everything.I read the whole thread and it is quite difficult to follow the modifications of scripts and DLLs...
In fact I read it like four times to get things working...(like more than 2 hours)

http://www.avisynth.org/LimitedSharpen


Fred.:)

morsa
10th January 2006, 20:01
ok thanks.

mg262
14th January 2006, 09:31
What am I going to speed up now :D?

Didée,

May I ask whether these things which you occasionally use:

temporalsoften(1,255,0,32,2)

are meant to exploit the scene change detection in temporalsoften or circumvent it?

FredThompson
14th January 2006, 09:42
What am I going to speed up now :D?
Rewrite DeHalo_alpha to use ffdshow filters instead of AVS native higher math...

buzzqw
14th January 2006, 12:02
:o please build a limitedsharpen.dll that include all mask*.dll/warpsh*.dll limitedspeed*.dll or whatever is needed to load limited sharpen without checking what is to load and what is to not load (because too new/too old) :o

BHH

MetalPhreak
14th January 2006, 12:41
I second buzzqw's request, or at least explain properly on the avisynth.org what is needed and links - currently if I download everything from there I get errors and warnings popping up left and right.

foxyshadis
14th January 2006, 13:46
Well, packaging everything in one archive would make it out of date as soon as an update to masktools was released. I guess I can list everything required for a particular function with its function though. And change the masktools2 link so you don't accidentally download an old one. See if you like it more now.

There should be no errors or warnings if you have the most recent versions of the dlls, as long as you just load them all from the script, unless there's some kind of versioning conflict with older ones.

Didée
14th January 2006, 17:29
May I ask whether these things which you occasionally use:

temporalsoften(1,255,0,32,2)

are meant to exploit the scene change detection in temporalsoften or circumvent it?
That's from LPprotect(), isn't it? It's meant to perform full temporal smoothing on Y, disregarding UV because that's not needed (and TS runs slightly faster not processing UV, which does pay out in the complex context of MCNR_simple), with a rather insensitive but still active SC detection.
Thinking about it, it could be the SC detection in fact isn't needed, and I could use average() ... but then, while average() (24Oct05) generally works nicely, sometimes it b0rks out with returning full green. Didn't find the cause up to know, and no reliable way to reproduce the bug.


>> (mg262) What am I going to speed up now ?

Rewrite DeHalo_alpha to use ffdshow filters instead of AVS native higher math... What are your actual speeds, Fred? With maximum optimization (replacing all MT 1.5.x with MT 2.0 commands, and using ss=1.0), this weak Celeron 2600 here renders a 720x432 clip at 35~40 fps. With ss=1.25, it's ~17 fps, and ~15fps with ss=1.5 ... supersampling in Avisynth is expensive, but necessary (without any ss, the method will produce aliasing on sharp & strong-contrasted edges). Personally I would never run DeHalo_alpha without it.)

mg262
14th January 2006, 17:51
Guys...

It looks like some improvement on this front may be in the works. But please bear in mind the following:

1) You're referring to four different plug-ins by four different authors. Compiling other people's code can be a lot of work... consider that (AFAIK) all the code is available and that you can amalgamate it yourself if you want it -- and then release the result as a public service.

2) Similarly the wiki is freely editable... foxyshadis doesn't need to be left to do all the work.

3) What would happen if you loaded the amalgamated plug-in together with (older or newer) versions of the relevant tools? Bugs might be unfixed by the clash... this could cause problems that were very hard to track down.

4) As foxyshadis notes, the thankless maintainer of the amalgamated plug-in you suggest would need to recompile it every time any of the included plug-ins changed.

5) The version of LimitedSharpen that all of this is based on is an experimental version. I wrote LimitedSupport because I promised Didée I would many months ago. I never really intended it to be used by anyone but him... the idea was that he would simply have more functions to play with. If and when he thinks that it is stable and appropriate for use, I expect that he will post scripts that use it. On the front page, with all the appropriate documentation. What I wrote about the functions was (and still largely is) targeted at Didée; I'm very happy for people other to use it, and I'll help with specific issues, but I was never trying to turn one of Didée's experiments into front-page form.

Edit:
Fred,

I'm not great at adapting other people's code :(. Most of that function seems to be resizes... I do definitely want to write a faster resizer one day, but it's a lot of work. It would fit quite neatly into a framework I have in mind that would speed up many of Didée's filters substantially... but I am waiting to see what the next generation of filters look like before I start on something that might be obsoleted!

Didée,

Average: Definitely not good -- I will try to hunt it down when my brain is next up to speed; thanks for telling me about it. But for this case I was thinking of writing a much simpler dedicated radius-1 temporal blur, which would be faster anyway. (Actually, this is right down kassandro's street -- I'm surprised he hasn't done this already at a gazillion FPS.) I thought I'd seen that usage in a couple of your functions, but maybe I was just looking at the same ones again and again :D.

videoFred
18th January 2006, 12:57
I did many tests with sharpeners....
Limitedsharpen is the best!!

Here are some Super-8 filmframes:
I used limitedSharpenFaster(smode:1, radius=2-3, strenght=100-300)

I had no problem to download everything to make it work.
Yep, it's faster!

Please remember real film sharpness is different from digital..
It's softer.. and it should be... It's the film look.

The frames are taken from the Mpeg2.. then converted to Jpeg.
So you can imagine how the original 1024x768 Huffyuv looks?

1972, Kodak film, Canon Super-8 camera (model unknown)

http://users.telenet.be/ho-slotcars/Frames/1976_Kodak_002.jpg

http://users.telenet.be/ho-slotcars/Frames/1972_kodak_002.jpg


Fred.

Isochroma
22nd January 2006, 02:58
There seems to be a problem with LimitedSharpenFaster() in the distribution of MaskTools 2.0 a20. I'm getting frameblends with this avs script:

ImageSource(file = "S:\VideoDone\Escaflowne\EF.%06d.png", start = 0, end = 140636, fps = 23.976)
ConvertToYUY2()
LimitedSharpenFaster(ss_x=2.0, ss_y=2.0, Smode=3, strength=800)

This script doesn't produce any frameblending:

ImageSource(file = "S:\VideoDone\Escaflowne\EF.%06d.png", start = 0, end = 140636, fps = 23.976)
ConvertToYUY2()
LimitedSharpen(ss_x=2.0, ss_y=2.0, Smode=3, strength=800)

In my own work, the original LS continues to prove its worth on a daily basis. So many thanks to the devs! I'd request that the MT2 version of the LS script be put back on avisynth.org until the bugs are worked out of the faster version.

Here are 3 frames (15782, 15783, 15784) made with the last non-integrated MT2 version of LS (second script in this post):

[Pics removed due to bandwidth overconsumption and issue already resolved]

and here are the three frames (15782, 15783, 15784) made with the MaskTools a20 version of LS-faster (first script):

[Pics removed due to bandwidth overconsumption and issue already resolved]

Pookie
22nd January 2006, 08:33
Same here. No biggie. I'll back down on the version until it is working better.

Problem seems to be happening with masktools-v2.0a19 and masktools-v2.0a20, works fine in a18.

tedkunich
22nd January 2006, 09:26
There seems to be a problem with LimitedSharpenFaster() in the distribution of MaskTools 2.0 a20. I'm getting frameblends with this avs script:

ImageSource(file = "S:\VideoDone\Escaflowne\EF.%06d.png", start = 0, end = 140636, fps = 23.976)
ConvertToYUY2()
LimitedSharpenFaster(ss_x=2.0, ss_y=2.0, Smode=3, strength=800)

This script doesn't produce any frameblending:

ImageSource(file = "S:\VideoDone\Escaflowne\EF.%06d.png", start = 0, end = 140636, fps = 23.976)
ConvertToYUY2()
LimitedSharpen(ss_x=2.0, ss_y=2.0, Smode=3, strength=800)

In my own work, the original LS continues to prove its worth on a daily basis. So many thanks to the devs! I'd request that the MT2 version of the LS script be put back on avisynth.org until the bugs are worked out of the faster version.

Here are 3 frames (15782, 15783, 15784) made with the last non-integrated MT2 version of LS (second script in this post):


and here are the three frames (15782, 15783, 15784) made with the MaskTools a20 version of LS-faster (first script):


Just a suggestion, but if you have more than one image to post, please just post a link to the image or post a smaller file (ie JPEG) so that people that have slow connections do not have to wait for 10 mintues for this thread to load.


T

Revgen
22nd January 2006, 09:42
Just a suggestion, but if you have more than one image to post, please just post a link to the image or post a smaller file (ie JPEG) so that people that have slow connections do not have to wait for 10 mintues for this thread to load.


T


Yeah! Who wants to wait 10 minutes to see some anime chicks huggin' each other!:D

Manao
22nd January 2006, 10:10
Thanks IsoChroma, Pookie. I fixed the bug ( cf the dedicated masktools thread ). Yet, I strongly advise you to keep to the masktools 2.0a18 for the time being, as I have said on the other thread, I'm hunting done another nasty issue, that mostly seems random and that may or may not happen on your computer ( but you wouldn't like it to happen at the #51239 frame of your clip ).

Apart for a bug with very small resolution ( < 128 horizontally ), the 2.0a18 version has no bug that I know of, so it might be considered as stable ( at least, relatively to the v2.0 "stability" standard :p )

I updated my sig to point toward that version, instead of the latest.

Manao
22nd January 2006, 11:39
Ok, the bug wasn't in the masktools, but in the old avisynth.dll that was in my system directory. Once updated to latest avisynth, it works quite alright. So provided that nothing else is wrong in 2.0a21, it can be used.

Soulhunter
22nd January 2006, 15:08
Wow, took me quite some time to read-up all the stuff i missed in the 2 months i was offline!

Cant await to play around with the new versions... ^^


Thx n' Bye

tedkunich
22nd January 2006, 18:33
Yeah! Who wants to wait 10 minutes to see some anime chicks huggin' each other!:D


anime... meh... long lost interest in cartoons decades ago...

ChronoCross
22nd January 2006, 18:40
anime... meh... long lost interest in cartoons decades ago...

how dare you call anime cartoons!!!! But yeah I need to start updating alot of the scripts I use to use the 2.0 version. Then I can really get going hehe.

Isochroma
22nd January 2006, 20:05
Good to hear the bug is squashed... if I post more than 2 pics in the future they will be links only.

Kador
23rd January 2006, 18:57
Hi, I'm using the latest :
- masktools2
- MT + avisynth dll
- the second LSF from the wiki page
- hqdn3d
I get a crash every time after several seconds of read, of course no crash without those filters ...

any idea ?

mg262
23rd January 2006, 19:53
Reading this...
But yeah I need to start updating alot of the scripts I use to use the 2.0 version. Then I can really get going hehe.
and many other recent posts, I want to dig out a caveat that may have been missed by those not following this thread continuously (hope you don't mind the liberty, Didée):

The version from page 1 still is the official one, although the modifikation posted in post 208 (http://forum.doom9.org/showthread.php?p=731909#post731909) works 100% reliable, hence is even recommended. Everything works as expected, and the additions Smode=4 and Lmode=3 might enable stronger texture enhancement than what one was used to formerly (however appliance of Soothe() might be better when using these).

For now, I want to keep any "official" version fully backwards compatible regarding the setup. MaskTools v2.0 as a whole is not free of quirks yet, and - more importantly - it *necessarily* requires Avisynth v2.56, which not everyone might be using yet.

So, instead of updating LimitedSharpen with small features or speedups that bring more confusion than benefit to the users (and to me the need of doing much explaining), time is better invested in fiddling with new toys. LimitedSharpen was good and all (and still is, of course), but its possibilities of enhancement are, well, limited. By now, it's time to go beyond what LS can do. I counted carefully, and found all needed puzzle pieces are there. The puzzle is big, and putting it together is very difficult. But then, it's definetly more challenging than doing minor poilshments on old toys, and explaining the change of glance.
MaskTools is now much stabler and has an unofficial accelerated LS version bundled with it (Manao put in a lot of work to make your lives easier -- go and thank him!).

Note the requirement for the latest version of AVISynth 2.5.6, and that you will still need the right version of RemoveGrain from here (http://videoprocessing.11.forumer.com/viewtopic.php?t=9). (<--Excuse the big letters; edited to stand out to those skimming this thread.)

But otherwise that post sums up the state of things.

Oh yes... one other thing: how dare you call cartoons anime! :p

Mr.Bitey
25th January 2006, 00:42
Hi All,

Im getting graphedit errors in ZoomPlayer 4.51 with limitedsharpen and mask_tools v2.0a21 after a second or two of dvd playback - no problems if I roll back to v2.0a18..

Cheers,
Bitey

aberforthsgoat
25th January 2006, 01:18
Im getting graphedit errors in ZoomPlayer 4.51 with limitedsharpen and mask_tools v2.0a21 after a second or two of dvd playback - no problems if I roll back to v2.0a18..

Ditto here. And SageTV crashes without mercy. a18 works very nicely; everything else (up to a23) seems to be an automatic crash machine.

Mike

mg262
25th January 2006, 01:50
I would post these issues in the MaskTools thread...

Manao
25th January 2006, 06:44
Mr Bitey, aberforthsgoat : can you check your avisynth.dll version & release data please ? Because builds after 2.0a18 have issues with early 2.5.6, but not with the last one. I can't make it crash on my computer.

So can you try latest 2.5.6 RC, and - if it still doesn't work - can you give me the avs script you used.

Chainmax
25th January 2006, 18:02
So how about someone either updates page 1 or makes a new thread with the newest script and required DLLs + a readme?

mg262
25th January 2006, 20:38
Front-page version is official. This version isn't (Didée has said so several times).

foxyshadis has listed everything necessary for the experimental version on AVISynth.org and kept it up-to-date through all the changes:

http://www.avisynth.org/LimitedSharpen

Mr.Bitey
26th January 2006, 02:23
Manao,

Im using the avisynth that came with MT05 (tsp says you need to use that version for MT05 in the MT05 thread, or v 2.6 (when its released)).

So can you try latest 2.5.6 RC, and - if it still doesn't work - can you give me the avs script you used.
Is that AviSynth 2.5.6a (28th oct 2005) or AVS 2.5.6 RC2 (7th Oct 2005) ?

There seems to be a similar discussion going on in the MT05 thread with LSF crashing out with MT5 - seems there might be some incompatability with the avisynth.dll needed (or recommended) for MT05 and the avisynth.dll needed for the +18 versions of masktools..

Cheers,
Bitey

foxyshadis
26th January 2006, 04:16
All of these "issues" are why the front-page is still the official version. :p

I could try testing various version of avisynth.dll, but I normally run a pre-2.5.7 so I guess I won't see any of the problems. Maybe you can ask tsp for a modified 2.5.7 cvs and see if that solves the problem.

Kador
26th January 2006, 09:30
Manao,

Im using the avisynth that came with MT05 (tsp says you need to use that version for MT05 in the MT05 thread, or v 2.6 (when its released)).

Is that AviSynth 2.5.6a (28th oct 2005) or AVS 2.5.6 RC2 (7th Oct 2005) ?

There seems to be a similar discussion going on in the MT05 thread with LSF crashing out with MT5 - seems there might be some incompatability with the avisynth.dll needed (or recommended) for MT05 and the avisynth.dll needed for the +18 versions of masktools..

Cheers,
Bitey

Me, I am using avisynth 2.5.6a, MT05 + avisynth.dll that comes with MT, latest masktools 2a23, removegrain1.0betaSSE3, limitedsharpen (the one in masktools distro), latest fddshow (2006.01.25 but I tried with several versions) and it crashes everytime. did not crash "before" (I mean with masktools pre 2a18)

Emilot
26th January 2006, 10:55
With the same config here, but with RemoveGrainSSE2.dll. Same results, crash everytime....after 2a18!!

Mr.Bitey
27th January 2006, 00:18
All of these "issues" are why the front-page is still the official version. :p


Dont get me wrong, im happy with the a18 / MT5 LSF combo - works very well! and there is always the 'why fix whats not broken'... Im just at the limit of pushing my CPU (its stable juuust long enough to watch a movie :-) and am looking for any speed improovements..


but I normally run a pre-2.5.7 so I guess I won't see any of the problems.

?? Are you saying there are some other builds that might work?? :)

Cheers,
Bitey

jjseth
13th February 2006, 14:26
Hi, i use the last limitedsharpenfaster with masktool, etc. Maybe is a stupid question but can soft parameter replace the Soothe function for real encoding?

"soft" acts different now: no more boolean true/false, but instead integer 0 - 100 (or -1 -> automatic) instead of blurring before finding minima/maxima, it now softens the "effect-of-sharpening"

And another question....what's exactly the function of soft=-1?

Didée
14th February 2006, 10:33
The "soft" option of LimitedSharpen is not related to Soothe's processing. "Soft" in LS is a *spatial* operation, in order to smoothe out pixelation/aliasing/etc that might be caused by strong sharpening settings. Soothe does *temporal* processing to reduce temporal jitter caused by the sharpening process.

So it's two different pairs of shoes, not meant to replace each other, but rather to work together hand-in-hand.

BTW, soft=-1 in LS ~tries~ to find a suited value for "soft" automatically, depending on the used supersampling factors. However I would not trust too much in it, but rather set it manually: suited strengths for "soft" depend pretty much on the combination of values for Smode, strength, supersampling & overshoot ... and so far, no formula containing all these variables & spitting out a good value for "soft" appeared to me.

stealth82
15th February 2006, 18:36
Ehm... sorry for the dumb question, I'm a newbie.

I use Avisynth as a ffdshow filter. This is my script call:

LanczosResize(1280,720)
LimitedSharpenFaster(ss_x=1.0,ss_y=1.0,Smode=3,str ength=50,overshoot=7)

I noticed that the Lanczos called through Avisynth is better than ffdshow resize (I don't know why, but that's it). However, ffdshow has more options like the choice of multiple resizes respect the original media resolution, and the possibility to set the tap parameter for the Lanczos resize.

Is there a way to have these two things even through Avisynth? I read the syntax for the Avisynth Lanczos resize:
LanczosResize(clip clip int target_width, int target_height, int taps)
The parameter taps (int) allow me to set my preferred taps? For instance, is this setting a Lanczos2?

LanczosResize(1280,720,2)

What for double resize (source NTSC 720x480 = 1440x960, source PAL 720x576 = 1440x1152)?

Thanks, and sorry for my english...

Richard Berg
15th February 2006, 19:11
LanczosResize(last.width * 2, last.height * 2)

stealth82
16th February 2006, 00:32
LanczosResize(last.width * 2, last.height * 2)
Many thanks!

JarrettH
16th February 2006, 04:13
Hey Didee, would the Spatial Smoothing option in DScaler AdaptiveNoise combined with Soothe+LimitedSharpen be redundant? I can't even perceive what Spatial Smoothing does and if you're saying Soothe already does that should I just disable it with AdaptiveNoise?

+ What does the top right "Parameter" in Resize > Settings do? I found I couldn't Lanczos resize (multiply by 2) + LimitedSharpen a DVD without the odd frame skip (enough to be irritating). Actually, I couldn't avoid frame skip with LimitedSharpen on its own. Just doing Lanczos resize with luma/chroma sharpen for now.

P4 2.8GHz, 2x512MB 2-2-2, Media Player Classic VMR9 Renderless mode

Thanks:cool:

JarrettH
18th February 2006, 05:49
bumpity

Didée
18th February 2006, 19:40
Mate ...

would the Spatial Smoothing option in DScaler AdaptiveNoise combined with Soothe+LimitedSharpen be redundant?
I don't run DScaler on any machine. So no clue what it does where, how or why. However "Spatial Smoothing option in DScaler AdaptiveNoise" sounds to me as if noise is created, and >that< created noise is what gets smoothed? So, no: seems hardly related.

I can't even perceive what Spatial Smoothing does and if you're saying Soothe already does that
Sloppy reading you did. I said that Soothe does temporal smoothing, not spatial.

+ What does the top right "Parameter" in Resize > Settings do?
Setting WHERE? Dscaler? Ffdshow? LimitedSharpen surely has no top-righthanded setting, neither has Soothe.

I found I couldn't Lanczos resize (multiply by 2) + LimitedSharpen a DVD without the odd frame skip (enough to be irritating). Actually, I couldn't avoid frame skip with LimitedSharpen on its own.
Use LimitedSharpenFaster.

Mr.Bitey
20th February 2006, 01:12
+ What does the top right "Parameter" in Resize > Settings do?

I presume your referring to ffdshow, if so its the TAP setting on the resizer in ffdshow.. In simple terms the deeper the sharpening.. - most people use 2 or 4. most people say 4 intorduces too much ringing and is too slow so they use 2.. (which is quicker and produces less ringing).

Cheers,
Bitey

JarrettH
21st February 2006, 19:55
Ooooo, maybe that's why.

Actually I had been using Faster, I just renamed the script and forgot about it.:D

jjseth
22nd February 2006, 12:56
The "soft" option of LimitedSharpen is not related to Soothe's processing. "Soft" in LS is a *spatial* operation, in order to smoothe out pixelation/aliasing/etc that might be caused by strong sharpening settings. Soothe does *temporal* processing to reduce temporal jitter caused by the sharpening process.

So it's two different pairs of shoes, not meant to replace each other, but rather to work together hand-in-hand.

BTW, soft=-1 in LS ~tries~ to find a suited value for "soft" automatically, depending on the used supersampling factors. However I would not trust too much in it, but rather set it manually: suited strengths for "soft" depend pretty much on the combination of values for Smode, strength, supersampling & overshoot ... and so far, no formula containing all these variables & spitting out a good value for "soft" appeared to me.
Thanks for the explanation Didee.

seehowyouare
4th March 2006, 15:14
"There is no function named mt_edge"
"There is no function named DEdge_mask"

I get one or the other error using LimitedSharpen and dll's from post 1, the last 5 pages and also from the wiki. I've d/l 4 different versions of every .dll used, 5 different versions of the script and every MaskTools I can find.
:readguid: Can someone test this wiki page and and update if necessary please ? http://www.avisynth.org/LimitedSharpen

foxyshadis
4th March 2006, 20:09
All you need are one of the two versions I linked to.

Step 1: See if you can use LoadPlugin("c:\path\to\Masktools.dll") and whether it now works. If so, it means you're not placing them into your autoload folder.

Step 2: You either have to find it and put them there, or change its location. It will not read plugins that are just plopped into the same folder as the script.

That's an avisynth issue, not LS, so it doesn't belong on that page. Someday I'll get around to making an avisynth troubleshooting FAQ. ^^;

seehowyouare
5th March 2006, 05:10
Thanks foxyshadis :-)
I got it working using MaskTools-v1.5.8.zip and the following line.

My understanding was obviously wrong that having the MaskTools.dll in the plugins folder would be adequate as the LimitedSharpen script should autload them.

Here's the script thing I used.

LoadPlugin("C:\Program Files (x86)\AviSynth\plugins\MaskTools.dll")
Import("C:\Program Files (x86)\AviSynth\plugins\LimitedSharpen.avs")

LimitedSharpen(ss_x=1.0,ss_y=1.0,Smode=3,strength=40)

Now LimitedSharpen works on my PC, I guess that means the rest of this day is gone :-)

Jeremy Duncan
11th March 2006, 08:16
This is the plugins and software I'm using.

FFDShow
http://www.afterdawn.com/software/video_software/codecs_and_filters/ffdshow.cfm
Avisynth
http://prdownloads.sourceforge.net/avisynth2/Avisynth_256.exe?download
Masktools
http://manao4.free.fr/masktools-v2.0a27.zip
Removegrain. Open RemoveGrain with Winrar, http://www.rarlab.com
http://home.arcor.de/kassandro/RemoveGrain/RemoveGrain.rar
Media Player classic
http://www.afterdawn.com/software/video_software/video_players/media_player_classic.cfm
ColorMatrix
http://www.geocities.com/wilbertdijkhof/ColorMatrix_v110.zip

I get mt_masktools.dll and LimitedSharpenFaster.avsi from the masktools
link.
I get RemoveGrainSSE2.dll from the remove grain link.
I get ColorMatrix.dll from the colormatrix link.
I put all of these into my avisynth plug-in folder.

I delete FFAvisynth.dll, DirectShowSource.dll, TCPDeliver.dll,
colors_rgb.avsi from the avisynth plugin folder.

In the removegrain link. Use the SSE that your cpu has, either SSE or
SSE 2, or SSE 3.
If your cpu has no SSE, use the removegrain dll that I showed that end
in "S", that means it's not SSE.
Get the corresponding SSE FFDShow as well.

Copy and paste this script in the FFDShow Avisynth text box;
ColorMatrix()
Lanczos4Resize(1280,768)
LimitedSharpenFaster(ss_x=1.0, ss_y=1.0, Smode=3, strength=60)

I read on avsforum.com that there is certain plug-in's and setup that don't need as much cpu power.
Is there anything like that available today ?

I can't get limitedsharpenfaster to work on my celeron M 1.4 GHz cpu.
Is it true ffdshow only uses the cpu ?
What hardware is recommended for limitedsharpenfaster + ffdshow ?

foxyshadis
11th March 2006, 09:29
Well, first, there's no way you'll ever get realtime playback of DVD-res mpeg-4 with LSF on a Celeron M of any speed, unless you like a lot of stuttering. You'll have to stick with old-fashioned sharpening for playback.

But for encoding it should work. What error do you get? You might need SSETools for removegrain, but I think that comes with it.

Boulder
11th March 2006, 09:42
Why do you delete those dlls?

I think SSETools is supplied with the latest official RemoveGrain package and not the pre-1.0 one, see www.removegrain.de.tf

Jeremy Duncan
11th March 2006, 10:45
The removegrain I link too is from august 2005.
The one you linked to is from may 2005.

I don't encode. I just watch dvd's.
Please describe the standard pc equipment needed to run limitedsharpenfaster.

And do you know if ffdshow only uses the cpu and only uses the graphics card for gamma video overlay ?

Jeremy Duncan
11th March 2006, 10:55
Why do you delete those dlls?

Just so I know those are all I need to run limitedsharpenfaster.

Boulder
11th March 2006, 11:02
The removegrain I link too is from august 2005.
The one you linked to is from may 2005.

SSETools (if you need that dll) is not available in the pre-1.0 release package like I said. It can only be found in the official v0.9 package. You don't need the older removegrain.dll.

foxyshadis
11th March 2006, 11:03
ffdshow can use the overlay; you need to set it to overlay in its output and set your player to overlay output.

To run LSF on DVD-res in realtime, hm. I would say at least a Pentium M 1.8 or Athlon XP 3000, maybe? (That includes decoding and postprocessing.) Unfortunately I have no experience with P4s or A64s. For smaller video, like vcd, it could work just fine on yours.

Thanks for bringing that up, Boulder, I'll make sure to update the links.

Boulder
11th March 2006, 16:10
ColorMatrix will consume some CPU cycles. Try using BicubicResize instead of Lanczos, it's a bit faster.

Jeremy Duncan
12th March 2006, 00:58
Thanks. I'll try that.

What does "Overlay Mixer" do in FFDShow ?
And does ffdshow only use the cpu ?

Mr.Bitey
12th March 2006, 14:22
Jeremy Duncan,

For the love of god, stop posting that guide on the forums! (here and avsforums) it is inheritly a REALLY bad idead to post a guide for something that yout cant get working yourself for others to follow!.

Now back on topic.

Overlay mixer uses the overlay to display your video, rather than using VMR9 (or vmr7 which isnt used much) - its usually much quicker (especially on low end video cards). You need to set this in ffdshow AND in your DVD PLAYER SOFTWARE PROGRAM. However the problem you are going to have is that your CPU isnt quick enough to run those settings (from your "guide" in real-time) - ffdshow runs in CPU and not GPU.

To resize first, and run those settings you are going to need around a 4Ghz P4. I asked you a long time ago for your system specs so people can help you, and like every other piece of advice/help youve been offered you ignored it.

Forget resizing first on your Pentium M. Just run LSF and let your video card scale the video upto your windows resoltion which I presume is 1280x720 from your "guide". If you get stuttering, try smode4 - its a bit quicker and drop the strength down until it plays smooth (if ever). You might also like to try a different denoiser (rather than using denoiser your using in ffdshow under blur & nr). See socio's guide (refer avsforums thread).

Cheers,
Bitey

tedkunich
12th March 2006, 17:33
Jeremy Duncan,

For the love of god, stop posting that guide on the forums! (here and avsforums) it is inheritly a REALLY bad idead to post a guide for something that yout cant get working yourself for others to follow!.

Now back on topic.

Overlay mixer uses the overlay to display your video, rather than using VMR9 (or vmr7 which isnt used much) - its usually much quicker (especially on low end video cards). You need to set this in ffdshow AND in your DVD PLAYER SOFTWARE PROGRAM. However the problem you are going to have is that your CPU isnt quick enough to run those settings (from your "guide" in real-time) - ffdshow runs in CPU and not GPU.

To resize first, and run those settings you are going to need around a 4Ghz P4. I asked you a long time ago for your system specs so people can help you, and like every other piece of advice/help youve been offered you ignored it.

Forget resizing first on your Pentium M. Just run LSF and let your video card scale the video upto your windows resoltion which I presume is 1280x720 from your "guide". If you get stuttering, try smode4 - its a bit quicker and drop the strength down until it plays smooth (if ever). You might also like to try a different denoiser (rather than using denoiser your using in ffdshow under blur & nr). See socio's guide (refer avsforums thread).

Cheers,
Bitey


Bitey,

I read in one of his posts on AVSForum that not only was he running a Celeron, but it was a laptop as well!! no way in hell will that thing have the bandwidth, not to mention the HP to do anything other than simple filtering.

T

Jeremy Duncan
12th March 2006, 19:23
Overlay mixer ...You need to set this in ffdshow AND in your DVD PLAYER SOFTWARE PROGRAM.

Forget resizing first on your Pentium M (Celeron M). Just run LSF and let your video card scale the video upto your windows resoltion which I presume is 1280x720 from your "guide". If you get stuttering, try smode4 - its a bit quicker and drop the strength down until it plays smooth (if ever). You might also like to try a different denoiser (rather than using denoiser your using in ffdshow under blur & nr). See socio's guide (refer avsforums thread).

Cheers,
Bitey

Well. I setup the overlay in MPC. And Now I can set the overlay in ffdshow.
I can play LSF and denoise3d, with minor stutter.
It doesn't matter if overlay is on or off, no performance difference.
I tried smode 4. Couldn't see a big difference.
I also set the strength to 100, 60, 30. No difference.
I tried with denoise3d off. No difference.

My pc specs are;
Dell Inspiron 1300
Celeron M
512 dual ram
Integrated gma 900 graphics
40GB HDD

If only I got a dual core notebook instead.
But I just learned about limitedsharpen a few days ago.

foxyshadis
12th March 2006, 22:48
Yep, there's a big difference between a $500 laptop and an $1800 one. Of course ffdshow is utterly single-threaded, so a good P-M would do you better than a core duo right now. And ss_x/ss_y are the only settings that make a noticeable speed difference. Anyway, now that you've figured out all your LSF settings can you not keep posting in this thread, for tidyness' sake?

Jeremy Duncan
13th March 2006, 02:01
I'll post in this thread again possibly, but when/if I do, I'll focus on keeping the thread "Avisynth Jedi" Cool.

aichan
19th March 2006, 09:37
i'd like to try this good sharpener. but i still confuse how to set the order on the script..

i would use these filter
1.deinterlacer
2.denoiser
3.??? (anything else?)
4.limited sharpener
how should i put in order the filter correctly??

sorry for my english and basic question :)

Yama4050242
20th March 2006, 01:43
i have original limitedsharpen and 2 more modiffied version(LimitedSharpen_(modded-27Nov2005), LimitedSharpen_(modded-29Oct2005)) and limitedsharpenfaster
my question is is limitedsharpenfaster really faster than the other 3,and which version is stable, which version i should use

Mr.Bitey
21st March 2006, 05:16
Yama4050242,

Limited sharpen faster, is faster - it has some of the scripting offloaded into MaskTools (previously into a seperate DLL)..

Cheers,
Bitey

seehowyouare
1st April 2006, 04:59
I still think the Avisynth LimitedSharpen wiki (http://www.avisynth.org/LimitedSharpen)needs an update :readfaq:

You can find all the different LS scripts there but I can't find any working examples of how to load the scripts etc. :confused: I have to start digging through this thread to learn the new functions and what they do.

foxyshadis
1st April 2006, 06:57
I moved it to the new wiki some time ago:

http://www.avisynth.org/mediawiki/wiki/LimitedSharpen

Feel free to contribute relevant examples, even if they're just copied from the thread. I kinda let that part slide.

Backflip
1st April 2006, 08:46
The Wiki doesn't load for me atm.

edit - it's working now, thanks :)
edit2 - admittedly I do get a little mixed up. I see that there are different versions of LimitedSharpen included in the Wiki (talked about). Which version (of LimitedSharpen(), MaskTools, etc) should be used today?
edit3 - LimitedSharpen is the topic, but LimitedSharpenFaster is the download, hhm

Jeremy Duncan
13th April 2006, 20:41
http://img156.imageshack.us/img156/1691/17ty2.jpg

2 removegrains ?

How does ffdshow use 2 removegrains ?

foxyshadis
14th April 2006, 00:51
I guess I should clear that up. You have to copy RG 1 over RG .9, otherwise you'll get errors (specifically, RG 1.0 does not include SSETools.dll, somebody *whistles* should make a package with both). When I make the RemoveGrain wiki page I'll explain that.

Jeremy Duncan
14th April 2006, 04:38
I guess I should clear that up. You have to copy RG 1 over RG .9, otherwise you'll get errors (specifically, RG 1.0 does not include SSETools.dll, somebody *whistles* should make a package with both). When I make the RemoveGrain wiki page I'll explain that.
Now I see.

Can somebody please post the text with them together ?
And do I call it removegrain.avs ?

foxyshadis
14th April 2006, 05:07
They're all .dll plugins, there's no text or avs, just the links you took a screenshot of. If kassandro gets back to me I'll host a combined package so that we can do away with linking to both, and perhaps get 1.0 final to see the light of day, but he's been away for a long time now.

Jeremy Duncan
14th April 2006, 08:09
Please show the steps to copy the 1 over the other ?
Do I put 0.9 in a folder then put the 1 in the same folder ?

foxyshadis
14th April 2006, 10:16
Exactly, in your avisynth plugins folder. The 1.0 rar is just the one file, I think, or maybe the three sse versions, but either way you just copy it over the old one.

Jeremy Duncan
14th April 2006, 16:22
That worked.

:thanks:

EpheMeroN
15th April 2006, 03:58
For those (like myself) that had issues getting the new LimitedSharpenFaster script working, or had a difficult time hunting down all the filters and scripts, I made a simple zip file containing the current LimitedSharpenFaster script and all the needed plugins.

You can get it here: http://rapidshare.de/files/18037395/LimitedSharpenFaster_v2.0b.zip.html

Chainmax
19th April 2006, 14:37
When using LMode=3, what difference would there be between using SMode=4 and SMode=3?

Mr.Bitey
20th April 2006, 02:47
Smode4 appears to have some type of magic involved.. and is quicker than Smode3.. the answer probably lies in the earlier part of this thread...

Cheers,
Bitey

Chainmax
20th April 2006, 02:53
I know about SMode=4's alleged magic but didn't know about the speed. In any case, reading the whole thread just for this seems pointless.

Mr.Bitey
20th April 2006, 03:15
I think i have found the answer:
http://forum.doom9.org/showthread.php?s=&threadid=87514

Upon further reading of that thread - its not ..

Cheers,
Bitey

Jeremy Duncan
26th April 2006, 07:13
Please tell me if LanczosResize is nessessary or recommended as a additional sharpener if I'm using Limitedsharpenfaster ?

Quoting zambelli
" LSF is designed to be better than your average sharpener. From Didee's description: "LimitedSharpen() applies one out of three different sharpeners (two domain sharpeners or a windowed range sharpener) to the source, but will limit the oversharpening (either 'hard' or 'soft') IF it exceeds a defined overshoot." AFAIK, LanczosResize just sharpens the entire image equally with no consideration for oversharpening. Someone please correct me if I'm wrong. Applying LanczosResize together with LSF is then double sharpening. If that's anyone's goal, why not just tweak LSF to produce that much sharpening in the first place? "

Link (http://www.avsforum.com/avs-vb/showthread.php?t=469464&page=23&pp=30)

Audionut
26th April 2006, 07:20
Please tell me if LanczosResize is nessessary or recommended as a additional sharpener if I'm using Limitedsharpenfaster ?

No. Just use limitedsharpen to resize.

Jeremy Duncan
26th April 2006, 08:03
I don't resize using limitedsharpen.

My question is about limitedsharpenfaster with resizing
vs
LanczosResize sharpening.

LanczosResize sharpens. AFAIK.
Limitedsharpenfaster sharpens. AFAIK.
Ok ? You see ?
Now. zambelli thinks LanczosResize resizing and using limitedsharpenfaster is sharpening twice,
and the reason to use LanczosResize is to sharpen.
If this is the case. Is Limitedsharpenfaster with resizing sufficient sharpening, or do we need LanczosResize sharpening too ?

Audionut
26th April 2006, 08:11
Lanczosresize is not a sharpener.

Limitedsharpen or limitedsharpenfaster is a sharpener.

Limitedsharpen/faster by it's nature, resizes video.
Limitedsharpen/faster allows you to select the output resolution after it has processed the video.

So limitedsharpen/faster is sharpening and resizing.
You might aswell select an output resolution in limitedsharpen/faster and just let it do the final resize rather than resizing with lanczosresize aswell.

If you need the video sharper, adjust the settings of limitedsharpen/faster.

Trying to sharpen with a plain resizer is useless.

Jeremy Duncan
26th April 2006, 08:19
SetMTMode(2)
MT("HQDN3D(0.0,2,0.0,4)")
MT("LimitedSharpenFaster(ss_x=1.0,ss_y=1.0,Smode=3,strength=60,overshoot=7)")

That's the script I'm using in ffdshow.
It's for using hyperthreading.
I can't use dest_x= and dest_y= in limitedsharpenfaster.

Using the script I've shown. Is limitedsharpenfaster still resizing And sharpening ?

Audionut
26th April 2006, 09:04
I have no problems using this.

limitedsharpenfaster(dest_x=720,dest_y=384,ss_x=1.0,ss_y=1.0,Smode=3,strength=60,overshoot=7)

Perhaps it's related to MT
Perhaps you could be more specific as to what the problem is.

Jeremy Duncan
26th April 2006, 09:51
SetMTMode(2)
MT("HQDN3D(0.0,2,0.0,4)")
MT("LimitedSharpenFaster(ss_x=1.0,ss_y=1.0,Smode=3,strength=60,overshoot=7)")

This is the script I'm using in ffdshow. It's made for hyperthreading.

I tried to run dest_x= and dest_y=. It won't work using this setup.

You said Limitedsharpenfaster resizes and sharpens.
Does the limitedsharpenfaster script I posted sharpen and resize ?

Am I correct in thinking I don't need dest_x= and dest_y= in limitedsharpenfaster for it to resize and sharpen ?

Jeremy Duncan
26th April 2006, 09:55
LanczosResize is an alternative to BicubicResize with high values of c about 0.6 ... 0.75 which produces quite strong sharpening. It usually offers better quality (fewer artifacts) and a sharp image.

Lanczos was created for AviSynth because it retained so much detail, more so even than BicubicResize(x,y,0,0.75). As you might know, the more detail a frame has, the more diffiult it is to compress it. This means that Lanczos is NOT suited for low bitrate video, the various Bicubic flavours are much better for this. If however you have enough bitrate then using Lanczos will give you a better picture, but in general I do not recommend using it for 1 CD rips because the bitrate is usually too low (there are exceptions of course).

Link (http://www.avisynth.org/Resize)

Jeremy Duncan
26th April 2006, 09:59
LanczosResize is a sharpener.
Is this how it removes artifacts ?

If I'm using limitedsharpenfaster.
Does this act as a replacement for LanczosResize ?
And is LanczosResize a replacement for limitedsharpenfaster ?

Audionut
26th April 2006, 10:07
Lanczos was created for AviSynth because it retained so much detail
Lancosresize is a resizer. It does not sharpen, it retains more detail. End of discussion.

Does the limitedsharpenfaster script I posted sharpen and resize ?
When limitedsharpenfaster processes video it resizes it.
However it's default setting will output video at the same resolution as input. If you would like limitedsharpenfaster to output a different resolution, then you must specify parameters of "dest_x=" & "dest_y=".

Audionut
26th April 2006, 10:14
All resizers blur the image. Lancosresize retains more detail. Hence it looks sharper.

It does not sharpen

Else it would be called.

Lancossharpenresize.

Jeremy Duncan
26th April 2006, 10:17
Lancosresize is a resizer. It does not sharpen, it retains more detail. End of discussion.


When limitedsharpenfaster processes video it resizes it.
However it's default setting will output video at the same resolution as input. If you would like limitedsharpenfaster to output a different resolution, then you must specify parameters of "dest_x=" & "dest_y=".

I'll post back what I think your saying.

- limitedsharpenfaster resizes. dest_x= & dest_y= add a option,
but limitedsharpenfaster resizes without using dest_x= & dest_y=

- LanczosResize retains more detail.
Does limitedsharpenfaster resize without dest_x= & dest_y= do the same thing ?

- What I'm asking is what does the function of LanczosResize do that limitedsharpenfaster does not ?

manono
26th April 2006, 12:28
Hi-

LanczosResize is an alternative to BicubicResize with high values of c about 0.6 ... 0.75 which produces quite strong sharpening. It usually offers better quality (fewer artifacts) and a sharp image.

In that quotation of yours from the AviSynth docs, the "produces quite strong sharpening" refers to Bicubic tuned to 0.75. I'll admit that it's confusing and badly worded. It's saying that Lanczos resizes while retaining detail, but without adding artifacts such as Edge Enhancement, that you might get from a strong Bicubic resizing.

To answer your question (maybe), if for some reason you're unable to get LimitedSharpen(Faster) to give you your final resolution, I don't see why you can't use LanczosResize to do it for you. It won't sharpen any more, but just retain the detail that's already there.

Jeremy Duncan
26th April 2006, 12:43
Hi.

1.) limitedsharpenfaster resizes. dest_x= & dest_y= add a option,
but limitedsharpenfaster resizes without using dest_x= & dest_y=

2.) LanczosResize retains more detail.
Does limitedsharpenfaster resize without dest_x= & dest_y= do the same thing ?

3.) What I'm asking is what does the function of LanczosResize do that limitedsharpenfaster does not ?

Those were my questions.
I'm sorry to ask this directly, but please answer my three questions. I'll probably link to it, and it'll help in general I think.

Thank you very much.

manono
26th April 2006, 14:15
...but please answer my three questions.

That's all right. I'll pass. If what I wrote before didn't help any, I have nothing more to add.

Soulhunter
26th April 2006, 15:58
Nooo, not the "lanczos sharpens (http://forum.doom9.org/showthread.php?p=808457#post808457)" discussion again... -.-

@ Jeremy Duncan

I dont really understand your questions, but I think you understood the whole concept of LimitedSharpen wrong!? LanczosResize is a resizer and LimitedSharpen is a sharpener... LimitedSharpen uses a resizer internally (LanczosResize iirc) coz it upsizes the image -> sharpens it (in a tricky way) -> downsizes it... Why the upsizing and downsizing? Because the sharpening step causes aliasing (steppy/pixelated edges) and the interpolation of the downsizing step helps to eliminate this effect! Now, as LimitedSharpen does internal resizing anyway, it offers a option to determine the output resolution (which saves you from using another resizing step afterwards) if you dont wanna keep the original resolution!


Bye

foxyshadis
26th April 2006, 17:03
MT might not be able to resize within, not sure. Anyway, LSF ends with a lancsozresize call. So if you follow it with another, you end up with 3 lanczosresizes, instead of just two, which leads to some more artifacts.

Oh wait, you use no supersampling, which means they're exactly the same, 1 resize whether you do it inside or outside. It'll look worse, but I assume this is for playback, or else there's no good reason to use no supersampling (always sharpen at the final size, whether you resize before or during LSF, but don't do it after unless you absolutely must).

Jeremy Duncan
26th April 2006, 23:06
Nooo, not the "lanczos sharpens (http://forum.doom9.org/showthread.php?p=808457#post808457)" discussion again... -.-

@ Jeremy Duncan

I dont really understand your questions, but I think you understood the whole concept of LimitedSharpen wrong!? LanczosResize is a resizer and LimitedSharpen is a sharpener... LimitedSharpen uses a resizer internally (LanczosResize iirc) coz it upsizes the image -> sharpens it (in a tricky way) -> downsizes it... Why the upsizing and downsizing? Because the sharpening step causes aliasing (steppy/pixelated edges) and the interpolation of the downsizing step helps to eliminate this effect! Now, as LimitedSharpen does internal resizing anyway, it offers a option to determine the output resolution (which saves you from using another resizing step afterwards) if you dont wanna keep the original resolution!


Bye

That's great. Thank you !

Mr.Bitey
28th April 2006, 07:04
I'll just add that if people are using MT you cannot use different input and ouput resolutions (via dest_x,dest_y) with limited sharpen faster.

Also in testing I found that running LSF with MT and resizing in ffdshow after (lanczos2) was faster than using dest_x,dest_y to resize without using MT.

Cheers,
Bitey

Jeremy Duncan
28th April 2006, 20:32
I can't run MT avisynth and resize.
My video card is 32MB sdram agp 4x

What video card do you recommend.
Also the cheapest one that just meets the requirement.
Please.

:thanks:

Mr.Bitey
29th April 2006, 11:49
Jeremy,

I can only say what works on my system. Are you sure its your video card letting you down? - it might be your CPU - there isnt really any way of telling unless you can find someone with a similar specced PC that can run it without stuttering.

I'd suggest a new thread over on avsforums seeking what hardware people are running stutter free, their settings and the test material - something that most people will have so people are able to test it. It also depends if the material is 16:9 or 2.35:1 - eg. I was testing on LOTR FSOTR EE (smooth) but found a couple of small stutters watching "into the void" which has lots of panning but is 16:9..

Im running a P4@3.44 and a radeon9800 pro (128mb,8x agp) - I can only use overlay to ensure stutter-free playback - vmr9 stutters (I havent tried vmr7 yet - but probably wont bother).

Cheers,
Bitey

sander815
8th May 2006, 10:50
how do i use this script?

Chainmax
8th May 2006, 14:48
All resizers blur the image. Lancosresize retains more detail. Hence it looks sharper.

It does not sharpen

Else it would be called.

Lancossharpenresize.

Not to be confrontational, but why does it ring then?

Wilbert
8th May 2006, 15:57
Not to be confrontational, but why does it ring then?
It's because the resizer oscillates (a sync function in this case). As a result you will get the Gibbs phenomenon around the edges: http://mathworld.wolfram.com/GibbsPhenomenon.html. A nice sharp edge is replaced by something which oscillates around the edge, which is called ringing. A small amount of ringing improves the perceived sharpness of the image.

Perhaps that technically you can see ringing as sharpening, but it's an unwanted effect if you want to sharpen your image.

http://audio.rightmark.org/lukin/graphics/resampling.htm
http://bigwww.epfl.ch/publications/thevenaz9901.html (page 8,9)

Chainmax
8th May 2006, 23:28
I see, thanks for the explanation :).

fjhdavid
10th May 2006, 00:44
Dear all,

I followed all the discussion threads and run avisynth 2.5.6 with masktools 2.0a28 , removegrain 1.0beta and of course LimitedSharpen Faster (29 october version)

I wrote:

Import("C:\Program Files\AviSynth 2.5\plugins\LimitedSharpenFaster.avsi")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\mt_maskTools.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\RemoveGrainSSE2.dll")

LimitedSharpenFaster(ss_x=1.0,ss_y=1.0,Smode=3,strength=50)

IT WORKS PERFECTLY

but when I want to use:

LimitedSharpenFaster(ss_x=1.0,ss_y=1.0,Smode=4,strength=150,soft=34)

I have a "invalid floating point error"

What should I have to do?
Thanks
francois

foxyshadis
10th May 2006, 01:27
Try soft=34 in the Smode=3 version. If it fails, then I'm almost certain it's removegrain failing, most likely because you don't actually have SSE2. (Other things that might cause the same crash: wide=true, special=true, or edgemode=1 or 2.) Try the basic SSE version. If smode=3 works, then it might be some bizarre error in masktools, but I haven't seen it happen on any of my machines. Hm.

Mr.Bitey
10th May 2006, 02:16
All,

Aparently there is a new version of ffdshow out that supports SSE2 and Multithreading. I havent tried myself but Jeremy (whom found and posted a link on avsforums) gave it shot and reports it works better than LSF with MT.

http://www.free-codecs.com/FFDShow_download.htm

Cheers,
Bitey

fjhdavid
10th May 2006, 23:01
I tried soft=34 with smode=3 and it works
I use also the last version of ffdshow of the 8 may of 2006

which version of ffdshow are you using foxyshadis?

videoFred
16th May 2006, 09:56
LimitedSharpenFaster is fixing Histograms, too!

Examples: go to bottom of page
http://forum.doom9.org/showthread.php?t=93571&page=5

Can someone explain this?

Fred.

foxyshadis
16th May 2006, 10:31
Anything that convolves the video will smooth the histogram back out. Try blur, sharpen, mipsmooth, frfun, and so on as well. (Certain filters, like removegrain/degrainmedian, don't average, they just pick one of the existing values. Thus they can never reinterpolate the histogram. Well, DGM does to a very very low extent, which might just be roundoff error.)

Voodoochild
29th May 2006, 18:16
Suddenly with limitedsharpenfaster, which wasn't before.
I don't know what happened , I used LimitedSharpenFaster lot's of time before. It took less then 50% cpu usage. now it takes 100% and I can't use it no more.
I didn't change the script,
I'm using removegrain 1.0 beta
and the latest masktool (2 I think).
I love this function but can't use it no more cause of the high cpu usage. I'd appreciate any help thanks in advance
Elad

Boulder
29th May 2006, 18:32
What is the source? What program did you use when the high cpu usage occurred?

Voodoochild
29th May 2006, 18:49
What is the source? What program did you use when the high cpu usage occurred?

I just playes it with virtualDub as always to check the filter effect, that all.
I also tried remove grain and cpu was low, hqdn3d() cpu is 70% .... only limitedsharpen 100% and I don't know why :-(

Boulder
29th May 2006, 18:51
If you didn't know, LS is very CPU intensive as it's a very complex function and not meant for realtime processing though you can do that at times.

Voodoochild
29th May 2006, 19:07
till few days ago it was max 50% cpu :-( I don't know what happend....

Voodoochild
29th May 2006, 21:53
earlier I used ss_x=1.0,ss_y=1.0 .. However when left the default (1.5) or 2.0 the function uses lanczosresize , which cause the function to take 100% of CPU usage.
Same with lmode=3 and edges=1. So now I know better how the function works and how to configure it,
10x any way for trying to help.
Elad

Soulhunter
29th May 2006, 22:24
EDIT: Corrected, lol!

Yeah, with 2x supersampling the filtering has to process 4x more data, hence the filtering eats 4x more CPU power... :)

Bye

Isochroma
29th May 2006, 22:31
Actually, in that case it would be 4x more data.

Soulhunter
30th May 2006, 01:31
Actually, in that case it would be 4x more data.

Oh yeah, I always forget the ² ^^;

It should be "(2*x)*(2*y) = 4x more data" or "2*(x*y) = 2x more data" where limitedsharpen's ss params do the first.


Thanks n' Bye

foxyshadis
30th May 2006, 01:36
LS is only 1.5x SS by default, so it's 2.25x the data. :p I've considered adding a "fast=true" or "realtime=true" preset to cut down on some of the processing for people who aren't afflicted with dual cores. But setting supersampling is mostly all that needs to be done.

fjhdavid
19th July 2006, 18:41
Dear all,

I recently tested LS which is very good for videoprojector.
I switched back and forth from smode=3 to smode=4.

My conclusion is that smode=3 looks better than smode=4
Do you share this conclusion?

thanks

Backwoods
19th July 2006, 22:07
It seems it would depend on the source footage.

fjhdavid
20th July 2006, 00:31
What do you mean?
If the source footage is below average or poor, do I have to use smode=3 or smode=4 ?

Backwoods
20th July 2006, 01:05
Sometimes anything won't help below average or poor source footage. Depending on how soft or sharp or what type of source (video, anime) smode can make a big difference, that is what I meant.

Best way is to do tests to determine what works for you. Which seems to be smode=3.

fjhdavid
20th July 2006, 08:24
ok, I read all the LS posts and the "soothe function" posts.

I have three questions:

With a "soft source" (film record from satellite on DVD and de-interlaced with weave) do I have to use smode=3 or smode=4?

Is the "soothe function" designed also for smode=3 (I saw only examples with smode=4) and is it useful or mandatory?

What is the filters order betwen "denoise and blurr", "lanczos resise" and "limitedsharpenfaster"?

thanks

foxyshadis
20th July 2006, 10:22
Soothe is actually made for any spatial filter that causes temporal instability, which is mostly sharpeners but a few aggressive smoothers as well. All the modes of LS are affected.

The main difference is that for the same strength, Smode 4 is a more powerful sharpening that also tends to pick up more noise (and thus can look worse on bad video), while softer transitions also aren't sharpened as hard, but overall they're very similar.

To make the differences really obvious, try this:

s3=LimitedSharpenFaster(Smode=3,strength=5000)
s4=LimitedSharpenFaster(Smode=4,strength=5000)
stackvertical(s3,s4) # or interleave()


The order of filters really depends on your source. If it's already reasonably clean, try:

dn=YourDenoiseFilter()
SeeSaw(denoised=dn)
Resize()

instead. If it's mediocre or just bad, try:

YourDenoiseFilters()
LimitedSharpenFaster(Smode=3,dest_x=720,dest_y=288)

or whatever you would otherwise resize to, or

YourDenoiseFilters()
Resize()
o=last
LimitedSharpenFaster(Smode=3)
Soothe(last,o)

if you want to soothe it.

fjhdavid
24th July 2006, 01:02
thanks for your help.

one thing:
What is exactly Lmode=3? it looks slower

If you have sufficient power is it better than Lmode=0?

RogueSquadron
25th July 2006, 22:33
after using LS script i seem to have missed out on a bit of detail frm the original source! *a stuble looks like clean shaven:( *

is it with the script or am i looking somewhere else?

Pookie
25th July 2006, 22:54
RogueSquadron - First post,huh? - Welcome. Post your script-otherwise, how can anyone even guess where the problem lies ?

RogueSquadron
26th July 2006, 08:49
RogueSquadron - First post,huh? - Welcome. Post your script-otherwise, how can anyone even guess where the problem lies ?

:D thanx


LoadPlugin("G:\MY DOWNLOADS\dvdripper\DVD tools\avs scripts\MaskTools.dll")
LoadPlugin("E:\Program Files\AviSynth 2.5\plugins\warpsharp.dll")
import("G:\MY DOWNLOADS\dvdripper\DVD tools\avs scripts\yvlevels.avs")
import("G:\MY DOWNLOADS\dvdripper\DVD tools\avs scripts\limitedsharpen.avs")
DGDecode_mpeg2source("C:\movies\Cste\index.d2v",info=3)
ColorMatrix(hints=true)
tfm().tdecimate()
crop( 6, 54, -6, -60)
YlevelS(0,1.1,255,0,255)
LanczosResize(720,304) # Lanczos (Sharp)
LimitedSharpen( ss_x=1.5, ss_y=1.5, dest_x=last.width, dest_y=last.height,
\ Smode=3, strength=1000, radius=2,
\ Lmode=1, wide=false, overshoot=1,
\ soft=false, edgemode=0, special=false,
\ exborder=0 )

undot()

colormatrix()

and yeah i used "strength=1000" coz i dint notice any considerable changes in the picture untill i put something that high..but time and again i loose a bit of detail this is not the frst tme ! i i lost it even when i try the fefault settings! even when i use seesaw it happens :( i was jst waiting for 5 days[*sigh* that was long] to finish and here iam ;)

foxyshadis
26th July 2006, 09:51
You don't have to specify every argument, expecially the debugging ones, that's why they're named. ;) (radius isn't even used for smode 3.) So is the lack of details comparing to LS+undot to undot alone? Or both to neither? Because undot has a habit of killing very fine detail very quickly, especially if your source is very sharp like this. With such a high strength you'll probably notice visible ringing as well, which cuts into detail.

Oh, and pick up LSF and try Smode 4, you'll probably notice sharpening at a much lower level. The first post in the thread is rather out of date. *pokes Didée to at least link to the wiki*

RogueSquadron
26th July 2006, 09:59
You don't have to specify every argument, expecially the debugging ones, that's why they're named. ;) (radius isn't even used for smode 3.) So is the lack of details comparing to LS+undot to undot alone? Or both to neither? Because undot has a habit of killing very fine detail very quickly, especially if your source is very sharp like this. With such a high strength you'll probably notice visible ringing as well, which cuts into detail.

Oh, and pick up LSF and try Smode 4, you'll probably notice sharpening at a much lower level. The first post in the thread is rather out of date. *pokes Didée to at least link to the wiki*

'yes i did try lsf! but there comes the question of discoloration! :(.. even with the default settings of lsf i loose a lot of color ..
so, wud u mean that i stop using ls+undot an use some other denoiser?

Boulder
26th July 2006, 10:04
Why not post a screenshot of a frame with and without LSF.

RogueSquadron
26th July 2006, 10:17
something exactly like this ...

http://forum.doom9.org/showpost.php?p=569645&postcount=59


but then i cudnt figure this out

http://forum.doom9.org/showpost.php?p=569672&postcount=61

Didée
26th July 2006, 11:44
after using LS script i seem to have missed out on a bit of detail frm the original source!
- - -
and yeah i used "strength=1000" coz i dint notice any considerable changes in the picture untill i put something that high..but time and again i loose a bit of detail this is not the frst tme ! i i lost it even when i try the fefault settings! even when i use seesaw it happens
- - -
'yes i did try lsf! but there comes the question of discoloration! .. even with the default settings of lsf i loose a lot of color ..

I'm not sure what you're doing there, but it really seems you're doing something wrong ...

LimitedSharpen/Faster and SeeSaw both are sharpeners. They aim for enhancing detail, and that's what they're doing. Can't imagine how any loss of detail should be happening there. Also, no discoloration will be produced by these functions.

What I noted in your script:

- ColorMatrix() is called two times (at beginning & at end). Don't do that. Delete the one at the end of the script.

- loss of very fine detail indeed may be caused by undot. Try without undot, to compare.

- Perhaps (?) some detail is lost during IVTC by TFM, because of (default) postprocessing? (Unsure about this, as usually I'm not working with telecined sources.)


Try the following script, zoom in by 200% or 400% in Vdub, and do forth-and-back-stepping with the arrow keys. This should show you that no detail loss or discoloration is caused by LimitedSharpen. (The same could be done for SeeSaw.)

Also you should be able to see the changes that LS is doing with "normal" strength values around ~100 ... 1000 is pretty high. But then, perhaps it's wrong expectations on your side ... LS is not intended for turning a dull source into something !boom!bas!tic! For that, just use "sharpen(1)", or even stronger Unsharp Masking, and live with all the uglyness that comes along with those ... ;)

DGDecode_mpeg2source("C:\movies\Cste\index.d2v",info=3)
ColorMatrix(hints=true)
tfm().tdecimate()
crop( 6, 54, -6, -60)
LanczosResize(720,304) # Lanczos (Sharp)
base = last

LimitedSharpen( ss_x=1.5, ss_y=1.5, dest_x=last.width, dest_y=last.height,
\ Smode=3, strength=1000, radius=2,
\ Lmode=1, wide=false, overshoot=1,
\ soft=false, edgemode=0, special=false,
\ exborder=0 )

interleave( base .subtitle("no LS"),
\ last .subtitle("with LS" ) .selectevery(4,0,1)

YlevelS(0,1.1,255,0,255)
return(last)

RogueSquadron
26th July 2006, 11:49
thanx didee, will give it try :)



edit:- i can see the difference! now[this script is similar to seesaw :D] its defnetely a problem with undot.. do u recommend anyother denoiser for little noise

thanx

Boulder
26th July 2006, 12:34
Furthermore, ColorMatrix is applied to avoid the color changes when encoding so no need to worry about the change of colors when you load the script in VDub.

pojke
27th July 2006, 04:58
After looking at the limitedsharpen page (http://www.avisynth.org/LimitedSharpen) and reading through this thread, I'm still confused. So, some questions:

Should the script be downloaded as a file or should it be copied from the above page? Should it be saved as .avs or .avsi? Does it go in the plugins folder?

The warpsharp, removegrain, and masktools downloads contain very many files, some of them in subfolders. What should be done with these? Are all of them to be dumped into the plugins folder? The removegrain documentation actually says not to put all of them in.

The page (http://www.avisynth.org/LimitedSharpen)says you need Removegrain 1.0 beta AND Removegrain 0.9. But both contain, for example, a RemoveGrainSSE2.dll -- and it's a different size. In such a case, how do you install both?

I'd really like to put only what's needed into the plugins folder. At minimum, what needs to be there?

foxyshadis
27th July 2006, 05:56
The dlls are the main files; all other files are source code for developers, or documentation. The dlls can all be put in the plugins folder safely (although avisynth 2.5.6 and lower has issues with too many files in it). Or you can load them manually; I split them between an auto and non-auto folder because of the old load limit.

As for removegrain, extract the 0.9 dlls and then extract the 1.0 dlls over it - some are missing from 1.0 and kassandro never made a final zip. I guess I should make that page clearer. You'll only need one of each, pick whatever your CPU is capable of.

The only difference saving the script as an avsi makes is that if it's in the plugin folder you won't have to add an Import("...") to each script that uses it. Pretty useful.

BangoO
27th July 2006, 16:11
Hi there,

Did anyone manage to apply LimitedSharpen (or LimitedSharpenFaster) realtime on 1280*720p sources ?
I have an X2 3800+ @ 2*2500Mhz, and even using MT() did not help, I'm still a bit too short :(

Daodan
27th July 2006, 16:38
Considering the playing speed using LSF on 720p is...well 5 fps on 3200+.. I really have doubts you'll be able to use it.

Pookie
27th July 2006, 17:10
Read Socio's posts at Avsforum.com on playback via LimitedSharpen.

My question - why not encode with LimitedSharpen and play THAT back ?

BangoO
27th July 2006, 17:55
What I read from Socio is that he was resizing after applying LimitedSharpen, and that his source is not 720p.
But maybe I wrong, I'll check and ask him...

Yes, I could encode with LimitedSharpen, but I prefer to encode with as less filters as possible in order to have a better choice during playback.

PS: Daodan, I get around 20-22fps, so not that far from the 24fps I should get...

pojke
27th July 2006, 23:24
The dlls are the main files; all other files are source code for developers, or documentation. The dlls can all be put in the plugins folder safely........ As for removegrain, extract the 0.9 dlls and then extract the 1.0 dlls over it......I put the following .dlls in the plugins folder (as well as the script)

warpsharp.dll - avsfilter.dll - SSE2Tools.dll - DenoiseSharpen.dll -RemoveGrainSSE2.dll - RepairSSE2.dll - RSharpenSSE2.dll - MaskTools.dll - LimitedSupport_09Jan06B.dll

but when I try to run the main script I get errors.
With LimitedSharpenFaster.avs, it said "there is no function named LimitedSharpenFaster"
With the .avsi extension, the error is, "there is no function named 'mt_edge.'"

In earlier posts others were having the same mt_edge issue but seemed to solve it by getting a newer avisynth, but I had just upgraded to 2.56.

This is the script I'm using:
DirectShowSource("E:\Capture\capture\mscl test.mpg")
Letterbox(4,0)
ConvertToYUY2()
PeachSmoother()
ConvertToYV12()
LimitedSharpenFaster(2)

foxyshadis
27th July 2006, 23:44
You're missing masktools 2 (its filename is mt_masktools.dll). LimitedSharpen uses masktools 1, whereas the Faster variant uses 2.

pojke
28th July 2006, 00:10
After adding mt_masktools.dll, the error messages disappeared. But it crashes CCE (2.70). If I take LimitedSharpenFaster() out of the script, it works fine, so the rest of the script is OK. Any ideas?

foxyshadis
28th July 2006, 00:39
Does it work in virtualdub? CCE requires a ConvertToYUY2 at the end, iirc, but that might not be it. If not, at least vdub should give you a useful error.

The newer wiki entry (http://www.avisynth.org/mediawiki/wiki/LimitedSharpen) also has better explanations on usage, once you get it working.

pojke
28th July 2006, 01:14
I can open the .avs in virtualdub and play or scroll through the clip, but if F5 is pressed in the script editor, it crashes.

I then tried putting a ConvertToYUY2() after limitedsharpen, but it still crashes CCE. And after an F5 in virtualdub, it doesn't crash, but exhibits very strange behavior when playing it -- video seems stuck in a loop where several frames are repeated.

Pookie
28th July 2006, 03:24
Try DGIndex on the source and call the .D2V with Mpeg2Source("xyz.d2v"). I've rarely had good luck with DirectShowSource on Mpeg files. BTW, to verify, when you remark out the call to LimitedSharpen, no crash?

pojke
28th July 2006, 08:15
I'm not sure I did it correctly, but I tried the DGIndex method and got an error when opening in virtualdub: "MPEG2Source: couldn't open source file, or obsolete D2V file"

Yes, when LimitedSharpenFaster() was removed, it encoded normally. Because of that, I don't think DirectShowSource is the problem here.

I probably should have concluded that about the YUY2 possibility too. As long as LimitedSharpenFaster() was removed, it worked fine even without converting to YUY2.

foxyshadis
28th July 2006, 09:34
DirectShowSource is the least stable part of avisynth; while such an interaction is weird, it's not improbable. The error means that you have a different version of DGIndex vs DGDecode, they always have to be the same. (That's why they're packaged together.)

pojke
29th July 2006, 04:35
It works!
At least on the 24-sec test clip with the following script:

LoadPlugin("C:\Program Files\AviSynth 2.5\old plugins\LoadPluginEx.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\old plugins\DustV5.dll")
Mpeg2Source("E:\Capture\capture\mscl test.d2v")
Letterbox(4,0)
ConvertToYUY2()
PixieDust(2)
ConvertToYV12()
LimitedSharpenFaster(2)

I downloaded the newest DGIndex and the .dll and CCE accepts it without issue. So it looks like DirectShowSource was the culprit.

And strangely, it looks great on the above source, which DGIndex says is interlaced. I thought the fields had to be separated but apparently not.

Thanks for all the help. :)

Melanchthon
29th July 2006, 19:36
I get a weird error using this with RemoveNoiseMC's lq_filter. The script runs, but the output is messed up. Sometimes the top half of the frame is tinted green and the bottom half is greyscale, and sometimes the chroma and luma don't match up. The latter looks a little like something that sometimes happened with Soothe, when it was possible for the two used clips to have different resolutions.

SeeSaw seems to be the key to the problem -- commenting out lq_filter but leaving the 'import SeeSaw' line active results in the output of what I think might be the LimitedSharpen mask. I'm not sure which thread it should go in, but since it's LimitedSharpen that's having problems I'll put it here.

Heini011
29th July 2006, 19:59
Hi Melanchthon,

keep mod 8 sizes and use YV12 colorspace!

Melanchthon
29th July 2006, 22:58
keep mod 8 sizes and use YV12 colorspace!
*smacks forehead* Yes, I was cropping just before LS. Thank you.

*edit* Hmm, still isn't working. Come to think of it, that can't be the mask. Pic. (http://img97.imageshack.us/my.php?image=greenkv9.jpg)
*edit again* I copied the version of LimitedSharpen off the very first page of the thread and that works fine.
*and again...* And now it doesn't, even though all I changed was some parameters on another filter. I now have no idea what is going on.
*one last time* I copied everything over to a new avs file and resolved the dependencies as they came up, and I also changed a couple of the lines in RemoveNoiseMC.avs (changed xxxx.dll to xxxxS.dll). The new script no longer requires the 'import SeeSaw' line, and runs smoothly from beginning to end. So everything is fine now, although I still don't know much about the exact problem or its solution.

shaolin95
30th July 2006, 10:26
Sorry for the stupid Q but if I am reading right, limited sharpen is not for live dvd playback but dvd backsups that are already deinterlaced? If that is so then that could be the reason I get those weird artifacts (line warp?). Can you please direct me to a guide on how to deinterlace a dvd? Ive been reading around but avisynth is a very complex beast indeed.
Thanks for your help.

PS BTW, I use a 7900GTX and Theater Tek 2.3 running ffdshow of course and to be honest I dont really see any interlaced issues...perhaps TT takes care of it?

RogueSquadron
30th July 2006, 20:16
you can use any of the deinterlacing filters in ur script[provided u have the dlls in ur directory], and call it as soon as u load the source, and yes LS can be used for real time playback

ben8778
1st August 2006, 04:48
Can you please direct me to a guide on how to deinterlace a dvd?

Decomb Guide (http://www.doom9.org/index.html?/decomb.htm) might help, but if you search a bit more, there are better solution then Decomb.

LS can be used for real time playback

I do not think LimitedSharpen (or LimitedSharpenFaster) is ideal for Real Time Playback.

shaolin95
1st August 2006, 05:12
I can use Limited Sharpen real time as long as I use x and y 1.0 instead of the normal 1.5x. Still, the artifacts are annoying. I am sure I am doing something wrong. BTW, according to TheaterTek info screen when the movie starts the Title screen shows is a 29.xx fps but when the actual movie starts it shows 23.9xxx so I assume that TheaterTek is actually taking care of the ivtc right? If that is so then I shouldnt have issues with LS.

foxyshadis
1st August 2006, 05:30
It depends on where the ivtc in applied in relation to the sharpening. If you're loading a script with the source and LSF applied in it, you're doing it pre-ivtc and it won't work. I have no idea how theatertek works, so I can't really help.

You'd better really like sharpness over dct artfacts though, because LS brings them all right into focus.

shaolin95
1st August 2006, 06:48
Perhaps thats why I am getting those "wavy" vertical lines? How is it that you guys are using it for real time dvd playback and not getting the wavy line?
Thanks for the help

Pookie
1st August 2006, 07:33
Perhaps thats why I am getting those "wavy" vertical lines? How is it that you guys are using it for real time dvd playback and not getting the wavy line?
Thanks for the help

Post a screen capture of the "wavy" vertical lines.- use one of the free image posting services - http://fileserver1.jpghosting.com or any other that you prefer. Use .PNG file format.

Again - why frustrate yourselves trying to add LimitedSharpen in realtime playback ? Just because you can doesn't always mean you should. You're going to spend the whole time keeping your fingers crossed that you don't stutter out during a complicated scene.

Audionut
1st August 2006, 08:00
With default settings. (limitedsharpenfaster)
On my AMD 3500 I get some stuttering.
With my P4 3.2Ghz HT @ 3.65Ghz, I get no stuttering. 20-35% CPU usage.

foxyshadis
1st August 2006, 09:01
With the Merom, I resize by spline up to 800x600, use Levels, DegrainMedian, LSF, Warpsharp, and Deband, and get 80% usage with D1-sized AVC video. :p Obviously I really like my sharpness, after years of fuzziness, I guess he might too.

See, but once you start doing that you start noticing how terrible your old encodes are, and start wishing you had the power to run mvdegrain or frfun7 in realtime. Now that would be quite a trick.

shaolin95
9th August 2006, 06:10
Post a screen capture of the "wavy" vertical lines.- use one of the free image posting services - http://fileserver1.jpghosting.com or any other that you prefer. Use .PNG file format.

Again - why frustrate yourselves trying to add LimitedSharpen in realtime playback ? Just because you can doesn't always mean you should. You're going to spend the whole time keeping your fingers crossed that you don't stutter out during a complicated scene.
Limited Sharpen works great for me now real time. My problem was that I needed to resize before or inside the LS call script. If I use ffdshow resize after LS then I get the wavy lines. This sharpener is amazin to say the least although I am having a hard time between LS and Seesaw.

aNToK
22nd August 2006, 21:50
Hi all! I've been using AviSynth for awhile now for cleaning up and adjusting avi and mpeg sources for archiving (mostly asian drama series that I subtitle) I'm far from an expert with Avisynth, but I'm somewhat proficient for general stuff.

This function is one I've long wanted to try out, as a huge problem of mine has been sharpening vid without adding a grainy or halo effect. After going through the 29 pages of this thread, I'm more confused than ever about which dll versions, script, etc. go together. Is there already or could someone list the requirements for limitedsharpen and limitedsharpenfaster? The ones in the first post seem to be outdated, and the ones further in the thread don't seem to be organized in any way I can understand.

I appreciate any help anyone is willing to offer!!

krieger2005
22nd August 2006, 22:00
http://www.avisynth.org/mediawiki/wiki/LimitedSharpen should help.

shaolin95
22nd August 2006, 23:26
Hi all! I've been using AviSynth for awhile now for cleaning up and adjusting avi and mpeg sources for archiving (mostly asian drama series that I subtitle) I'm far from an expert with Avisynth, but I'm somewhat proficient for general stuff.

This function is one I've long wanted to try out, as a huge problem of mine has been sharpening vid without adding a grainy or halo effect. After going through the 29 pages of this thread, I'm more confused than ever about which dll versions, script, etc. go together. Is there already or could someone list the requirements for limitedsharpen and limitedsharpenfaster? The ones in the first post seem to be outdated, and the ones further in the thread don't seem to be organized in any way I can understand.

I appreciate any help anyone is willing to offer!!
I would try Seesaw first if I were you...I already made the change too.

aNToK
23rd August 2006, 00:00
Hmm.. once I get Limitedsharpen figured out, I'll give Seesaw a try as well. I copied the .dll's for masktools, the sse3 ones for removegrain (removegrainsse3,repairsse3,rsharpensse3, and sse3tools) and avsfilter, loadpluginex, and warpsharp from the warpsharp package to my avisynth plugins folder, as well as adding the contents of the limitedsharpenfaster avs into the avs file for my video and came back with a "no mt_edge" function error. I must be doing something wrong.

Am I supposed to copy the entire contents of the limitedsharpen avs file into mine or am I supposed to copy that avs into my plugins directory? Is there some sort of call feature I'm supposed to use?

I also noticed that the limitedsharpenfaster avs says to use removegrain v0.9, but it later references using the 1.0 beta version. Is that why the mt_edge thing isn't loading?

I'm not at all familiar with any of the call functions, etc. mentioned in the seesaw one (where to put which files, let alone how to script it...)

aNToK
23rd August 2006, 00:03
Guess I should mention that I'm trying to use this in the chain after filtering with degrainmedian and fft3d and the blockoverlap function. That part works well, so I'm hoping to finish off with a bit of sharpening on the results.

shaolin95
23rd August 2006, 00:05
Check here for the same problem and solution;
http://forum.doom9.org/showthread.php?p=794255#post794255

aNToK
23rd August 2006, 00:26
Thanks for the fast replies! I've got 4 different series I'm working on right now, and two are in desperate need of denoising and sharpening. Is there a newbie guide somewhere to learn about call functions, etc. and how to call different .avs files as functions like Limitedsharpen and seesaw? I'm all up for doing my homework, but whenever I try following the threads I seem to be a bit over my head.

Backwoods
23rd August 2006, 04:57
Trial and error.

foxyshadis
23rd August 2006, 16:28
No, not trial and error, but the wiki's main page includes several pages dedicated to learning your way around avisynth, like importing and calling functions. (The documentation that comes with avisynth is culled from it, though it's almost a year old now.)

Learning to use them effectively, that part's trial and error (along with picking up interesting calls others use).

aNToK
24th August 2006, 08:16
@jeremy: thanks for the step-by-step. LimitedSharpen worked very nicely, though I got an error with Spresso (yv12lutxy as an invalid function), and I haven't been able to figure out the a clip portion, but I'll do some more research before bugging anyone here about it.

Does Soothe work with LimitedSharpen or only with SeeSaw?

Jeremy Duncan
24th August 2006, 08:44
Your missing the Masktools.dll

frednerk33
24th August 2006, 12:44
sorry, snipped to another thread http://forum.doom9.org/showthread.php?p=867351#post867351 asking about SPresso

foxyshadis
24th August 2006, 23:14
Jeremy, could you make a thread starting with this (like your thread on avsforums) so that it can be stickied or at least referenced each time someone asks, that way this information isn't cluttering up all of Didée's sharpening threads? All of this realtime playing and multithreading business is really pretty off-topic for them (and a number of posts spawned by these discussions should really be in the newbies forum).

Jeremy Duncan
9th September 2006, 22:38
Here's a Walkthrough for Limitedsharpenfaster.
Link. (http://forum.doom9.org/showthread.php?t=115727)

drakend
9th January 2007, 10:07
Hello,
can someone post here in the forum the latest version of LimitedSharpenFaster() function as the mediawiki is down? :(

HeadBangeR77
13th January 2007, 15:28
Here you are ;) This is what I've recently downloaded with one of the AviSynth plugins, and it's working :D


# LimitedSharpen() ( a modded version, 29 Oct 2005 )
#
# A multi-purpose sharpener by Didée
#
#
# Changes in this mod:
#
# - RemoveGrain >= v0.9 IS REQUIRED!!
# ==================================
#
# - Smode=4 / sometimes does the magic ;-)
# - a separate "undershoot" parameter, to allow for some line darkening in comic or Anime
# - Lmode=3 / on edges, limited sharpening with zero OS & US. On not-edges, limited sharpening with specified OS + LS
# - "soft" acts different now: no more boolean true/false, but instead integer 0 - 100 (or -1 -> automatic)
# instead of blurring before finding minima/maxima, it now softens the "effect-of-sharpening"
# - edgemode=-1 now shows the edgemask. (scaling still not implemented :p )
#
## - MODIFIED version using MaskTools 2.0

function LimitedSharpenFaster( clip clp,
\ float "ss_x", float "ss_y",
\ int "dest_x", int "dest_y",
\ int "Smode" , int "strength", int "radius",
\ int "Lmode", bool "wide", int "overshoot", int "undershoot",
\ int "soft", int "edgemode", bool "special",
\ int "exborder" )
{
ox = clp.width
oy = clp.height

Smode = default( Smode, 3 )
ss_x = (Smode==4)
\ ? default( ss_x, 1.25)
\ : default( ss_x, 1.5 )
ss_y = (Smode==4)
\ ? default( ss_y, 1.25)
\ : default( ss_y, 1.5 )
dest_x = default( dest_x, ox )
dest_y = default( dest_y, oy )
strength = (Smode==1)
\ ? default( strength, 160 )
\ : default( strength, 100 )
strength = (Smode==2&&strength>100) ? 100 : strength
radius = default( radius, 2 )
Lmode = default( Lmode, 1 )
wide = default( wide, false )
overshoot = default( overshoot, 1)
undershoot= default( undershoot, overshoot)
softdec = default( soft, 0 )
soft = softdec!=-1 ? softdec : sqrt( (((ss_x+ss_y)/2.0-1.0)*100.0) ) * 10
soft = soft>100 ? 100 : soft
edgemode = default( edgemode, 0 )
special = default( special, false )
exborder = default( exborder, 0)
#radius = round( radius*(ss_x+ss_y)/2) # If it's you, Mug Funky - feel free to activate it again
xxs=round(ox*ss_x/8)*8
yys=round(oy*ss_y/8)*8
smx=exborder==0?dest_x:round(dest_x/Exborder/4)*4
smy=exborder==0?dest_y:round(dest_y/Exborder/4)*4

clp.isYV12() ? clp : clp.converttoyv12()

ss_x != 1.0 || ss_y != 1.0 ? last.lanczosresize(xxs,yys) : last
tmp = last

edge = mt_logic( tmp.mt_edge(thY1=0,thY2=255,"8 16 8 0 0 0 -8 -16 -8 4")
\ ,tmp.mt_edge(thY1=0,thY2=255,"8 0 -8 16 0 -16 8 0 -8 4")
\ ,"max") .mt_lut("x 128 / 0.86 ^ 255 *") #.levels(0,0.86,128,0,255,false)

tmpsoft = tmp.removegrain(11,-1)
dark_limit1 = tmp.mt_inpand()
bright_limit1 = tmp.mt_expand()
dark_limit = (wide==false) ? dark_limit1 : dark_limit1 .removegrain(20,-1).mt_inpand()
bright_limit = (wide==false) ? bright_limit1 : bright_limit1.removegrain(20,-1).mt_expand()
minmaxavg = special==false
\ ? mt_average(dark_limit1, bright_limit1)
\ : mt_merge(dark_limit,bright_limit,tmp.removegrain(11,-1),Y=3,U=-128,V=-128)

Str=string(float(strength)/100.0)
normsharp = Smode==1 ? unsharpmask(strength,radius,0)
\ : Smode==2 ? sharpen(float(strength)/100.0)
\ : Smode==3 ? mt_lutxy(tmp,minmaxavg,yexpr="x x y - "+Str+" * +")
\ : mt_lutxy(tmp,tmpsoft,"x y == x x x y - abs 16 / 1 2 / ^ 16 * "+Str+
\ " * x y - 2 ^ x y - 2 ^ "+Str+" 100 * 25 / + / * x y - x y - abs / * + ?")

OS = string(overshoot)
US = string(undershoot)
mt_lutxy( bright_limit, normsharp, yexpr="y x "+OS+" + < y x y x - "+OS+" - 1 2 / ^ + "+OS+" + ?")
mt_lutxy( dark_limit, last, yexpr="y x "+US+" - > y x x y - "+US+" - 1 2 / ^ - "+US+" - ?")

Lmode==1 ? mt_clamp(normsharp, bright_limit, dark_limit, overshoot, undershoot) : last

normal = last
zero = mt_clamp(normsharp, bright_limit, dark_limit, 0,0)

Lmode==3 ? mt_merge(normal,zero,edge.mt_inflate()) : normal

edgemode==0 ? last
\ : edgemode==1 ? mt_merge(tmp,last,edge.mt_inflate().mt_inflate().removegrain(11,-1),Y=3,U=1,V=1)
\ : mt_merge(last,tmp,edge.mt_inflate().mt_inflate().removegrain(11,-1),Y=3,U=1,V=1)

AMNT = string(soft)
AMNT2 = string(100-soft)
sharpdiff=mt_makediff(tmp,last)
sharpdiff2=mt_lutxy(sharpdiff,sharpdiff.removegrain(19,-1),
\ "x 128 - abs y 128 - abs > y "+AMNT+" * x "+AMNT2+" * + 100 / x ?")

soft==0 ? last : mt_makediff(tmp,sharpdiff2)

(ss_x != 1.0 || ss_y != 1.0)
\ || (dest_x != ox || dest_y != oy) ? lanczosresize(dest_x,dest_y) : last

ex=blankclip(last,width=smx,height=smy,color=$FFFFFF).addborders(2,2,2,2).coloryuv(levels="TV->PC")
\.blur(1.3).mt_inpand().blur(1.3).bicubicresize(dest_x,dest_y,1.0,.0)
tmp = clp.lanczosresize(dest_x,dest_y)

clp.isYV12() ? ( exborder==0 ? tmp.mergeluma(last)
\ : mt_merge(tmp,last,ex,Y=3,U=1,V=1) )
\ : ( exborder==0 ? tmp.mergeluma(last.converttoyuy2())
\ : tmp.mergeluma( mt_merge(tmp.converttoyv12(),last,ex,Y=3,U=1,V=1)
\ .converttoyuy2()) )

(edgemode!= -1) ? last : edge.lanczosresize(dest_x,dest_y).greyscale

return last
}



PS. I've just discovered it's included in the last MaskTools package (2.0a30) - LSF dated 21.01.2006.

check
7th February 2007, 03:48
the 'special' switch is interesting. How would I go about changing lsf so that it works in reverse? I was playing around with it on some anime (having not read the info about it), and it produced almost the opposite effect I was looking for ;-)

HeadBangeR77
7th February 2007, 04:16
the 'special' switch is interesting. How would I go about changing lsf so that it works in reverse? I was playing around with it on some anime (having not read the info about it), and it produced almost the opposite effect I was looking for ;-)
I've played with it too, though it's probably still treated as 'experimental'. ;) It gave me sort of brightening, yet such a description is rather simplistic.

If we made a 'wishlist' of requested features, then working with output resolution is already on the 1st place (:D), so that SS factor wouldn't change while resizing with LS(F).

QQ
22nd February 2007, 08:56
i'm sorry if this is a stupid question, but is it possible to simply use this sharpening for playback of videos in any dshow player..? perhaps combined with ffdshow or smth like that..

foxyshadis
22nd February 2007, 10:33
Of course! It's discussed in this thread, but 30 pages is certainly a lot to wade through. But Jeremy Duncan put together a pretty good tutorial on how to set it up, now bumped to the second page: http://forum.doom9.org/showthread.php?t=115727

Morte66
22nd February 2007, 17:16
I'm interested in using LimitedSharpenFaster() and Soothe() multithreaded with MT(), which splits the picture into two halves and feeds one to each core. MT() allows you to pad the two halves with an overlap, so filters that don't process to the edges of their input won't show a discontinuity at the join. So I'm wondering how LSF/Soothe handles this. I tried to work it out from the code, but I came over all dizzy...

If it matters, I'm using something like:
function LSFS (clip c) {
nonsharpened=c
sharpened=c.limitedsharpenfaster(edgemode=1,strength=100)
soothe( sharpened, nonsharpened )
return last
}

#some source

MT( "LSFS ()", 2, 8 )

Any info would be appreciated...

tsp
22nd February 2007, 22:57
Morte66: Well MT just does something like script:

function LSFS (clip c) {
nonsharpened=c
sharpened=c.limitedsharpenfaster(edgemode=1,strength=100)
soothe( sharpened, nonsharpened )
return last
}

src=some source
left=src.crop(0,0,src.width/2+8,src.height).LSFS()
right=src.crop(src.width/2-8,0,src.width/2+8,src.height).LSFS()
stackhorizontal(left.crop(0,0,src.width/2,src.height),right.crop(8,0,src.width/2,src.height))

left and right are handled by each core. LimitedSharpen just sharpen each part. You only needs to pad 3 pixels because that is how many neighbour pixel that are need for lanczosresize at the border.

Morte66
23rd February 2007, 00:20
You only needs to pad 3 pixels because that is how many neighbour pixel that are need for lanczosresize at the border.

Thanks, that was the bit I needed to know. :)

outcomes
18th March 2007, 04:41
where can i download this?

Shinigami-Sama
18th March 2007, 04:49
it should be posted in various locations of the thread; or atleast last time I checked it was

outcomes
18th March 2007, 05:06
it should be posted in various locations of the thread; or atleast last time I checked it was

I got it...no worries ...thanx !

esix
29th April 2007, 00:45
LoadPlugin("F:\encode.filters.take1\MaskTools.dll")
LoadPlugin("F:\encode.filters.take1\TIVTC.dll")
LoadPlugin("F:\encode.filters.take1\TDeint.dll")
LoadPlugin("F:\encode.filters.take1\DegrainMedian.dll")
LoadPlugin("F:\encode.filters.take1\ColorMatrix.dll")
LoadPlugin("F:\encode.filters.take1\TomsMoComp.dll")
LoadPlugin("F:\encode.filters.take1\RemoveGrainSSE2.dll")
LoadPlugin("F:\encode.filters.take1\DGDecode.dll")
#see saw BEGIN
LoadPlugin("F:\encode.filters.take1\SeeSaw\MaskTools-v1.5.8\MaskTools.dll")
LoadPlugin("F:\encode.filters.take1\SeeSaw\DenoiseSharpen.dll")
LoadPlugin("F:\encode.filters.take1\SeeSaw\RepairSSE2.dll")
LoadPlugin("F:\encode.filters.take1\SeeSaw\RSharpenSSE2.dll")
#see saw END
Import("F:\encode.filters.take1\LimitedSharpenFaster.avsi")
Import("F:\encode.filters.take1\Soothe.avsi")
Import("F:\encode.filters.take1\SeeSaw\SeeSaw_2006.01.02\SeeSaw.avs")

# SOURCE
MPEG2Source("E:\Kelly Clarkson-Behind These Hazel Eyes (MV) 1080i-CtrlHD.d2v")

# IVTC TIVTC
tfm().tdecimate()

TDeint( mode = 2 ).DeGrainMedian( mode = 1, interlaced = false ).DeGrainMedian( mode = 0, interlaced = false )
ColorMatrix( )
LanczosResize( 1280, 720 )
LimitedSharpenFaster( dest_x = last.width, dest_y = last.height, Smode = 3, strength = 250, radius = 2, Lmode = 1, wide = false, overshoot = 1 )


The Original with ColorMatrix() and LanczosResize() on it:
http://img95.imageshack.us/img95/3406/a1todayio2.th.png (http://img95.imageshack.us/my.php?image=a1todayio2.png)
The Result with lsf()
http://img216.imageshack.us/img216/2081/a2todayzj9.th.png (http://img216.imageshack.us/my.php?image=a2todayzj9.png)

What can I do to make it more sharper? I've tried applying lsf().lsf() but the result is fuzzy

Didée
2nd May 2007, 12:15
What's up? Your source comes along as High Definition, which is advertised as "crystal clear", "real as life", and whatnotever ... so it's already in the best possible quality! Why do you want to sharpen up such a brilliant source?

:D :D


Well ... Turning such fuzzy sources into "beautifully sharp" ones is difficult. And requires a lot of fiddling-around. And sometimes it just won't.

Chaining multiple instances of LimitedSharped is one possibility to try. If doing so, try to:

- start with UnsharpMasking (Smode=1) /w some bigger radius
- follow with UnsharpMasking /w smaller radius
- end up with 3x3-kernel sharpening (Smode=2/3/4)
- - for all instances:
- - do use the "soft=xx" parameter (!) , and/or reduce the strength for each instance


Basic example:

source
LSF(ss_x=1.0, Smode=1, Lmode=3, radius=4, strength=160, soft=100)
LSF(ss_x=1.0, Smode=1, Lmode=1, radius=2, strength=96, soft=75)
LSF(ss_x=1.5, Smode=3, Lmode=1 strength=150, soft=75)
LSF(ss_x=1.0, Smode=3, Lmode=1 strength=51, soft=51)

The values for strength/soft are from the guts and may be quite off, you have to tweak them around.
Eventually, it's benefitial to add "edgmode=1" to some of the inner or later instances ...

BTW, this kind of "multi-radius-sharpening" is what iiP() actually is doing, which could also be worth a try.

No promise that this route of processing will work out. Fiddling is what is needed, and perhaps another way than this one would be better.
Compare also this thread (http://forum.doom9.org/showthread.php?t=125204) - Chainmax is fighting a similar case. Kind of, at least.

safi
11th June 2007, 22:05
i'm new, and i want to know how to use LimitedSharpenFaster with megui for dvd rips-xvid?

J_Darnley
12th June 2007, 00:38
Go to the edit tab of the AviSynth Script Creator of MeGUI (or use a text editor) and then Import the LSF script and use it where you want. Or do you need to know how to use it?

Import("X:\Path\to\LSF script\LimitedSharpenFaster.avs")
LimitedSharpenFaster()

shadowhaze
10th July 2007, 03:55
Another great program (:thanks: Didée), but I keep getting an error :mad: when I close the progam using any script containing LSF:
(program).exe Application Error - The Instruction at "0x39797a8" referenced memory at "0x011eb40". The memory could not be "read". (see attached jpg)
If I take LSF out of my script - the problem disappears.

It doesn't matter whether it's AsvP, VD, VDMod, HCenc or Media Player Classic. I always get the same error when closing the program.

Didée or anyone else, please help. My vidoes just don't look as good without LSF. I tried seesaw & got a similar error (The Instruction at "0x10097a8" referenced memory at "0x018a3b08". The memory could not be "read".) I then unistalled & re-installed avisynth (latest ver.) along with all the external plugins, but that didn't fix the problem. FYI - I running XP home SP2 w/ an AMD Athlon X2 AM2 & 1GB of ram.

Thanks

~bT~
10th July 2007, 04:05
^ i had the same problem, got rid of aWarpSharp.dll to sort it.

shadowhaze
10th July 2007, 21:43
^ i had the same problem, got rid of aWarpSharp.dll to sort it.

Thanks for the idea, but for some reason it doesn't work for me :mad::mad::mad: This is so incredibly frustrating. I've got a ton of stuff I'd like to transfer to DVD.

While I didn't delete the file, I did remove it out of the AviSynth folder altogether & put it in a plugin back up folder in my doc.

What did you do exactly? How did you figure out it was aWarpSharp.dll? Should I uninstall/reinstall avisynth & the plugins again? At this point, I thinking of removing every plugin one by one (I've got alot) I keep testing.

Thanks again for your help and let me know if you have any other ideas or if I missed this somehere in the thread or forum (I've got the same problem w/ seesaw).

Didée
10th July 2007, 22:26
Hmh. Do you load any "SSE3" DLLs (RemoveGrainSSE3.dll, RepairSSE3.dll), or have those merely present in the plugins folder? If so, remove those DLLs completely, and use the "SSE2" variants.

shadowhaze
11th July 2007, 02:31
Hmh. Do you load any "SSE3" DLLs (RemoveGrainSSE3.dll, RepairSSE3.dll), or have those merely present in the plugins folder? If so, remove those DLLs completely, and use the "SSE2" variants.

Didée,

THANK YOU!!! Everything works perfectly now. I never would have figured that out. All of my RemoveGrain dlls were SSE3. I deleted all of them, downloaded v0.9 & 1.0 again, and inserted only SSE2 dlls

I'm sure my processor can do SSE3 instructions (confirmed by CPU-Z) so I don't understand why that causes a problem, but right now I don't care. It works! Now I just have to work on using seesaw, compare to LSF, and spend the next few weeks :rolleyes: converting all my avi files to DVD.

Nikos
14th July 2007, 01:00
From http://avisynth.org/mediawiki/LimitedSharpen

Lmode int (0-3, default 0)
Lmode:
0 : No effect
1 : Clamp to over/undershoot.
3 : Zero over/undershoot on edges.

Where is the 2?
A litle explain what it does the Lmode?

foxyshadis
14th July 2007, 02:37
It's just a vestigal thing. 2 maps to 0 now.

Nikos
14th July 2007, 07:18
It's just a vestigal thing. 2 maps to 0 now.

Inside the script there are only Lmode==1 and Lmode==3.

Also the script from the wiki (http://avisynth.org/mediawiki/LimitedSharpen) for the LSF (http://avisynth.org/mediawiki/upload/2/2d/LimitedSharpenFaster.avs) is wrong in lines 52 and 53.
The wrong lines:
xxs=m(8,ox*ss_x)
yys=m(8,oy*ss_y)

The right lines:
xxs=round(ox*ss_x/8)*8
yys=round(oy*ss_y/8)*8

foxyshadis
14th July 2007, 12:08
Sure, and if you set it to anything else, it might as well be 0, or no effect. =p

Also, that's the definition for the m(int,float) function. I just like a cleaner script.

Nikos
14th July 2007, 12:46
Thank you foxyshadis for the reply, but the script (LSF) from the wiki give me error on line 52. I don't find m() function.

The script (LSF) from masktools-v2.0a30.zip run fine.

Another thing that i notice, you use spline36resize not Lanczos but its ok for me.

Didée
14th July 2007, 12:49
foxy: when using selfmade brownies like your modulo-function, you should also put them on the Wiki page (or include them in the script).
When an artless user just gets LSF & the needed plugins as stated, s/he is left up with a "there is no function named "m"" error ... and searching for "m()" might become an effort.

Nikos
14th July 2007, 17:35
From first page: (Thanks Didee)
Smode ("Sharpen mode")
1 = UnsharpMask() [from WarpSharp.dll package]
2 = Sharpen()
3 = "MinMaxSharpen()" [private routine of LimitedSharpen]
Default is Smode=3. Change yourself if you prefer another one.

strength
Obviously, the strength of sharpening. For Smode=1, it can be 0~127 (simple sharpening), 128~255 (simple overdrive), 255~4096 (big overdrive).
For Smode=2, values 0~100 are handled over to Sharpen() as 0.0~1.0. Values >100 are mapped to 100.
For Smode=3, 0~100 is common, but 100~inf. can be used if necessary.
Default is strength=160 for Smode=1, and strength=100 for Smode=2|3.
I understand the strength limit on each mode.

On the wiki:
Smode int (1-4, default 3)
Sharpen mode:
1 : UnsharpMask
2 : Sharpen
3 : Range sharpening.
4 : nonlinear sharpening.

strength int = 160
Sharpening strength. Limited to 100 in Smode=2.
I don't understand the strength limit on each mode, but thanks anyway.

foxyshadis
15th July 2007, 00:45
Didn't I? ....oops. That was supposed to be at the end of the filter. Sorry about that.

Good call on the better explanation of sharpening.

Nikos
15th July 2007, 02:41
Thanks again foxyshadis for the valuable informations.

bjur
27th July 2007, 14:44
I have not read all 32 pages, but I'm using FFdshow and would also like to use LimitedSharpen, but can anyone please paste a quick guide with the needed plugins and the latest settings so I can get a good picture:)

I have Core 2 Duo E6600 2.4 GHz with GForce 7600.
Any help would really be appreciated.

salehin
10th August 2007, 00:26
I get a MeGUI error (cf. attachment). It occurs only when I open megui 1st time- not later (i.e., no such error if i close that d2v file and open another one without closing megui). I'm just wondering has it got something to do with the .dll file itself.

Following this (http://avisynth.org/LimitedSharpen#LimitedSharpenFaster), i got a file called LimitedSupport_09Jan06B.dll (just 297 bytes). Did i get the file properly. I'm aksing because if i click the link, it says that I don't have permission to access- but when i select 'save link as' i get that small .dll file.

My question: is this affectng the encode in anyway when I'm using LSF and Soothe (, both or LSF only)?

I'm using the followings (not exactly as suggested on avisynth.org):
Removegrain 1.0: from Wittmann's (http://www.removegrain.de.tf/)
Masktools2: alpha 31(stable) ---- from Manao's site (http://manao4.free.fr/MaskTools.htm),
Warpsharp [if using Smode=1]: same as avisynth.org (http://avisynth.org/warpenterprises/)
LimitedSupport: same link as avisynth.org <-- No LONGER NEEDED
Updated LSF.avsi: which comes with masktools2
Soothe.avsi: this one (http://forums.mvgroup.org/derefer.php?http://forum.doom9.org/showthread.php?p=784366#post784366)

Thanks for your time :)

foxyshadis
10th August 2007, 01:02
The "dll" you saved is really just an html error page. You can open it in notepad to see. :p You should delete it anyway, there's no need for it now that all the functions in it are part of masktools2.

salehin
14th August 2007, 17:13
I'm such a fool. I should have noticed that when i was unable to access the site.

Thanks a lot, foxyshadis ... working perfectly now :)

3ngel
11th September 2007, 22:10
@Didee
It was from sometime i was wondering what smode=4 would do and what was its principle.
I read on avisynth wiki that

smode=4 nonlinear sharpening

In what it is nonlinear?

In other words what is the curve results of this mode?

Thanks

Didée
11th September 2007, 22:40
http://img522.imageshack.us/img522/1599/smodefournx7.png (http://imageshack.us)

3ngel
11th September 2007, 23:07
If i've understood right the graph, comparing with that on first page, it's a more anticipated Lmode=1 but with an overall loss of brightness on the edges?
If not, can you do a graph like that on first page?
Thanks

Didée
18th September 2007, 10:54
You cannot compare ^that graph to the one on page 1. There's no relation to Lmode. Those two graphs show two different kind of things.

The graph on page 1 shows how the *limiting* works, i.e. how a pixel is treated once it has been sharpened.

The graph above shows how the *sharpening* of Smode=4 works. Blue is "linear" sharpening, i.e. if the sharpener calculated a change of x for a pixel, then the pixel is changed by x.

Smode=4 (pink) uses a gamma function to modify the calculated change. It's the very same principle as used in SeeSaw, only that there are no parameters for Spower/SdampLo (LimitedSharpen /w Smode=4 uses fixed values), and SdampHi is not used at all.

For Smode=4: if the blurring kernel yielded a change of 'x' for the current pixel, then the change that will be applied is:

16 * sqrt(|x/16|) * (x^2 / (x^2 +4)) * (-sign(x)) | (for strength=100)

McCauley
4th November 2007, 03:20
Hi,

i can't sleep, so i'll use this time to ask a question.
First i want to say thanks for all your fine scripts Didée, especially this one!

I use Limitedsharpenfaster mostly for downsizing 1080(i/p) stuff and found it more pleasing to replace Lanczos4resize with Spline36resize. With the new introduced Blackmanresize and Spline64resize resizers in Avisynth 2.5.8 i wanted to do some tests, but it's really annoying to fiddle around with multiple versions of this script.

My question is now, if somebody could show me how to exchange the Lanczos4resize calls used in the script with variables, so i can do some more testing, the first upsizing call should have a different parameter than the other three downsizing calls. If no parameter is given for the two different resizers, there should be a default.
It should be usable like this (for example):
Limitedsharpenfaster(upsize=blackman, downsize=spline64, strength=50)

Regards and thanks in advance
McCauley

foxyshadis
5th November 2007, 11:00
Replace the resizes by:
last.eval(upsize + "resize(" + string(xxs) + "," + string(xxy) + ")"
similar for the downsize.

If you want to play with the b/c in bicubic or the taps in lanczos, replace them by a call to a function which will perform the proper resize based on the name, instead.

It should be pretty obvious how to add new parameters with all of them up at the top, just add two more.

Didée
5th November 2007, 12:15
Function Resize( clip c,
\ int target_width, int target_height,
\ float "src_left", float "src_top",
\ float "src_width", float "src_height",
\ string "type",
\ float "b", float "c", int "taps", int "p" )
{
... some script code is missing here ...
}
Someone just needs to fill in the missing lines ... :)

Order of parameters is arguable, too. Full compliancy to the original resizer calls is hardly possible with such an all-in-one thingy, anyway. (Specifying parameters unnamed -> bicubic's b/c parameters, etc.)

Leak
5th November 2007, 13:57
Order of parameters is arguable, too. Full compliancy to the original resizer calls is hardly possible with such an all-in-one thingy, anyway. (Specifying parameters unnamed -> bicubic's b/c parameters, etc.)
Wouldn't it be cleaner to expect the user to define a function "LimitedSharpenResize" and call that with only a clip, width and height?

That way you could use whatever you want for resizing by defining the function appropriately.

Didée
5th November 2007, 14:40
Possible, but I already see the rookies whining why it doesn't work out of the box. Means that LS would have to define a default function, which the user has to override. Which requires that user's function is declared after LS has been imported -> next pitfall.

Perhaps better: the user has to manually supply an upsampled clip, which then is used for supersampled operations. Only if no upsampled clip is provided, LS upsamples internally.

KML
11th March 2008, 22:51
Hi friends this my first message on Doom9

@Didée
First thanks for LSF&SeeSaw
This is my script
LoadPlugin("C:\Program Files\GordianKnot\DGMPGDec\DGDecode.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\RemoveGrainSSE3.dll")
import("c:\Program Files\AviSynth 2.5\plugins\blinddehalo2.avs")
import("c:\Program Files\AviSynth 2.5\plugins\Soothe.avs")
import("c:\Program Files\AviSynth 2.5\plugins\LimitedSharpenFaster.avs")
LoadPlugin("c:\Program Files\AviSynth 2.5\plugins\MaskTools.dll")
LoadPlugin("c:\Program Files\AviSynth 2.5\plugins\mt_masktools.dll")
LoadPlugin("c:\Program Files\AviSynth 2.5\plugins\degrainmedian.dll")
LoadPlugin("c:\Program Files\AviSynth 2.5\plugins\RemoveGrainS.dll")
LoadPlugin("c:\Program Files\AviSynth 2.5\plugins\repairS.dll")
LoadPlugin("c:\Program Files\AviSynth 2.5\plugins\LimitedSupport_09Jan06B.dll")
mpeg2source("D:\TERMINATOR\audio\VTS_01_1.d2v")

crop(2,12,716,552)
LanczosResize(720,384)
DeGrainMedian(limitY=6,limitUV=6,mode=4)
dull= last
sharp= dull.limitedsharpenfaster(ss_x=2.0,ss_y=2.0,Smode=4,strength=140)
Soothe( sharp, dull, 50 )
Convolution3d("movieHq")
Undot()
blinddehalo2(2.0,2.0,105)

I want to use: ''ss_x=2.0,ss_y=2.0'' while 2pass encoding because ''ss_x=2.0,ss_y=2.0'' mode, reduces the squares in the picture.But I can't get the sharp result that I want.I'm increasing the strength but the result is the same what should I do?How can I get the most sharp picture with no halos and no squares?
If I should change my script what's your advice?

Nikos
12th March 2008, 00:07
Try this order:
blinddehalo2(2.0,2.0,105)
Undot()
DeGrainMedian(limitY=6,limitUV=6,mode=4)
Convolution3d("movieHq")
dull= last
sharp= dull.limitedsharpenfaster(ss_x=2.0,ss_y=2.0,Smode=4,strength=140)
Soothe( sharp, dull, 50 )

Ranguvar
12th March 2008, 01:08
I highly recommend DeHalo_alpha() over BlindDeHalo2().

leeperry
7th July 2008, 20:12
hi there,

I'm using the spline36 version of LSF in ffdshow, but the higher I set the SetMemoryMax, the more LSF sucks up :eek:

is there any point to go over 512MB(the default option) ?

like if I allocate 1300MB, does it do anything better/faster ?

it doesn't stutter at 512MB, though.

Didée
8th July 2008, 15:05
The more you specify, the more will be used by Avisynth for internal buffering/caching ... it's not LSF that "sucks up" the memory, it's Avisynth that starts to use all memory that you did allow to use, via SetMemMax.

Memory requirements of LSF are rather little ... with SD PAL input, it runs at "full speed" for me with sth like SetMemoryMax(16), and possibly even less than that. :)

yup
14th July 2008, 07:42
Hi all!
Advice parameter set for sharpening VHS analog capture movie (not anime). My source progressive and I use MVDegrain3 for denoising and image seeing little blury. Which kind mode prefer for this source 3 or 4?
With kind regards yup.

yup
15th July 2008, 12:13
Hi all one more!
Very difficult question?
I try
dull = last
sharp = dull.LimitedSharpenFaster(ss_x=3.0,ss_y=3.0,Smode=3,strength=100,wide=true)
Soothe( sharp, dull, 20 )
and not see improvement.
What I made wrong?
May be better way using TempGaussMC as postprocess instead Soothe?
yup.

foxyshadis
16th July 2008, 22:43
Way too much supersampling, which reduces sharpening! Stick to 1.3-2 in Smode 3 and 1.1-1.6 in Smode 4.

yup
17th July 2008, 06:10
foxyshadis!
:thanks:
I read at first post this thread:
ss_x, ss_y
As usual, these floats are the factors for supersampled operation. You'll hardly ever need to go higher than 2.0. For simple sharpening tasks, set these to 1.0 (no supersampling). Default is 1.5 each, however.
and try use big supersampling. I think my task not very simple.
One more :thanks:
yup.

PolaR ID
7th January 2009, 16:48
any idea why i get such error?
Script error: the named argument "soft" to LimitedSharpenFaster had the wrong type.

Leak
7th January 2009, 17:14
any idea why i get such error?
Script error: the named argument "soft" to LimitedSharpenFaster had the wrong type.
Why not tell us what you called it with? That way someone might actually spot the problem instead of having to guess...

(You did use a value between 0 and 100 for it, didn't you?)

np: Sigur Rós - Andvari (Takk...)

PolaR ID
7th January 2009, 19:58
Here is the script, I was trying to do simple test. I may doing something wrong but i don't know what i'm doing wrong.

MPEG2Source("C:\Documents and Settings\R4Z3R\My Documents\Rips\test.d2v", cpu=0)
Crop(10, 0, -8, -0)
LimitedSharpenFaster(ss_x=1.5, ss_y=1.5, dest_x=last.width, dest_y=last.height, Smode=3, strength=100, radius=2, Lmode=1, wide=false, overshoot=1, soft=false, edgemode=0, special=false, exborder=0)
Tweak(hue=5.0, sat=0.7, bright=0, cont=1.2)
LanczosResize(416, 320)

~bT~
7th January 2009, 20:42
^ why not just use LimitedSharpenFaster()

PolaR ID
7th January 2009, 20:52
Well, that way off curse it makes it easy to use LSF, but I want to know my mistake or what i'm doing wrong.

Leak
7th January 2009, 22:39
Well, that way off curse it makes it easy to use LSF, but I want to know my mistake or what i'm doing wrong.
(You did use a value between 0 and 100 for it, didn't you?)
For "soft" values of "it".

np: Butcher The Bar - Get Away (Sleep At Your Own Speed)

~bT~
8th January 2009, 01:42
Well, that way off curse it makes it easy to use LSF, but I want to know my mistake or what i'm doing wrong.
aren't u using the defaults anyway? i'm just guessing here but the parms do look like the defaults.

btw, Leak has pointed it out for you above where you went wrong.

MPEG2Source("C:\Documents and Settings\R4Z3R\My Documents\Rips\test.d2v", cpu=0)
Crop(10, 0, -8, -0)
LimitedSharpenFaster(ss_x=1.5, ss_y=1.5, dest_x=last.width, dest_y=last.height, Smode=3, strength=100, radius=2, Lmode=1, wide=false, overshoot=1, soft=0, edgemode=0, special=false, exborder=0)
Tweak(hue=5.0, sat=0.7, bright=0, cont=1.2)
LanczosResize(416, 320)

talen9
13th January 2009, 11:40
I suppose that's the default line inserted by AvsP :)

The preset (which you should be able to change, even if I just don't recollect how to) relates to an older version of LSF, where "soft" was a boolean ;)

andybkma
30th September 2009, 03:37
Hi, I'm new to the whole avisynth thing. I am just using AviSynth 2.58 in conjunction with newest ffdshow-tryouts & Zoom Player 7 Max in order to sharpen up any vids I watch. I was using a Dscaler sharpening filter but I find using LimitedSharpenFaster gives me a better picture on my projector. So am using these settings: LimitedSharpenFaster(ss_x=1.0,ss_y=1.0,Smode=3,strength=100,wide=true) but I find Zoom Player using so much more ram than before, up to 512Mb which seems a bit much. How can I limit LimitedSharpenFaster and Zoom Player from using so much ram? Would like to get it down to no more than 128Mb if possible. I tried putting

SetMemoryMax(128)
LimitedSharpenFaster(ss_x=1.0,ss_y=1.0,Smode=3,strength=100,wide=true)

in ffdshow but that had no effect on ram usage.

Thanks for any guidance for this noob, bkm

Edit: Made a new thread for this question as it seems this one is dead...

actarusfleed
3rd January 2010, 21:15
Hi there,
my question is very simple: Can we use together LSF + this motion flow script ?

SetMTMode(2,8)
multinum=2
multiden=1
mode=2
spar=0
pel=1
blkh=16
blkv=16
ffdShow_source()
super=MSuper(pel=pel,hpad=blkh, vpad=blkv, levels=4)
backward_vec1=MAnalyse(super, isb=true, blksize=blkh, blksizev=blkv, searchparam=spar, plevel=2, levels=4)
forward_vec1=MAnalyse(super, isb=false, blksize=blkh, blksizev=blkv, searchparam=spar, plevel=2, levels=4)
MBlockFps(super, backward_vec1, forward_vec1, num=FramerateNumerator(last)*multinum, den=FramerateDenominator(last)*multiden, mode=mode)
distributor()

When I install the DLLs that this script needs I install a avisynth.dll library in the folder "system32" in windows.

http://www.mediafire.com/?o1dccmm1l1t

The same thing happens when I've to install LSF.

So my question is: Is there a avisynth.dll that goes right for LSF and Motionflow script together?

Thank you,
actarus.

zmaster
8th November 2010, 12:38
Hi!
I have a small question: In order to make XXXResize(width*4, height*4) need to use ss_x=4.0, ss_y=4.0? (values of 4.0 give "width*4, height*4"?)

Of course, I read the first post (this and made me ask a question)However, the initially mentioned "speedy version" of 4*supersampled XSharpen'ing would look as simple as

LimitedSharpen( ss_x=2.0, ss_y=2.0, Smode=2)But when I look at the script work and the results obtained, it seems to me that 4x supersampling is done with the parameters 4.0. I do not understand what value should use for 4x supersampling? :confused:
p/s: nice script, it's fast ;)

Didée
10th November 2010, 14:11
> In order to make XXXResize(width*4, height*4) need to use ss_x=4.0, ss_y=4.0?

Yes.

The example was in reference to the old SSXSharpen script. 2*supersampled LimitedSharpen looks pretty much the same like 4*supersampled SSXSharpen, but runs much faster.

With 4*supersampled LimitedSharpen/Faster you'll get only very weak sharpening. The limiting neighborhood simply becomes too small with such big oversampling factors.

zmaster
10th November 2010, 18:14
Thanks!

Mounir
28th April 2011, 12:27
I'm testing Limitedsharpen currently and i have an issue it put the levels to 0-255, is there a parameter i am missing or it's a normal behaviour ?

the coding part:
LimitedSharpenFaster(ss_x=1.5,ss_y=1.5,Smode=4,strength=100,soft=-1,edgemode=1,wide=false)

Mounir
2nd August 2011, 14:49
Anyone? Why can't this filter keep the 16-235 limit

Didée
2nd August 2011, 22:53
Well ... take a clip that's strictly [16,235], make

lanczosresize(2*width,2*height).lanczosresize(width,height)

, see that the result does not obey TV levels anymore, and start wondering why a simple resize behaves like that.


Another one:

You have a TV levels clip that's strictly [16,235].

- there is a black line (Y=16) on a very dark background (Y=20).

- You perform LSF. What do you expect to happen? Sharpening makes the Y=16-line darker. Disallowing that, you basically can not sharpen that line at all. Making instead the neighborhood brighter means to create halos around the line. That's not good either.


So, what to do? Dilemma!


(The "special=true/false" switch of older LimitedSharpen versions was loosely related to this problem, but using special=true created .... ugly halos.)

Mounir
2nd August 2011, 23:21
Ok well the author should add in the title "not suited for dvd's and blu rays at all " this way that'll not mislead nobody.

I expect an option to limit the range at the very least but if you say it produce halo's then this filter is useless either ways.

Didée
2nd August 2011, 23:40
Oh, "not suited" and "useless"? I don't know what you are smoking, but you can always do

LSF().Limiter()

*.mp4 guy
3rd August 2011, 08:01
Ok well the author should add in the title "not suited for dvd's and blu rays at all " this way that'll not mislead nobody.

I expect an option to limit the range at the very least but if you say it produce halo's then this filter is useless either ways.Pushing small features outside of the limited range is harmless, which is why nobody worries about it. Range limitations are only an issue for frame wide contrast and such, as truncation of global contrast is harmful. Truncation of post sharpening deviations, whether explicitly or by the playback device is only harmful if you want to try to deconvolve the sharpening away later, in which case you shouldn't be sharpening anyway....

`Orum
29th April 2018, 03:03
Has anyone edited this filter to support high bit depth? If so, could you share it?

Otherwise I may do so myself as I'm in need of a sharpener with support for it, and this was one of my favorite sharpeners when I last used it.

real.finder
29th April 2018, 04:22
Has anyone edited this filter to support high bit depth? If so, could you share it?

Otherwise I may do so myself as I'm in need of a sharpener with support for it, and this was one of my favorite sharpeners when I last used it.

not completed yet https://forum.doom9.org/showthread.php?t=174752

SaurusX
29th April 2018, 22:24
I hate to even broach the subject, but now is as good a time as any. Is Didee no longer with us?

StainlessS
30th April 2018, 13:54
I hate to even broach the subject, but now is as good a time as any. Is Didee no longer with us?

Last post was 6 Dec 2015, Didee profile does not list last on-line date, some profiles do, some dont, dont know why (maybe governed by some privacy setting).

orion44
22nd June 2025, 23:48
On AviSynth's page for LimitedSharpen, there is an incorrect default value written for the "radius" parameter.

It is incorrectly written that the default value for the radius parameter is "radius=1", when it should be "radius=2".

http://avisynth.nl/index.php/LimitedSharpen

Could anyone edit this page and write the correct value?

FranceBB
23rd June 2025, 05:41
It is incorrectly written that the default value for the radius parameter is "radius=1", when it should be "radius=2".


Ooops, you're right, looking at the code it sure is 2

radius = default( radius, 2 )


Could anyone edit this page and write the correct value?

Updated. Thank you for spotting it and reporting it. :)