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

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

 

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

Reply
 
Thread Tools Search this Thread Display Modes
Old 29th September 2010, 13:16   #41  |  Link
stpdrgstr
Registered User
 
Join Date: Oct 2008
Posts: 37
I get "there is no function named "Max"" when trying to use Gradfun3().
stpdrgstr is offline   Reply With Quote
Old 29th September 2010, 13:55   #42  |  Link
Didée
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!)
Didée is offline   Reply With Quote
Old 29th September 2010, 17:10   #43  |  Link
stpdrgstr
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.
stpdrgstr is offline   Reply With Quote
Old 29th September 2010, 18:32   #44  |  Link
Didée
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!)
Didée is offline   Reply With Quote
Old 29th September 2010, 18:54   #45  |  Link
stpdrgstr
Registered User
 
Join Date: Oct 2008
Posts: 37
That's weird, I can't see that and other threads listed.

I went with 2.6 at the end, but thanks anyways.
stpdrgstr is offline   Reply With Quote
Old 7th November 2010, 18:30   #46  |  Link
cretindesalpes
͡҉҉ ̵̡̢̛̗̘̙̜̝̞̟̠͇̊̋̌̍̎̏̿̿
 
cretindesalpes's Avatar
 
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
cretindesalpes is offline   Reply With Quote
Old 12th November 2010, 02:15   #47  |  Link
sneaker_ger
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?
sneaker_ger is offline   Reply With Quote
Old 12th November 2010, 02:36   #48  |  Link
Usedocne
lurkster
 
Join Date: Jul 2009
Location: D9|D10
Posts: 123
libfftw3f-3.dll goes in the Windows\SysWOW64 folder.
Usedocne is offline   Reply With Quote
Old 12th November 2010, 18:15   #49  |  Link
sneaker_ger
Registered User
 
Join Date: Dec 2002
Posts: 5,565
Thank you, works now.
sneaker_ger is offline   Reply With Quote
Old 19th February 2011, 05:45   #50  |  Link
Fullmetal Encoder
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)
Since I didn't want DFTTest to be doing any extra denoising my idea was to deactivate any of it's processing and still have the filter output an msb and lsb, which, as I understand it, are absolutely necessary for DitherPost. I also tried setting y,u,v to "false" in dfttest() and using various other modes for DitherPost but in all cases this script either produces nothing (displays the source clip without any apparent processing) or slows the script down (dfttest appears to slow down navigation in VirtualDub but no dithering is taking place). There really isn't any point in doing extra processing with a very slow DFTTest just to get rid of banding. This is somewhat of a hack, however, as invoking DFTTest at all leaves me not knowing whether it may be slowing down processing even if I use sigma=0 so ideally I'd like to be able to use DitherPost by itself. While I have been able to get DitherPost to add dithering by omitting DFTTest and msb and lsb the results are very ugly with very visible spots and band.

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.
Fullmetal Encoder is offline   Reply With Quote
Old 19th February 2011, 09:22   #51  |  Link
Dogway
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
Dogway is offline   Reply With Quote
Old 20th February 2011, 16:43   #52  |  Link
cretindesalpes
͡҉҉ ̵̡̢̛̗̘̙̜̝̞̟̠͇̊̋̌̍̎̏̿̿
 
cretindesalpes's Avatar
 
Join Date: Feb 2009
Location: No support in PM
Posts: 712
Quote:
Originally Posted by Fullmetal Encoder View Post
I'm having a bit of difficulty getting this to work properly in the absence of a denoiser.
I fear that calling dfttest with sigma=0 will do absolutely nothing excepted warming your room and wasting your time.

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)
EDIT : better use the denoised clip for the MAnalyse steps.


Quote:
Originally Posted by Dogway View Post
Is it possible to sharpen between dfttest and dither?
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.
cretindesalpes is offline   Reply With Quote
Old 21st February 2011, 14:25   #53  |  Link
Heaud
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
Could that be used in junction to dfttest+ditherpost?

What about the lost edges, could a repair function fix that?
Heaud is offline   Reply With Quote
Old 21st February 2011, 21:26   #54  |  Link
-Vit-
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 )
The first restoral tries to recover detail that was misrecognized as noise in the denoising step - it may survive a temporal smooth compensated by motion vectors calculated from the clean source. The second restoral adds in some measure of true noise as you wish.

This part of QTGMC is still work in progress.
-Vit- is offline   Reply With Quote
Old 23rd February 2011, 10:49   #55  |  Link
Dogway
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)
Im trying to put ditherpost into play here adding:
Code:
msb_sharp = msb.ContraSharpening(luma, input)
mask = DitherBuildMask (msb_sharp, msb)
DitherPost (msb_sharp, lsb, prot=false, mask=mask)
but a warning message warns me:
Code:
Repair: clips must be of equal type, line 160.
I think it has to be with comparing 8 bit against 16 bit data in the contrasharpening. Besides I have been reading the dither documentation and its unclear about the msb and lsb variables. It looks like when dfttest is inside a variable msb/lsb can't be called, which renders the masking and contrasharpening not being usable.
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.
Dogway is offline   Reply With Quote
Old 23rd February 2011, 11:48   #56  |  Link
cretindesalpes
͡҉҉ ̵̡̢̛̗̘̙̜̝̞̟̠͇̊̋̌̍̎̏̿̿
 
cretindesalpes's Avatar
 
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)
You can also contrasharpen the rounded clips, compute the difference between before and after using mt_makediff and add this difference back on the final result.
__________________
dither 1.28.1 for AviSynth | avstp 1.0.4 for AviSynth development | fmtconv r30 for Vapoursynth & Avs+ | trimx264opt segmented encoding
cretindesalpes is offline   Reply With Quote
Old 23rd February 2011, 17:05   #57  |  Link
Dogway
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  |
|_______|
What you propose is to go back to 8bits, do the stuff and then in ditherpost compare that and lsb, right?
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)
Is it correct? I edited out, as I think I figured out the working. Still I have a question, msb_sharp in ditherpost is already 8bit (done in rounded), is it ok?

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.
Dogway is offline   Reply With Quote
Old 23rd February 2011, 21:35   #58  |  Link
cretindesalpes
͡҉҉ ̵̡̢̛̗̘̙̜̝̞̟̠͇̊̋̌̍̎̏̿̿
 
cretindesalpes's Avatar
 
Join Date: Feb 2009
Location: No support in PM
Posts: 712
Quote:
Originally Posted by Dogway View Post
I really would like to understand better what MSB and LSB are
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:
What you propose is to go back to 8bits, do the stuff and then in ditherpost compare that and lsb, right?
Technically, it's not exactly that, but you got it. The LSB is not compared, it is added. To take the previous comparison again, it's like sharpening using the tens, and adding the units at the very end. On gradients, the sharpening shouldn't change anything, so the operation should be transparent regarding gradients. But we need to protect the detailed zones and their close neighbourhood.

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)
I supposed your lumamask function handles the chroma planes too.
__________________
dither 1.28.1 for AviSynth | avstp 1.0.4 for AviSynth development | fmtconv r30 for Vapoursynth & Avs+ | trimx264opt segmented encoding
cretindesalpes is offline   Reply With Quote
Old 23rd February 2011, 22:16   #59  |  Link
Dogway
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
Dogway is offline   Reply With Quote
Old 23rd February 2011, 22:44   #60  |  Link
cretindesalpes
͡҉҉ ̵̡̢̛̗̘̙̜̝̞̟̠͇̊̋̌̍̎̏̿̿
 
cretindesalpes's Avatar
 
Join Date: Feb 2009
Location: No support in PM
Posts: 712
Quote:
Originally Posted by Dogway View Post
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.
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
cretindesalpes is offline   Reply With Quote
Reply

Tags
color banding, deblocking, noise reduction

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

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

Forum Jump


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


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