Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 Doom9's Forum iip: Integrated Image Processor, e.g. DVD -> 720p HDTV
 Register FAQ Calendar Search Today's Posts Mark Forums Read

 15th February 2004, 20:35 #1  |  Link Didée Registered User   Join Date: Apr 2002 Location: Germany Posts: 5,390 iip: Integrated Image Processor, e.g. DVD -> 720p HDTV Hello folks, this is an early version of iip: integrated image processor. (I don't like the name too much, but didn't come up with a better one.) Its main purpose is upconversion from DVD resolutions to (pseudo-) HDTV resolutions. It should work, however, also for just processing at native input resolution, or even for traditional downsizing. The default parameters are chosen for upconversion, and probably should be adopted for smaller resolutions. This script aims at natural sources only! For animated/cartoon content, you are probably better of with mf's mftoon & sharpresize. I wrote this script for the following reasons: - after denoising a clip, much detail is attenuated also, or even gone away completely. - DVB broadcasting in Germany is often very poor, and this script is just what I needed for these sources. - plain fun of fiddling around So, what does it do exactly? - it will test your patience! 1. Basic denoising of the clip 2. Sharpen the picture up, excluding already hard edges to avoid oversharpening. This step can be done in a small supersampled stage, to get (a little) finer granularity. 3. Big Supersampling, applying Xsharpen for better edge definition. 4. Now search for edges again. Areas without edges get the original, denoised, not-sharpened picture applied. This should give the best relative compressability for any level of detail enhancement. The denoising is currently hard-coded to PixieDust. If you want to try any other denoiser, you must change the function itself for now - no hard job, its only one line in the function. However, in my opinion the dust filters still are offering the best ratio of "compressability/preserved detail", and that's why I've build the whole function around PixieDust. The basic usage looks like this: Code: LoadPlugin("path\to\undot.dll") # LoadPlugin("path\to\MaskTools_v1.4.9.dll") # These plugins LoadPlugin("path\to\WarpSharp.dll") # LoadPlugin("path\to\LoadPluginEx.dll") # are required! LoadPlugin("path\to\dustv5.dll") # Removed. See update on this thread's page 6! # As you see, there are quite some parameters to play around with. And you MUST play around with them. Everything depends in the quality of the input, the final resolution, your taste regarding image quality, and the bitrate you are willing to spend Parameter description dest_x, dest_y [int],[int] Obviously, these are specifying the final output resolution. duststr, dustweight, antiflicker [int],[float 0.0~1.0],[bool] duststr is the denoising level of PixieDust. default is 2, try 1~8 depending on how noisy the source is. dustweight: instead of using the "dusted" clip, you can mix it back with the raw input image by a percentage of dustweight. antiflicker: I had other plans for it. For now, it simply calms the picture further down by a weak temporalsoften(). See if you like it better on or off. ss1_x, ss1_y [float],[float] These are the supersampling factors for the following sharpening stage. Default is 1.4, try 1.0~2.0. With 1.0 the supersampling is discarded. detailcontr, contrast_radius, PreSharp [int],[int],[float] These are the values for detail enhancement. detailcontr is the strength of unsharp masking. Default is 112, try 40~80~160~255~512, this depends on the source quality and your taste. contrast_radius is the radius for unsharp masking. Default is 2, try 3 and 4 also. This correlated with the supersampling factors above. PreSharp is simply the value for a sharpen()-command after unsharp masking. Default is 0.8, try 0.0~1.0. NOTE: to completely disable detail enhancement, set detailcontr=0 and PreSharp=0.0 ss2_x, ss2_y [float],[float] These are the supersampling factors for the following Xsharpening stage. Default is 3.5 . For downsizing, go not under 4.0. For upsizing, 3.0 might be sufficient. Xstren, Xlimit [int],[int] These are the strength and limit factors for Xsharpen(). Default is (255,255). If you don't have the patience for big enough supersampling, e.g. for 2* supersampling only, try something like (128,23). do_subpel [bool] This envokes a sharpen(1.0) on the flat areas, and a blur(1.0) on the edges of the supersampled image, prior to XSharpen(). flatweight [int] At the very end, the denoised-but-not-sharpened original clip is copied back into the flat areas of the full-processed clip. Through flatweight you can control the strength of this copying process. "0" will return the calmest picture with best compressability. Try values 0~32~64~128. So, I suggest you play around with all the knobs, and see if you like it. AviSynth virtuosos might want to play with the levels() commands for the masks. In this area there is probably room for improvement - you are invited. perhaps upcoming features: - integrated deringing - perhaps a better flicker reduction Have fun - Didée __________________ - We´re at the beginning of the end of mankind´s childhood - My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!) Last edited by Didée; 22nd March 2005 at 12:50.
 15th February 2004, 20:38 #2  |  Link Didée Registered User   Join Date: Apr 2002 Location: Germany Posts: 5,390 The script. Copy&paste in you editor, save & import as "iip.avs". EDIT: Script removed. See updated version of iiP on page 6! __________________ - We´re at the beginning of the end of mankind´s childhood - My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!) Last edited by Didée; 22nd March 2005 at 12:49.
 15th February 2004, 21:37 #3  |  Link Wilbert Moderator   Join Date: Nov 2001 Location: Netherlands Posts: 6,295 btw, there is still a bug in generalconvolution. (There is no division by the total number of weights ...) I hope Richard has time one day to correct this
 18th February 2004, 17:58 #4  |  Link alky Guest   Posts: n/a congratulations: you win! http://web00020.ipax.tk/video it preserves very much detail and even adds some compared to just resizing. the sharpening is also not too strong - this should look really good viewed on a normal television. drawback: i cannot use it as it is since i have to crop black borders from the source before doing anything (pvr250 always adds 8-10 black pixel left/right, even if it gets a normal 4:3 signal) and i almost never get a mod 16 by this. maybe you could integrate cropping in the function?
 18th February 2004, 18:29 #5  |  Link alky Guest   Posts: n/a haha... was i speaking of practical usage?! a divx5 1st-pass would need ~34 hours for one csi episode...
 18th February 2004, 19:45 #6  |  Link Soulhunter Bored...     Join Date: Apr 2003 Location: Unknown Posts: 2,812 A quick test... Hmmm... Yes, a nice script !!! But I will take a closer look next weekend !!! Bye __________________ Visit my IRC channel
19th February 2004, 07:05   #8  |  Link
Richard Berg
developer wannabe

Join Date: Nov 2001
Location: Brooklyn, NY
Posts: 1,212
Quote:
 Originally posted by Wilbert btw, there is still a bug in generalconvolution. (There is no division by the total number of weights ...) I hope Richard has time one day to correct this
Done in the latest CVS. (Thought about doing multiplication too, but I think Overlay would be faster.)

Here's the new internal documentation:
Code:
    /**
* GeneralConvolution(PClip clip, int divisor=1, int bias=0, string matrix)
* clip     =  input video
* divisor  =  divides the output of the convolution (calculated before adding bias)
* matrix   =  the kernel (3x3 or 5x5).  any kind of whitespace is ok, see example
*
* clip.GeneralConvolution("1 2 3
*                          4 5 6
*                          7 8 9")
**/

 19th February 2004, 07:12 #9  |  Link SoonUDie Registered User   Join Date: Dec 2003 Posts: 147 I worked on something similar for a while, but I've given up for the time being. There are some filters I want to code before I give it another serious go, but I'm not a coder and I don't have a lot of free time right now :/ One thing I'd love but could never code myself would be a superresoultion filter - they regenerate a high resolution image from temporal information. There are a million papers available on the technique, but I haven't seen any effort to make one. __________________ Stuff was here at some point.
 19th February 2004, 07:19 #10  |  Link Richard Berg developer wannabe     Join Date: Nov 2001 Location: Brooklyn, NY Posts: 1,212 Actually, that little example at the bottom is very old, and therefore wrong Now that there are more arguments you have to say 'matrix="..."' or prepend it with '1, 0, "..."'.
19th February 2004, 13:16   #11  |  Link
mf
·

Join Date: Jan 2002
Posts: 1,729
Quote:
 Originally posted by Didée [BAs of now, I am converting a 40min episode with (the upcoming) version, with the abovementioned fast 1st pass. On my (only) Athlon1800, the first pass took 9.5 hours, second will crunch for about 16-19 hours.[/B]
Thought of VBLE yet? Or don't you have the HD space?

19th February 2004, 13:56   #12  |  Link
Didée
Registered User

Join Date: Apr 2002
Location: Germany
Posts: 5,390
[off-topic]
Quote:
 Originally posted by mf Thought of VBLE yet? Or don't you have the HD space?
Of course that's one of the common procedures. I am used to do things that way too, yes.

My excuses:

1. My HD's are currently cluttered with WAY too much unfinished projects and not-yet-touched DVB captures.

2. I'm short with HD space generally: it's only ~ 500 GB

3. Since this script is fairly new for me, too, I decided to do a conventional 1st-pass and analyze it thourougly afterwards, to see how the actual compressability will turn out, and to be able to perhaps adjust the parameters slightly for the 2nd pass.

I'm going to put 13 episodes of 40~42 minutes each, at 704*528, to one DVD+R. Hence I don't want to make (too) much mistakes with such a crawler script.

Rule#1: First know your tools exactly, *then* start doing the tricks.

BTW, I was almost sure I'll get a kick in the a** from you, mf, for the crap I am scripting here

[/off-topic]

- Didée
__________________
- We´re at the beginning of the end of mankind´s childhood -

My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!)

19th February 2004, 13:59   #13  |  Link
mf
·

Join Date: Jan 2002
Posts: 1,729
Quote:
 Originally posted by Didée BTW, I was almost sure I'll get a kick in the a** from you, mf, for the crap I am scripting here
Yeah, I didn't look too closely yet, but I was tickled for a moment to script a quick hack that *does* allow the denoiser to be chosen .

 20th February 2004, 09:34 #14  |  Link Mug Funky interlace this!     Join Date: Jun 2003 Location: i'm in ur transfers, addin noise Posts: 4,547 hmm. i don't use generalconvolution for edge masking, but are there any advantages do just "subtract(last,last.blur(1))" and some leveling or overlaying? i'm pretty new to edgemasking, but this method works for me in most instances (except for the odd white-dot effect when colours stray outside the CCIR range) __________________ sucking the life out of your videos since 2004
20th February 2004, 13:05   #15  |  Link
mf
·

Join Date: Jan 2002
Posts: 1,729
Quote:
 Originally posted by Mug Funky i'm pretty new to edgemasking, but this method works for me in most instances (except for the odd white-dot effect when colours stray outside the CCIR range)
Fix for that is using YV12Subtract with tol=0 twice and layering them.
Example (semi-avs cause I'm lazy):
dark = yv12subtract(tol=0)
light = invert.yv12subtract(tol=0).invert
layer/overlay/whatever(dark, light, op=lighten)

That worked for me. The idea is that when using tol=0 only the dark values come out for some wicked reason. So if you invert twice you get the light values and then you layer those over the dark ones.

20th February 2004, 13:07   #16  |  Link
Didée
Registered User

Join Date: Apr 2002
Location: Germany
Posts: 5,390
@ mf:
Quote:
 ...I was tickled for a moment to script a quick hack that *does* allow the denoiser to be chosen.
Now, this is a really BRILLIANT idea:

I'll do the technical art, and you take the punishment of making my stuff more user friendly!

Do we have a deal?

Quote:
 originally posted by Mug Funky i don't use generalconvolution for edge masking, but are there any advantages do just "subtract(last,last.blur(1))" and some leveling or overlaying?
A good idea, Mug Funky - which I had already 2 years ago ... [edit: in November 2002]

Subtract() will leave you with an image centered around Y=127, spreading the differences towards 0 and 255 both. This is not suited for masking (most times).
Almost 2 years ago, I proposed more than once that subtract() badly needed another mode where it returns [no difference]=[0] & [full difference]=[255]. But I was talking to the wind.
Of course it is possible to adjust the 127-centered result of subtract() to what is needed; but these calculations (you need both overlaying and levelling) also need some CPU time, so that doing it from start by GeneralConvolution turns out to be about just the same effort.
Another possibility is to use "adjust.dll" for making subtract()'s output suitable ... works pretty good also, but requires YV12<->YUY2 conversion.
After all, with Convolution I have better control over what's exactly happening. (Keep dreaming of "UltraFastLaPlacianKernelConvolution.DLL" ...)

Regarding iip itself:

New version is ready. Deringing is in. MOD16 is no more required. Sharpening works a little more tasty now (for me). Speed has not improved. Custom denoising is waiting for mf

When I'll return home, I'll have to do a little more fine-tuning on the deringing part - deringing of natural sources with neither destroying nor "forgetting" something is probably a little more complicated than on animee ...

Should go online this night.

One more question:

Much overlaying is going on in this script, and ...

1. Overlay() is (yet) less optimized than MaskTool's functions, speak: it's noticeably slower.

2. MaskedMerge() of MaskTools seems to inheritely have small rounding errors: it may introduce slight color shifts.

What do you prefer ... ?

- Didée
__________________
- We´re at the beginning of the end of mankind´s childhood -

My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!)

Last edited by Didée; 20th February 2004 at 13:55.

 20th February 2004, 14:06 #17  |  Link Didée Registered User   Join Date: Apr 2002 Location: Germany Posts: 5,390 Oops, didn't see that mf was replying while I was still typing ... mf: So one can get it to work that way, okay. But then, how much faster is [2*subtract]+[invert]+[overlaying]+[SomeThingsMore] compared to GeneralConvolution()?? Plus, the latter still is more exact than this UnsharpMasking-like approach -- but: it is well suited to e.g. create simple deringing masks, agreed. Should we create a new thread, about edge detection ... - Didée __________________ - We´re at the beginning of the end of mankind´s childhood - My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!) Last edited by Didée; 20th February 2004 at 14:10.
 20th February 2004, 15:44 #18  |  Link mf ·     Join Date: Jan 2002 Posts: 1,729 Actually, I hate putting in the end-user stuff. I just like to release a filter and see the reactions, so I try to put in as much user-configurable stuff as possible. In that sense you could say I'm a fame junkie . And you've given me an idea for an edge mask. It has to do with an old filter in MaskTools that's been a friend of mine for some time... Can you guess it?
 20th February 2004, 16:33 #19  |  Link Didée Registered User   Join Date: Apr 2002 Location: Germany Posts: 5,390 I put (little) money on "MaskOverlay()" ? - I didn't try that one myself, not one single time But I do remember the good old times, say a year ago, when we simply posted pure linear scripts, and simply stated "try this!". Today, we shall produce full-featured functions, that catch every possible user error, are configurable from head to toe, do sing and dance, glow in the dark and defragment your HD in the background. Oh my Lord. ( partly , partly ) - Didée __________________ - We´re at the beginning of the end of mankind´s childhood - My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!)
 20th February 2004, 21:39 #20  |  Link mf ·     Join Date: Jan 2002 Posts: 1,729 It has to do with Inflate .