PDA

View Full Version : New filters: SharpTools and DetailIllusion


mf
23rd August 2003, 19:24
Hi there! :)


More slowass filters have reached into my AVS Dumpster :D.

SharpTools (http://nabeshin.ddo.jp/avisynth/SharpTools-v0.3.avs)
DetailIllusion (http://nabeshin.ddo.jp/avisynth/DetailIllusion-v0.1.avs)

My filters are self-documenting now (and parameters need little explanation), so I'll keep it short.

SharpTools: 2 filters - SharpResize() and SSXSharpen(), both using XSharpening for best results ^_^. I guess this kind of explains itself. If it doesn't, here's an SSXSharpen explanation (http://mf.onthanet.com/supersampled_xsharpen), and a Resize Comparison (http://nabeshin.ddo.jp/resizecomparison.png).

DetailIllusion: now here things are getting a little more complicated. This is an experimental filter to test out a theory, that I've been thinking of. It adds slight noise to detailed areas of the picture, so if there's a lack of detail (through smoothing or resizing) it will try to trick your subconscious into thinking there's more detail. The concept itself works okay imho, but I've noticed after encoding it works better, because the codec will compress the noise and (XviD will do this anyway) replace it by detail-approximating artifacts, one of the reasons we prefer XviD over RV9 or DivX5 ;). Feel free to test it yourself, this was simply a concept-test and for me it works pretty well, I'm testing it right now on a movie I've SharpResized from DVD resolution to 1024x432 (because of the resolution blowup a lot of detail (that was never there in the source) is missing). A final note, this works like turd on anime, so don't even try it ^^;.

Anyway, thanks everyone who's been using mfToon for encouraging me to write AVISynth in a way that everyone can use it.

Happy testing :).

yaz
26th August 2003, 17:22
@mf:
sure, i give it a try (as i rebuild my system hopelessly crashed) but ..

Originally posted by mf
DetailIllusion: ... It adds slight noise to detailed areas of the picture, so if there's a lack of detail (through smoothing or resizing) it will try to trick your subconscious into thinking there's more detail.
- can't get it. does it add noise to detailed or to smooth area? (my english is pretty weak:-)
- what is addnoise() in the script? the only thing occurs to me is blockbuster (having this name at born) do u still use that?
- can't blockbuster be tuned to do the task or u don't like bb?
- have u tried addgrain? i like the way it goes.
- why would help a size-up for doing this trick? (presuming, there comes a heavy size-down afterwards)

i luv your concept & i've experienced a lot with selective noising (which really helps to improve the overall look). so, no blame intended here :-)

the bests
y

PS
Originally posted by mf
... detail-approximating artifacts (one of the reasons we prefer XviD) ...whooa ... the best expression i've ever heard. for me, it is the main reason.

Didée
27th August 2003, 12:42
Hi mf!

Very fine tools, indeed.

Regarding SharpTools: Well, I feel a little "out-raced" ... Some time ago, I thought "hey, I should try an area sharpener with supersampling". But just before I actually found the time to sit down, you came up with v0.1 of your SharpTools ... must be some form of morphogenetic energy?

Regarding DetailIllusion: interesting concept (but the name looks very irritating in Arial script :) ).
One thing I don't like about the current implementation: it acts in the form "the harder the edge, the more noise we add". This is IMHO sub-optimal (but agreed, AviSynth's lack of curve adjustments makes it a pain to simulate exactly that).
The point is, it would be better to add the "noitail" only to the not-so-hard edges, speak: to the areas of soft detail, and to leave the very hard edges alone again, just like the flat areas.
As it is by now, it sometimes just looks like mosquito noise, and areas with lots of fine detail tend to look too "nerveous".

Your permission granted, I'll come up with a modification of DetailIllusion in the next few days ... unless you do it on your own again ;)

- Didée

mf
27th August 2003, 12:50
Originally posted by Didée
Hi mf!

Very fine tools, indeed.

Regarding SharpTools: Well, I feel a little "out-raced" ... Some time ago, I thought "hey, I should try an area sharpener with supersampling". But just before I actually found the time to sit down, you came up with v0.1 of your SharpTools ... must be some form of morphogenetic energy?

SSXSharpen is a VERY old idea. It dates back to more than a year ago. So, sorry :D.

Regarding DetailIllusion: interesting concept (but the name looks very irritating in Arial script :) ).
One thing I don't like about the current implementation: it acts in the form "the harder the edge, the more noise we add". This is IMHO sub-optimal (but agreed, AviSynth's lack of curve adjustments makes it a pain to simulate exactly that).
The point is, it would be better to add the "noitail" only to the not-so-hard edges, speak: to the areas of soft detail, and to leave the very hard edges alone again, just like the flat areas.
As it is by now, it sometimes just looks like mosquito noise, and areas with lots of fine detail tend to look too "nerveous".

Your permission granted, I'll come up with a modification of DetailIllusion in the next few days ... unless you do it on your own again ;)

- Didée
Well, I've had an idea when I first tested it (before I released it, yes :rolleyes:), to subtract the amplified (you can see I run a few sharpens before I make the edgemask, to amplify small edges) mask with the normal mask, to give hard edges a harder time (lame pun alert :D), but seeing that'd slow it down even more, I didn't do it. I could add it later :).

mf
27th August 2003, 13:46
Originally posted by yaz
@mf:

- can't get it. does it add noise to detailed or to smooth area? (my english is pretty weak:-)
- what is addnoise() in the script? the only thing occurs to me is blockbuster (having this name at born) do u still use that?
- can't blockbuster be tuned to do the task or u don't like bb?
- have u tried addgrain? i like the way it goes.
- why would help a size-up for doing this trick? (presuming, there comes a heavy size-down afterwards)

- It adds noise to detailed areas. If it added noise to flat areas, it would just look like film grain.
- AddNoise is one of SansGrip's filters - they were the only ones I could find when I looked for a noise filter.
- SansGrip's filter page is quite confusing. It looked like all filters did the same thing, so I just grabbed one randomly.
- I've just heard of it today, and I think I'll make a version 0.2 that uses it instead of AddNoise (AddNoise is legacy 2.0x anyway, so that's a good reason for not using it).
- You misinterpreted my words :). I meant that it works good if you're trying to make a small source bigger (like say you have a low-res VCD, and want to blow it up to DVD resolution, DetailIllusion might make it look better).

PS
whooa ... the best expression i've ever heard. for me, it is the main reason.
Thanks :cool:. But it's not about the expression, it's about the effect :).

yaz
27th August 2003, 14:59
@mf
thx! it's getting clear:-)

blockbuster: leave sansgrip's h.p., he's away:-(( the avs2.5 compliant version is at www.avisynth.org/~warpenterprises. it does really worth a try. last night i tried to implement your idea with it (& wout masking which is hella slow) it made sg but it was too late for a thorough test.
addgrain: trbarry's released a bugfix for that, see his h.p.!

the bests
y

mf
14th September 2003, 16:21
OK, since ppl don't seem to be so interested in my sharptools, I'll show you a nice horny screenshot of SharpResize() in action. This is as you might be able to recognize from Onegai Twins.
http://mf.creations.nl/hornyresize.png

Now is that nice or nice :D.

APF_Gandalf
17th September 2003, 00:40
I'll be interested if I could download it ;p
seems all the nabeshin.ddo.jp... links are dead.

mf
17th September 2003, 12:08
Oh yeah. Find them on http://mf.creations.nl/avs/functions/.

APF_Gandalf
17th September 2003, 19:56
thanks, I'll give it a try on my next encode

killerhis
23rd September 2003, 11:10
OK I've tested those filters.. dahm why didn't I do it before :D

Detailillusion.. don't like it yet.. not getting much detail back for that filesize.... sharpresize looks impressive, but still liking bilinearresize.. but SSXSharpen() whooo :p

Gives better results then awarpsharp and xsharp combined (my settings) and filesize is like only 0.5% bigger then with awarpsharp and xsharp... and as far I can see.. no more sharping artifacts on the edges..... I LOVE THIS FILTER.. maybe you get a new update soon.. with more paramerters and options :D

Maybe you can also get detailillusion working nice at lower bitrate :cool:

keep the job MF

Zarxrax
23rd September 2003, 20:32
I just tried the sharpresize and I must say, it's amazing! I doubt I will ever have a use for it, because I haven't seen low resolution files in ages, but still, its amazing :D
There's GOT to be some way to speed up the supersampling process though... or perhaps build an efficient supersampling method directly into xsharpen... or maybe some smart coder out there could find a way to reproduce the results of this without having to resort to supersampling. This is a powerful filter, I hope someone could look into it some more.

mf
24th September 2003, 12:48
Originally posted by Zarxrax
I just tried the sharpresize and I must say, it's amazing! I doubt I will ever have a use for it, because I haven't seen low resolution files in ages, but still, its amazing :D
There's GOT to be some way to speed up the supersampling process though... or perhaps build an efficient supersampling method directly into xsharpen... or maybe some smart coder out there could find a way to reproduce the results of this without having to resort to supersampling. This is a powerful filter, I hope someone could look into it some more.
There is an idea floating around for this (it was Gldm's idea). It's called the "piecemeal supersampler", which basically speeds up supersampling by sizing small pieces of the frame at a time, that fit into the processor cache. Moving around 7MB frames through the CPU is the main culprit for the slow speed. The pieces overlap for image quality. However, nobody's been interested in coding it.

Didée
24th September 2003, 15:19
... In fact, I started scripting this weeks ago, by the time I shouted to do something about detailIllusion.
In the meantime, I got heavily side-tracked by "Restore24". However, already with a simple 2*2 tiling, I got something like a 8% speed-up on my old Athlon700.
The problem is, the smaller you make the tiles, together with overlapping & additional function calls, the more overhead is produced at the same time.
Is overlapping really necessary? Depends on how XSharpen processes the borders - I didn't test that thoroughly.

- Didée

mf
24th September 2003, 17:41
I don't really think you can script this effectively in AVISynth. I'd like to know how you managed to do it though, as I'd say you need loops, which AVS doesn't have.

Didée
24th September 2003, 18:02
... with a simple 2*2 tiling ......and 4*4 tiling I tried as well, this is no magic at all: define the number of tiles, and with some calculations, do the cropping, upsizing, filtering, downsizing, and stacking.
Even a recursive function could be done, if you were thinking of something like that.
But you're perfectly right: It is not efficient to do all that by scripting, this should definetly be done by a nifty little plugin.
By scripting you will, from a certain point, loose more time through overhead than you are gaining from reducing the active processed frame size.
However, it was plain fun to try it - and as I said, it got indeed somewhat faster. Not by much, but if you send your PC to a 100-hours-encoding-journey, 8% gain are as much as one day office work ;) (And I do prefer the days I am NOT in office.)

- Didée

Didée
25th November 2003, 13:01
Diggin' out this thread ;)


@ mf

Technical question about XSharpen (WarpSharp.dll):

Do you know if it works just the same way as Donald's XSharpen for Vdub? 'Cause in my experience, these three XSharpens: *Vdub, *WarpSharp.dll, *ffdshow -- they all behave somewhat different...

My concern is: what size is the "window" that's running over the frame? Do you have any clue?

- Didée

mf
25th November 2003, 13:26
I believe the only differences (I can't code so I can't check out the source) between the different versions is:
VDub's XSharpen: works in RGB so the luma conversion might be different.
Japanese Warpsharp.dll: Works in YV12 only but is closest to the VDub version.
sh0dan's Warpsharp.dll: Has an assembly bug somewhere causing unoptimal results.
ffdshow's XSharpen: Don't know much, but I have a feeling this is the same one as sh0dan's warpsharp.dll.

Chainmax
25th November 2003, 20:22
What exactly is the difference between SSXSharpen and mfToon? Also, when is it better to use one over the other (barrying speed reasons)?

I don't seem to be able to view the resize comparison, how much sharper than lanczos is SSXResize? How do they compare speedwise?

mf
25th November 2003, 21:36
Resizecomparison is now up here:
http://mf.creations.nl/resizecomparison.png

mfToon is better when cartoon lines are vague and less-defined.
As for speed, try it yourself.

69Mws
26th November 2003, 11:35
Unfortunately the downloadlinks are down :(

I'm interested in sharpening-filters, as I resize avi's to a dvd-compliant size sometimes and hope to preserve as much detail as possible when "blowing up" the resolution.

Are there sharpening filters here especially designed for toons/anime or may the also be useful for non-animated sources?

Greetz
69Mws

P.S.: I use avs-scripts in combination with CCE and resize normally by using bicubicresize

mf
26th November 2003, 12:59
New downloadlinks:

http://mf.creations.nl/avs/functions/SharpTools-v0.3.avs
http://mf.creations.nl/avs/functions/DetailIllusion-v0.1.avs

Both were made with live action in mind as well (I tried them on The Matrix Reloaded).

69Mws
26th November 2003, 13:10
Thx :)

69Mws
27th November 2003, 12:41
whoa, those filters with all its parameters are giving me quite a headache (being a total noob when it comes to using filters in AviSynth :()

I definately need to do some more research..... :)

Greetz
69Mws

dbzgundam
12th December 2003, 16:44
I'm also having problems getting these to work. AVS keeps saying it cannot load the Sharpresize script. :mad:

And when I got it to work (I think) I was incredibly confused with how to use the parameters, sadly I too am unskilled with AVS. So if anyone can post the correct settings (I understand how it works, so if I knew how to script I could do it)

Upscale to 1128x480 (2.35:1)
Supersample @ 3.0
Xsharpen strength at 15 and threshold at 15

So if anyone can post a sharpresize script that I could just copy and paste into AVS PLEASE DO!

mf
12th December 2003, 16:56
sxsinput = last
targetwidth = 1128
targetheight = 480

sxsinput.LanczosResize(targetwidth*4, targetheight*4)
XSharpen(255, 255)
LanczosResize(targetwidth, targetheight)

There you go. :)

dbzgundam
12th December 2003, 17:56
THANKS! I just don't understand it looks like there is resize twice?

sxsinput.LanczosResize(targetwidth*4, targetheight*4) <---This

LanczosResize(targetwidth, targetheight <---- And this.

Wouldn't I only need the first one since it already has the Resize command in it? Also do I need Lanczos?

mf
12th December 2003, 19:04
Originally posted by dbzgundam
THANKS! I just don't understand it looks like there is resize twice?

sxsinput.LanczosResize(targetwidth*4, targetheight*4) <---This

LanczosResize(targetwidth, targetheight <---- And this.

Wouldn't I only need the first one since it already has the Resize command in it? Also do I need Lanczos?
Yes, that's also why it's called "supersampled". Anyway, you can replace "Lanczos" with anything else. Lanczos is just the sharpest.

Chainmax
14th December 2003, 21:22
I have a question regarding DetailIllusion: I'm going to make a sharpresized 1008x608 rip from my "Lion King" DVD. Since it's not exactly anime, is it a good idea to use DetailIllusion on it? If so, should I use it before or after the sharpresize?

mf
14th December 2003, 22:01
Originally posted by Chainmax
I have a question regarding DetailIllusion: I'm going to make a sharpresized 1008x608 rip from my "Lion King" DVD. Since it's not exactly anime, is it a good idea to use DetailIllusion on it? If so, should I use it before or after the sharpresize?
Bad idea. And the point is to use it after resizing.

clima
15th December 2003, 16:23
SharpResize() doesn't work with my mod16 input resolution.

720x480 :
Crop (Top:6,Left=4,Right=2,Bottom=10)
SharpResize(640,352)

And the error :


Avisynth open failure:
Filter Error: Attempted to request an YV12 frame that wasn't mod2 in widht and height!
(SharpTools-v0.3.avs, line37)
(gits.avs, line36)


I can't figure where the mod2 issue occurs o_O

mf
15th December 2003, 18:11
Clearly, something isn't mod4. Make sure it is.

Aiorus
15th December 2003, 18:23
well, after the cropping the resolution is Mod2, but not Mod4. You might want to check that

mf
15th December 2003, 18:36
Originally posted by Aiorus
well, after the cropping the resolution is Mod2, but not Mod4. You might want to check that
Nah, UVToY() requires mod4, alas. Not my fault.

Aiorus
15th December 2003, 21:13
By "you" I meant clima ^_~

mf
15th December 2003, 22:02
Originally posted by Aiorus
By "you" I meant clima ^_~
I didn't read the usernames well. To be honest, I thought you were the same person :D.

clima
19th December 2003, 08:25
No, I wouldn't behave like that :p

I was tricked by the mod2 in the error message.

Thx :)

dookie
26th December 2003, 04:16
here is the avs file I am using first off, the video isnt getting resized to the desired resolution. secondly, are the shaprness values set like msharper? I am getting pixilation on moving objects. Your help will be greatly apprecaite! thx


#PLUGINS
LoadPlugin("D:\SYSTEM~1\Gordian Knot\mpeg2dec3.dll")

#SOURCE
mpeg2source("V:\TEMP\DVD\Projects\test.d2v")

#CROPPING
crop(0,0,720,480)

##
## SharpTools by mf
##
## Contains sharpening filters and filters using sharpening techniques.
##
## Usage: Import("SharpTools-v0.1.avs")
##
## New in v0.3 (0.2 was internal test): chroma processing for SharpResize ^__^.
##


function SharpResize(clip input, int width, int height, int "xstren", int "xthresh", \
int "ssw", int "ssh", bool "chroma") {
##
## SharpResize
## Resizes while trying to maintain sharpness.
##
## Usage: SharpResize(640, 480)


## Parameters:
width = 1480
height = 960
xstren = 164
xthresh = 200
ssw = 3
ssh = 3
chroma = true
##

SharpResize(1480, 980)

input.ConvertToYV12()
input2 = last

input2.GreyScale()
LanczosResize(width*ssw, height*ssh)
XSharpen(xstren, xthresh)
LanczosResize(width, height)
y = last

input2.UToY()
LanczosResize(width*ssw, height*ssh)
XSharpen(xstren, xthresh)
LanczosResize(width, height)
u = last

input2.VToY()
LanczosResize(width*ssw, height*ssh)
XSharpen(xstren, xthresh)
LanczosResize(width, height)
v = last

input2.UToY()
LanczosResize(width, height)
u2 = last

input2.VToY()
LanczosResize(width, height)
v2 = last

fullproc = YToUV(u, v, y)
lumaonly = YToUV(u2, v2, y)

return chroma ? fullproc : lumaonly
}


function SSXSharpen(clip input, int "ssw", int "ssh", int "xstren", int "xthresh") {
##
## SSXSharpen
## Sharpens the picture using supersampling techniques.
##
## Usage: SSXSharpen()
##
## Parameters:
ssw = 4
ssh = 4
xstren = 164
xthresh = 200
##

input.LanczosResize(input.width*ssw, input.height*ssh)
XSharpen(xstren, xthresh)
LanczosResize(input.width, input.height)
}

mf
26th December 2003, 14:19
You need to just place the .avs in the same directory, and use Import("SharpTools-v0.3.avs") - then you can do SharpResize(1480, 980).

dookie
26th December 2003, 14:55
Thank you for your reply!

My new avs file is:


#PLUGINS
LoadPlugin("D:\SYSTEM~1\Gordian Knot\mpeg2dec3.dll")
LoadPlugin("D:\SYSTEM~1\Gordian Knot\undot.dll")

#SOURCE
mpeg2source("V:\TEMP\DVD\Projects\blah.d2v")

#CROPPING
crop(0,0,720,480)

#Import("SharpTools-v0.3.avs")

When i do File > open in virtualdubmod it gives me an error "Avisynth open failure: The script's return value was not a video clip"

Thx again,
dookie

Wilbert
26th December 2003, 15:33
1) Don't change (or add anything in) the "SharpTools-v0.3.avs". Download link is in the second post.

2) Change your script into:

#PLUGINS
LoadPlugin("D:\SYSTEM~1\Gordian Knot\mpeg2dec3.dll")
LoadPlugin("D:\SYSTEM~1\Gordian Knot\undot.dll")

Import("C:\SharpTools-v0.3.avs") # or whatever the correct path is

#SOURCE
mpeg2source("V:\TEMP\DVD\Projects\blah.d2v")

#CROPPING
crop(0,0,720,480)

SharpResize(1480, 980)

dookie
26th December 2003, 22:47
Thank you for the help :) I did what you told me. I downloaded the new SharpTools-v3.0.avs script and didn't make any changes anywhere in that script. Then I changed my main avs file, I copy/pasted the info you kinkly mentioned on your last post. However, I get an error Script error: there is no function named "XSharpen" (V:\TEMP\DVD\PROJECTS\SharpTools-v3.0.avs, line32) V:\TEMP\DVD\PROJECTS\blah.avs, line 14)

Line 32 on SharpTools-v3.0.avs is "XSharpen(xstren, xthresh)"; as for like 14 on blah.avs, there isn't anything there for that line. Do I need to specify XSharpen or any other filters in blah.avs(main) before executing another script? Also, is there a priority on the avs files? EX I noticed you put the SharpTools-v3.0.avs import above "mpeg2source." If that is true, and If I wanted to add DetailIllusion-v0.1.avs, I presume it would go right under "Import("V:\TEMP\DVD\Projects\SharpTools-v0.3.avs")" correct?

Thank You again!
dookie

Wilbert
27th December 2003, 00:28
You need the Xsharpen plugin (you got that message, because the plugins is not there). You can get it from:

http://www.avisynth.org/index.php?page=Section+3%3A+Filters%2C+plugins+and+colorspaces#q3.5

It's a filter in the Warpsharp-package in the misc plugins in Q3.5 (called Warpsharp.dll) (plugin no. 22). As stated, you also need to put those two dll's in your system-dir. You only need to put the warpsharp.dll in your autoloading AviSynth plugin-dir.

Also, is there a priority on the avs files? EX I noticed you put the SharpTools-v3.0.avs import above "mpeg2source."
Yes. You have to load the plugins first before you can use them, later on in final script. Then the scripts. Finally you load the source and apply the plugins/scripts:

#PLUGINS
LoadPlugin("D:\SYSTEM~1\Gordian Knot\mpeg2dec3.dll")
LoadPlugin("D:\SYSTEM~1\Gordian Knot\undot.dll")

Import("C:\SharpTools-v0.3.avs") # or whatever the correct path is
Import("V:\TEMP\DVD\Projects\SharpTools-v0.3.avs")

#SOURCE
mpeg2source("V:\TEMP\DVD\Projects\blah.d2v")

#CROPPING
crop(0,0,720,480)

SharpResize(1480, 980)

dookie
27th December 2003, 01:24
Amazing! got it to work, thx for your help mf and Wilbert!