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. |
29th September 2010, 13:55 | #42 | Link |
Registered User
Join Date: Apr 2002
Location: Germany
Posts: 5,389
|
min() and max() functions were added in Avisynth 2.5.8.
Seems you're still using 2.5.6 or 2.5.7.
__________________
- 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!) |
29th September 2010, 17:10 | #43 | Link |
Registered User
Join Date: Oct 2008
Posts: 37
|
So that's why. I was using the 2.5.7 mt version I could find at the avisynth wiki because one of the 2.5.8 versions gave me weird errors with assumefps. What 2.5.8 mt do you recommend?
EDIT: I just noticed there's only one 2.5.8 supporting MT, but it's 64 bits. Isn't there a 32 bits version? Last edited by stpdrgstr; 29th September 2010 at 18:06. |
29th September 2010, 18:32 | #44 | Link |
Registered User
Join Date: Apr 2002
Location: Germany
Posts: 5,389
|
Sure there is.
__________________
- 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!) |
7th November 2010, 18:30 | #46 | Link |
͡҉҉ ̵̡̢̛̗̘̙̜̝̞̟̠͇̊̋̌̍̎̏̿̿
Join Date: Feb 2009
Location: No support in PM
Posts: 712
|
Dither updated to version 1.5. Added several error diffusion algorithms (however ordered dithering still looks better after video compression) and fixed the randomness of the internal noise generator.
__________________
dither 1.28.1 for AviSynth | avstp 1.0.4 for AviSynth development | fmtconv r30 for Vapoursynth & Avs+ | trimx264opt segmented encoding |
12th November 2010, 02:15 | #47 | Link |
Registered User
Join Date: Dec 2002
Posts: 5,565
|
I wanted to try dither out but I always get the error "dfftest: unable to load libfftw3f-3.dll". I'm using AviSynth 2.5.8 (MT) on Windows 7 64bit with a Core i7. I have copied libfftw3f-3.dll to my plugin directory. Any idea?
|
19th February 2011, 05:45 | #50 | Link |
Registered User
Join Date: Jan 2011
Posts: 107
|
I'm having a bit of difficulty getting this to work properly in the absence of a denoiser. I prefer to use TNLMeans to denoise and I have a clip which has been denoised to my satisfaction. From the sample images posted in this thread it appears that the debanding methods that DitherPost employs are superior to GradFun2DBMod. Plus, I would like to see how I can use the mask tool to preserve detail beyond the level I have been able to accomplish with GradFun2DBMod. How do I go about using/testing DitherPost on a previously denoised clip? While I would like to have 16-bit depth output with TNLMeans I'm afraid that the sun would go supernova before Dither2Pre finished processsing the video. Here is what I have attempted:
Code:
SetMTMode(2,8) SetMemoryMax(1400) AVISource("clip.avi") dfttest(sigma=0,sigma2=0,lsb=true) msb = last.Crop (0, 0, 720, 480) lsb = last.Crop (0, 480, 720, 480) DitherPost (msb, mode=0, lsb, prot=false) BTW, I was the one who created a thread earlier asking about the possibility of sending only portions of a frame through to a filter based on a luma threshold or other criteria. What I was thinking of using that to accomplish appears to be almost exactly what you have done with DitherPost and BuildDitherMask, which is to allow high quality dithering while protecting more detailed areas of the image. Thanks in advance for any help you can provide. |
19th February 2011, 09:22 | #51 | Link |
Registered User
Join Date: Nov 2009
Posts: 2,352
|
Is it possible to sharpen between dfttest and dither?
__________________
i7-4790K@Stock::GTX 1070] AviSynth+ filters and mods on GitHub + Discussion thread |
20th February 2011, 16:43 | #52 | Link | |
͡҉҉ ̵̡̢̛̗̘̙̜̝̞̟̠͇̊̋̌̍̎̏̿̿
Join Date: Feb 2009
Location: No support in PM
Posts: 712
|
Quote:
Ideally, your denoiser could be able to output 16-bit data. I haven't studied how TNLMeans works, but I wouldn't be surprised if its internal computations are done at a higher bit depth than its actual output. Anyway, to deband a denoised clip, you can simply use the GradFun3 function. Just pass it your denoised clip and it will act like Gradfun2db. No need for additional DitherPost. But these functions just try to repair the harm done by the 8-bit quantification happening in the denoiser. If you don't want to use dfttest/MDegrain as main denoiser, restore a small bit of noise in your previously filtered clip and use dfttest with a low sigma (1.0 for example). Code:
# Your favourite denoiser here denoised = MyExcellentDenoiser (parameters) # Restore a bit of noise mt_lutxy (last, denoised, expr="x y < y 1 - x y > y 1 + y ? ?", y=3, u=3, v=3) super = MSuper () # You could also reuse the vectors found in a previous processing stage vf1 = super.MAnalyse (isb=false, delta=1, overlap=4, blksize=16) vb1 = super.MAnalyse (isb=true, delta=1, overlap=4, blksize=16) # Turns remaining noise into 16-bit gradients cf1 = MCompensate (super, vf1, thSAD=200) cb1 = MCompensate (super, vb1, thSAD=200) Interleave (cf1, last, cb1) dfttest (sigma=1.0, tbsize=3, lsb=true) SelectEvery (3, 1) # Additional smoothing pass tmp = last SmoothGrad (thr=0.20, radius= 8, stacked=true, ref=tmp) SmoothGrad (thr=0.17, radius=12, stacked=true, ref=tmp) SmoothGrad (thr=0.15, radius=16, stacked=true, ref=tmp) # Back to 8 bits DitherPost (prot=false, stacked=true) Sure, although I think it's better to use the sharpener afterwards, with a mask to avoid sharpening the remaining noise/grain and the dither patterns. Code:
w = Width () h = Height () dfttest (sigma=1.0, tbsize=1, lsb=true) msb = Crop (0, 0, w, h) lsb = Crop (0, h, w, h) msb_sharp = msb.Sharpen (0.5) mask = DitherBuildMask (msb_sharp, msb) DitherPost (msb_sharp, lsb, prot=false, mask=mask)
__________________
dither 1.28.1 for AviSynth | avstp 1.0.4 for AviSynth development | fmtconv r30 for Vapoursynth & Avs+ | trimx264opt segmented encoding Last edited by cretindesalpes; 20th February 2011 at 16:49. |
|
21st February 2011, 14:25 | #53 | Link |
Registered User
Join Date: Apr 2008
Posts: 58
|
Is there a way to restore fine detail, any lost sharp edges, and an adjustable amount of noise back? Using dfttest to denoise can sometimes soften the hard edges on certain sigma values. Setting it too low causes ditherpost to do almost no dithering and setting it too high smoothes hard edges (animation) and fine detail is lost.
I noticed that QTGMC has a feature to restore lost noise/detail from the denoising stage using a script: Code:
# Add back any extracted noise, after final temporal smooth. This will appear as noise/grain in the output # Average luma of FFT3DFilter extracted noise is 128.5, so deal with that too addNoise2 = (NoiseRestore > 0.0) ? lossed2.mt_adddiff( deintNoise.mt_lut( "x 128.5 - " + string(NoiseRestore) + " * 128 +", U=1,V=1 ), U=2,V=2 ) : lossed2 What about the lost edges, could a repair function fix that? |
21st February 2011, 21:26 | #54 | Link |
Registered User
Join Date: Jul 2010
Posts: 448
|
That's just the last line of the noise bypass. The bare principle ignoring a few steps is this:
Code:
source=last clean = source.YourFavoriteDenoiser() noise = mt_makediff( source, clean, U=3,V=3 ) # Calculate motion vectors on clean source ... processed=clean.OtherProcessing() # QTGMC does it's deinterlacing here #... restored1 = processed.mt_lutxy( noise, "x y 128 - " + string(DetailRestore) + " * 128 +", U=3,V=3 ) smoothed = restored1.MoCoSmooth() # Some kind of motion-compensated temporal smooth restored2 = smoothed.mt_lutxy( noise, "x y 128 - " + string(NoiseRestore) + " * 128 +", U=3,V=3 ) This part of QTGMC is still work in progress. |
23rd February 2011, 10:49 | #55 | Link |
Registered User
Join Date: Nov 2009
Posts: 2,352
|
Im making up my mind to make this filter work without changing my workflow too much.
Normally my filtering methods go as follow: Code:
input=last temp=mdegrain... ... denoised = temp.dfttest(sigma=20, tbsize=1, lsb=true) luma=lumamask(temp,denoised,1,40) ContraSharpening(luma, input) Code:
msb_sharp = msb.ContraSharpening(luma, input) mask = DitherBuildMask (msb_sharp, msb) DitherPost (msb_sharp, lsb, prot=false, mask=mask) Code:
Repair: clips must be of equal type, line 160. Maybe its not very flexible, but Im curious to know the improvements when encoding patterned dithering specially on anime content.
__________________
i7-4790K@Stock::GTX 1070] AviSynth+ filters and mods on GitHub + Discussion thread Last edited by Dogway; 23rd February 2011 at 10:57. |
23rd February 2011, 11:48 | #56 | Link |
͡҉҉ ̵̡̢̛̗̘̙̜̝̞̟̠͇̊̋̌̍̎̏̿̿
Join Date: Feb 2009
Location: No support in PM
Posts: 712
|
Modified dfttest or MDegrain with parameter lsb=true will always produce a double-height clip, with the pixel MSB stacked on top of the LSB. You have 2 solutions get back to a 8-bit clip :
– Extract the MSB with a Crop. This is the simplest solution, although the maximum rounding error is suboptimal. The operation is actually value_8bits = floor (value_16bits / 256.0), leading to an error in the 0.0 – 1.0 range. Use it only if you need to process the clip in the 8-bit land and substitute the result to the previous MSB before dithering. This will give you a better chance to maintain the MSB/LSB consistency. – Just round the pixel values, as it would be done at the output of a regular denoiser without the 16-bit kludge. Just pass your clip to DitherPost (mode=-1, stacked=true, prot=false). Here, value_8bits = round (value_16bits / 256.0), leading to an error in the -0.5 – +0.5 range. Code:
input=last temp=mdegrain... ... denoised = temp.dfttest(sigma=20, tbsize=1, lsb=true) rounded = denoised.DitherPost (mode=-1, stacked=true, prot=false) luma=lumamask(temp,rounded,1,40) ... msb_sharp = msb.ContraSharpening(luma, input) mask = DitherBuildMask (msb_sharp, msb) DitherPost (msb_sharp, lsb, prot=false, mask=mask)
__________________
dither 1.28.1 for AviSynth | avstp 1.0.4 for AviSynth development | fmtconv r30 for Vapoursynth & Avs+ | trimx264opt segmented encoding |
23rd February 2011, 17:05 | #57 | Link |
Registered User
Join Date: Nov 2009
Posts: 2,352
|
I really would like to understand better what MSB and LSB are, documentation is very loose. As I understand it, MSB is the 16bit denoised output, while LSB is the denoised 8bit output, which are stacked one above the other (thus the double height). In this situation where we have only denoiser+ditherpost we use stacked=true, and ditherpost will automatically select (crop) to obtain the MSB and LSB. But if we do some working in between we need first to separate msb and lsb by cropping ourselves.
Code:
_______ | | | MSB | |_______| | | | LSB | |_______| Right now I have as follows: Code:
w = Width () h = Height () temp=mdegrain denoised = temp.dfttest(sigma=20, tbsize=1, lsb=true) lsb = denoised.Crop (0, h, w, h) rounded = denoised.DitherPost (mode=-1, stacked=true, prot=false) luma=lumamask(temp,rounded,1,40) msb_sharp=ContraSharpening(luma, temp) mask = DitherBuildMask (msb_sharp, luma) DitherPost (msb_sharp, lsb, prot=false, mask=mask) I might try your last suggestion as well. Anyway the effect is too subtle for my source after testing with several parameters, looks more like banding prevention than dithering.
__________________
i7-4790K@Stock::GTX 1070] AviSynth+ filters and mods on GitHub + Discussion thread Last edited by Dogway; 23rd February 2011 at 21:55. |
23rd February 2011, 21:35 | #58 | Link | |
͡҉҉ ̵̡̢̛̗̘̙̜̝̞̟̠͇̊̋̌̍̎̏̿̿
Join Date: Feb 2009
Location: No support in PM
Posts: 712
|
Here, MSB/LSB stands for Most/Least Significant Byte. The color depth of the filter output is 16 bits per component (total: 48 bits) but Avisynth can only handle 8-bit pixel values. Therefore we have to split each 16-bit pixel value into a pair of 8-bit pixels. It's exactly like separating digits of numbers from 0 to 99 into tens and units.
There are many ways to organize these pixels. We can store the MSB and LSB on separate frames, group them horizontally or vertically, or group all MSB and LSB and stack them. I choose the latter for the denoiser output, stacking MSB and LSB vertically. Below is an example of what it looks like : Original | Without dither (rounded) | Dithered The MSB part is very close to the simple 8-bit picture, but the full precision requires a combination of the LSB and the MSB. Quote:
Now, how to get the tens ? Let's suppose we have a pixel value of 28. If we take just the tens (the Crop method), we get a 2. If we round before to the closest ten (the other method), we get 3. The second method is indeed better, especially if we have to compare the clip with the original. But let's say we are in a gradient area, and the sharpener changes nothing. If we inject back the 3 as MSB, we got a 38, which is a (relatively) big error. Nothing should have changed. Therefore we have to work with differences (between before/after processing, or between before/after rounding, your choice). Regarding this issue, my first attempt at modifying your script wasn't right. Here is another version based on your previous post: Code:
w = Width () h = Height () temp=mdegrain denoised = temp.dfttest(sigma=20, tbsize=1, lsb=true) msb = denoised.Crop (0, 0, w, h) lsb = denoised.Crop (0, h, w, h) rounded = denoised.DitherPost (mode=-1, stacked=true, prot=false) luma=lumamask(temp,rounded,1,40) contra = ContraSharpening(luma, temp) contra_d = mt_makediff (contra, rounded, y=3, u=3, v=3) msb_sharp = mt_adddiff (msb, contra_d, y=3, u=3, v=3) mask = DitherBuildMask (msb_sharp, msb) DitherPost (msb_sharp, lsb, prot=false, mask=mask)
__________________
dither 1.28.1 for AviSynth | avstp 1.0.4 for AviSynth development | fmtconv r30 for Vapoursynth & Avs+ | trimx264opt segmented encoding |
|
23rd February 2011, 22:16 | #59 | Link |
Registered User
Join Date: Nov 2009
Posts: 2,352
|
Sweet, now it works as supposed. I will do some testings with parameters and encodings tomorrow, but I like what I see. At last it turned to be your suggestion what worked out.
A bit offtopic but as I see you are used with anime, do you recommend me going on tbsize=1 over dfttestmc? even mocomp'ed it introduces some artifacting but well, just asking people's doings. PD: I edited my previous post for easier reading.
__________________
i7-4790K@Stock::GTX 1070] AviSynth+ filters and mods on GitHub + Discussion thread |
23rd February 2011, 22:44 | #60 | Link |
͡҉҉ ̵̡̢̛̗̘̙̜̝̞̟̠͇̊̋̌̍̎̏̿̿
Join Date: Feb 2009
Location: No support in PM
Posts: 712
|
The tbsize=1 was just for the sake of simplifying the example; I find it introduces too much blurring. I generally use a combination of MDegrain3 and MC dfttest with tbsize=5, both with a low thSAD (200 or even lower) and a prefiltered motion search clip. It's not perfect, but it's still a very good compromise and I rarely have ghosting problems. Then I finalize the gradient smoothing with a single SmoothGrad pass with thr=0.15 before DitherPost.
__________________
dither 1.28.1 for AviSynth | avstp 1.0.4 for AviSynth development | fmtconv r30 for Vapoursynth & Avs+ | trimx264opt segmented encoding |
Tags |
color banding, deblocking, noise reduction |
Thread Tools | Search this Thread |
Display Modes | |
|
|