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 24th February 2011, 14:53   #61  |  Link
Heaud
Registered User
 
Join Date: Apr 2008
Posts: 58
Could you post the script that uses the combination MDegrain3 and MC dfttest? I would like to try it out.
Heaud is offline   Reply With Quote
Old 24th February 2011, 21:06   #62  |  Link
cretindesalpes
͡҉҉ ̵̡̢̛̗̘̙̜̝̞̟̠͇̊̋̌̍̎̏̿̿
 
cretindesalpes's Avatar
 
Join Date: Feb 2009
Location: No support in PM
Posts: 712
I already posted here an earlier version of this script. It is a bit rough and has to be finetuned (especially for the motion search clip), but the basic concept remains the same.
__________________
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 26th February 2011, 16:33   #63  |  Link
Dogway
Registered User
 
Join Date: Nov 2009
Posts: 2,352
It produces flatter color areas and preserves more details, compared to my gradfun workflow. Lossless compressed to FFV1 chunk weighted less (163Mb) than the gradfun method (189Mb) which indicates that it is more efficient fot bits allocation in h.264. Im using a very high bitrate for h.264 but (ordered) dither encodes nicely. Its perfect for 2D animation. Im gonna try your last suggestions, and methods to see if I can improve quality or optimization.

edit: It also deals nicely with the problem I was having with GradFun2DBmod (ghosting)
__________________
i7-4790K@Stock::GTX 1070] AviSynth+ filters and mods on GitHub + Discussion thread

Last edited by Dogway; 26th February 2011 at 16:42.
Dogway is offline   Reply With Quote
Old 27th February 2011, 14:38   #64  |  Link
Heaud
Registered User
 
Join Date: Apr 2008
Posts: 58
Dogway, would your ghosting problem be similar to mine? It's not the filter that is causing it for my source. I've tried many different ways and I noticed that it has been occuring in b-frames.
Heaud is offline   Reply With Quote
Old 27th February 2011, 15:12   #65  |  Link
LaTo
LaTo INV.
 
LaTo's Avatar
 
Join Date: Jun 2007
Location: France
Posts: 701
Quote:
Originally Posted by Dogway View Post
edit: It also deals nicely with the problem I was having with GradFun2DBmod (ghosting)
GradFun2DBmod can not create ghosting, it is because your source's filter is not accurate in temporal domain.

Set temp=-1 (disable temporal stabilization) in GF2DBmod is a good workaround.
LaTo is offline   Reply With Quote
Old 27th February 2011, 16:41   #66  |  Link
Dogway
Registered User
 
Join Date: Nov 2009
Posts: 2,352
Without dither
GradFun2DBmod temp=-1
Dither
Maybe ghosting is not the right word.
__________________
i7-4790K@Stock::GTX 1070] AviSynth+ filters and mods on GitHub + Discussion thread
Dogway is offline   Reply With Quote
Old 27th February 2011, 18:33   #67  |  Link
SilaSurfer
Registered User
 
SilaSurfer's Avatar
 
Join Date: Oct 2009
Posts: 212
@cretindesalpes

Very nice! I have a two questions. This is a standard usage call for Dither?

h = Height ()
w = Width ()
dfttest (lsb=true) # Output contains stacked MSB-LSB on the same frame.
msb = last.Crop (0, 0, w, h)
lsb = last.Crop (0, h, w, h)
DitherPost (msb, lsb, prot=false)

and

Could one for example use only Dithering?

TiA

Last edited by SilaSurfer; 27th February 2011 at 18:38.
SilaSurfer is offline   Reply With Quote
Old 27th February 2011, 18:55   #68  |  Link
Dogway
Registered User
 
Join Date: Nov 2009
Posts: 2,352
@SilaSurfer: if thats all you are going to do after dfttest, then I think you can just use:
dfttest (lsb=true)
DitherPost (stacked=true, prot=false)
__________________
i7-4790K@Stock::GTX 1070] AviSynth+ filters and mods on GitHub + Discussion thread
Dogway is offline   Reply With Quote
Old 27th February 2011, 19:12   #69  |  Link
cretindesalpes
͡҉҉ ̵̡̢̛̗̘̙̜̝̞̟̠͇̊̋̌̍̎̏̿̿
 
cretindesalpes's Avatar
 
Join Date: Feb 2009
Location: No support in PM
Posts: 712
Quote:
Originally Posted by Dogway View Post
Maybe ghosting is not the right word.
Indeed, this is haloing, not ghosting. This issue with gradfun2db is known and has been described here. This is related to how the gf2db filter works. Gradfun2db averages a large area around the processed pixel (box filtering), because box filtering is very fast and its speed is almost constant whatever the size of the box. The resulting 16-bit pixel value is compared to the current pixel and replaces it if the difference is small enough (with a smooth curve controlled by thr). Then, the result is dithered to 8 bits using error diffusion.

Actually the box filter + threshold is intended to be a simplification of a bilateral filter. It should have rejected input values which are too far away from the processed pixel, but instead it rejects output values which are not very close from the current pixel. In most case this works pretty well, but sometimes it fails and generates large, subtle halos near gradient boundaries.

Quote:
Originally Posted by SilaSurfer View Post
This is a standard usage call for Dither?
Yes for the purpose of debanding, but now you can write this even simpler:

Code:
dfttest (lsb=true)
DitherPost (prot=false, stacked=true)
Quote:
Could one for example use only Dithering?
Of course, if you can generate a 16-bit input. The general purpose of dither is basically converting high bitdepth data to a lower bitdepth while preserving the perceptive quality. The most interesting uses I can think of are high quality levels and colorspace conversions. For debanding purpose, you'll need a filter first to generate the 16-bit gradients from a 8-bits picture. The exact kind of filter depends on the nature of your source. Noisy: use a noise filter operating on large areas (like dfttest). Already banded: use a gradient rebuilder (like SmoothGrad).
__________________
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 27th February 2011, 19:39   #70  |  Link
SilaSurfer
Registered User
 
SilaSurfer's Avatar
 
Join Date: Oct 2009
Posts: 212
I'm confused here.

dfttest (lsb=true)
DitherPost (prot=false, stacked=true) #Debanding

What if I wanted to use Mdegrain also?

Sorry guys for the confusion, can't test this since encode is running here for the next 22 hours.

Last edited by SilaSurfer; 27th February 2011 at 19:46.
SilaSurfer is offline   Reply With Quote
Old 27th February 2011, 19:51   #71  |  Link
cretindesalpes
͡҉҉ ̵̡̢̛̗̘̙̜̝̞̟̠͇̊̋̌̍̎̏̿̿
 
cretindesalpes's Avatar
 
Join Date: Feb 2009
Location: No support in PM
Posts: 712
Quote:
Originally Posted by SilaSurfer View Post
dfttest (lsb=true) #Denoising
DitherPost (prot=false, stacked=true) #Debending
Not exactly : dfttest = denoising + debanding (or banding prevention). DitherPost = turns the previous result into something watchable and somewhat resilient to lossy video compression.

MDegrain* (lsb=true) does the same job as dfttest, but only temporally. Therefore it cannot remove banding when it is already in the source, but won't introduce new banding.
__________________
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 27th February 2011, 20:00   #72  |  Link
SilaSurfer
Registered User
 
SilaSurfer's Avatar
 
Join Date: Oct 2009
Posts: 212
Thanks cretindesalpes

So if I want to use DFTest

dfttest (lsb=true)
DitherPost (prot=false, stacked=true)

Mdegrain

Mdegrain (lsb=true)
DitherPost (prot=false, stacked=true)
SilaSurfer is offline   Reply With Quote
Old 27th February 2011, 20:18   #73  |  Link
cretindesalpes
͡҉҉ ̵̡̢̛̗̘̙̜̝̞̟̠͇̊̋̌̍̎̏̿̿
 
cretindesalpes's Avatar
 
Join Date: Feb 2009
Location: No support in PM
Posts: 712
Yes, just replace MDegrain with MDegrain1/MDegrain2/MDegrain3, and add at least the mandatory parameters required for the MDegrain* filters (superclip and motion vectors, see the MVTools2 documentation).
__________________
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 27th February 2011, 21:19   #74  |  Link
mp3dom
Registered User
 
Join Date: Jul 2003
Location: Italy
Posts: 1,135
For what I've seen, debanding filters in general suffers on dark areas. For example a thick black line in a dark gray background once debanded have the risk to be completely lost. I'm currently interested in only debanding (not denoise+debanding) so I think I'd need to use SmoothGrad (am I right?). In that case, have SmoothGrad some routines to avoid this (seems) common problem in dark areas without lowering the debanding strength on all other parts of the image? (I've not tested it yet, so I'm just asking). Thanks.
mp3dom is offline   Reply With Quote
Old 27th February 2011, 23:36   #75  |  Link
cretindesalpes
͡҉҉ ̵̡̢̛̗̘̙̜̝̞̟̠͇̊̋̌̍̎̏̿̿
 
cretindesalpes's Avatar
 
Join Date: Feb 2009
Location: No support in PM
Posts: 712
Quote:
Originally Posted by mp3dom View Post
In that case, have SmoothGrad some routines to avoid this (seems) common problem in dark areas without lowering the debanding strength on all other parts of the image?
No, SmoothGrad does just the basic debanding task and works just like gradfun2db, leaving the dithering for DitherPost. I even think about splitting the function again. You can protect the very dark shades this way: apply a curve to amplify the dynamic range of low luma (something like a gamma correction), SmoothGrad, then apply the inverse curve. Computation in the 16-bit land with 8-bit clips is a bit tricky, but it looks workable with the Masktools (mt_lutxy is your friend). You can also process the clip using two SmoothGrad with different settings, and use a luma mask to select the right parts.

However SmoothGrad was intended to be a postprocessor for the main filtering functions and therefore operates directly on a 16-bit clip, so you'll have to convert your clip to 16 bits. Just stack it on the top of a BlankClip with color_yuv=$000000. GradFun3 is a more or less sophisticated wrapper around SmoothGrad + DitherPost that would replace gradfun2db, but I'm not totally happy with its current implementation. I may rework it later.
__________________
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 6th April 2011, 04:08   #76  |  Link
Dogway
Registered User
 
Join Date: Nov 2009
Posts: 2,352
I found out that you dont need the quotes when using the filter string in ditherpre. But I wanted to note that despite it works wonders when it works, in ocassions it can smooth too much the results, more than dithering banding. I can tell from the last source Im testing with, it causes the lineart to blur. I can post comparisons.
What I thought was to use no dither (mode=-1) for lineart, and dither for the rest, but the effect is the same and running 2 instances (one with ditherpre, and one without) is a bit of CPU waste, moreover when Im using tnlmeans.

The code would come as follows:

Code:
line=src.MT("tnlmeans(ax=10,ay=10,az=2,sx=2,sy=2,bx=1,by=1,h=0.6,sse=false)",2,2)
flat=Dither2Pre(line,stacked=true)
Would this run tnlmeans twice, or will it just use the buffered image for dither2pre?

Also I have discovered some big ghosting problems (not halo-like like gradfun) in fast motion scenes. This is strange because I didnt think "Dither" had temporal qualities.
__________________
i7-4790K@Stock::GTX 1070] AviSynth+ filters and mods on GitHub + Discussion thread

Last edited by Dogway; 6th April 2011 at 06:58.
Dogway is offline   Reply With Quote
Old 7th April 2011, 19:08   #77  |  Link
cretindesalpes
͡҉҉ ̵̡̢̛̗̘̙̜̝̞̟̠͇̊̋̌̍̎̏̿̿
 
cretindesalpes's Avatar
 
Join Date: Feb 2009
Location: No support in PM
Posts: 712
Quote:
Originally Posted by Dogway View Post
I found out that you dont need the quotes when using the filter string in ditherpre.
If you don't put the double quotes, Avisynth will interpret the filter as a command to process last and will use the result as input (first parameter) for DitherPre. And because you probably multiplied the filter strength by 2 or 4 depending on the DitherPre function you use, you'll get maximum blur here. Moreover, the clip will be filtered a second time with the default filter. This is clearly not what you want.

Quote:
Originally Posted by Dogway View Post
Would this run tnlmeans twice, or will it just use the buffered image for dither2pre?
This will run tnlmeans once, and the internal default filter (a vanilla dfttest) four times. This code should work better:
Code:
Dither2Pre (flt="tnlmeans(ax=10,ay=10,az=2,sx=2,sy=2,bx=1,by=1,h=0.6,sse=false)", stacked=true)
I don't know exactly which function you should wrap with MT() for maximum performances.

Quote:
Originally Posted by Dogway View Post
Also I have discovered some big ghosting problems (not halo-like like gradfun) in fast motion scenes. This is strange because I didnt think "Dither" had temporal qualities.
The ghosting comes from dfttest used in DitherPre as default filter. Dfttest is not protected against ghosting, therefore you have to MCompensate/Interleave the previous and next frames first, and SelectEvery the result (see the dfttestMC function). Regarding motion compensation, it is advised to do it outside the DitherPre functions. Avoid using dfttestMC (or other motion-aware filters) in the filter string, because the motion estimation may fail on the material actually submitted to the filter.
__________________
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 7th April 2011, 23:07   #78  |  Link
Dogway
Registered User
 
Join Date: Nov 2009
Posts: 2,352
Thank you. In this case tnlmeans works best with MT. I had to use three quotes, which is what I did first, but Dither weakens the denoise effect so I thought it wasn't working at all or something. Then I got fooled with the "clip" parameter I guess.
That explains all the issues I was having, so hopefuly I dont need any edgemask workaround anymore.

Now what Im trying to do is some resizing in between, the code I have is as follows, but Im unsure if I can resize msb and lsb without ditherposting them first.

Code:
den=Dither2Pre(flt="""MT("tnlmeans(settings)",2,2)""",stacked=true)
msb=den.Crop(0,0,w,h)
lsb=den.Crop(0,h,w,h)
rounded=den.SmoothGrad (stacked=true).DitherPost(mode=-1,stacked=true,prot=false)
contraV=rounded.splinaa(720,480).LSFmod()
contra_d=mt_makediff (contraV,rounded.spline36resize(720,480),y=3,u=3,v=3)
msb_sharp=mt_adddiff(msb.spline36resize(720,480),contra_d,y=3,u=3,v=3)
mask=DitherBuildMask(msb_sharp,msb.spline36resize(720,480))
DitherPost(msb_sharp,lsb.spline36resize(720,480),prot=false,mask=mask)
I omitted the parameters but I realised how they need to be tweaked to obtain the same denoising as without using dither. In help, you say "amplitude-relative parameters must be doubled, and powers quadrupled" (for Dither1Pre which Im testing with), yet I dont get the values:
tnlmeans(ax=10,ay=10,az=2,sx=2,sy=2,bx=1,by=1,h=0.6)
tnlmeans(ax=20,ay=20,az=4,sx=4,sy=4,bx=1,by=1,h=2.4)
Are you sure filter behaviour is maintained?
__________________
i7-4790K@Stock::GTX 1070] AviSynth+ filters and mods on GitHub + Discussion thread

Last edited by Dogway; 8th April 2011 at 02:33.
Dogway is offline   Reply With Quote
Old 10th April 2011, 10:53   #79  |  Link
cretindesalpes
͡҉҉ ̵̡̢̛̗̘̙̜̝̞̟̠͇̊̋̌̍̎̏̿̿
 
cretindesalpes's Avatar
 
Join Date: Feb 2009
Location: No support in PM
Posts: 712
Quote:
Originally Posted by Dogway View Post
Now what Im trying to do is some resizing in between, the code I have is as follows, but Im unsure if I can resize msb and lsb without ditherposting them first.
Resizing a 16-bit picture is possible but prone to (light) artifacts. You should resize the lsb with BilinearResize in order to minimize the overshoots. Also, use prot=true in DitherPost. Anyway, I recommend to do 16-bit operations only on the final resolution. Resizing 16-bit data would not be an issue if we had 16-bit resizers... PhrostByte's ResampleHQ could do the job but it seems he's not interested in developing true 16-bit input/output.

Quote:
In help, you say "amplitude-relative parameters must be doubled, and powers quadrupled" (for Dither1Pre which Im testing with), yet I dont get the values:
tnlmeans(ax=10,ay=10,az=2,sx=2,sy=2,bx=1,by=1,h=0.6)
tnlmeans(ax=20,ay=20,az=4,sx=4,sy=4,bx=1,by=1,h=2.4)
Are you sure filter behaviour is maintained?
I don't know much TNLmeans so I can't give an definitive opinion. Anyway from what I read in the doc, ax, ay and az are spatial or temporal parameters, so they shouldn't be modified. Only a and h are related to pixel values, and I guess both must be multiplied by 2 in this case.
__________________
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 10th April 2011, 13:26   #80  |  Link
Dogway
Registered User
 
Join Date: Nov 2009
Posts: 2,352
uhmm As you said doubling only a and h seemed to work almost identical, I then applied your suggestions to ditherpost. Only after I realised of some artifacts so-to-speak, which I linked to the fact of resizing in 16bits. So I run a few tests up to a simple ditherpre-ditherpost, and still there, so maybe there's need to tweak more tnlmeans parameters, or they are wrong....

These are the two shots for comparison, the first one running only tnlmeans and dithering with gradfun, the second one with this workaround with dither. I want you look at the wall, grass loses some detail too.

old-workflow
dither-workflow

edit: the issue could be in ditherpost as well, although I tried several modes(-1,0,6,7) and didn't see any improve.
edit2:about ResampleHQ it would be nice in the meantime, bear in mind even yv12 dither isn't implemented. Its a bit pity to develop a 16b processing filter to benefit from wider bitdepth, and then crush it down to 8 back again.
__________________
i7-4790K@Stock::GTX 1070] AviSynth+ filters and mods on GitHub + Discussion thread

Last edited by Dogway; 10th April 2011 at 14:09.
Dogway 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 14:52.


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