Quantcast Avisynth: Ads() a Function Using a Masked Denoising etc - Page 3 - digitalFAQ.com Forums [Archives]
  #41  
09-22-2004, 01:50 PM
audioslave audioslave is offline
Free Member
 
Join Date: Mar 2003
Location: Sweden
Posts: 725
Thanks: 0
Thanked 0 Times in 0 Posts
@Peter1234
I already asked incredible about this in a previous post...

Change this line:
Code:
cr= (W==720) ? 8 : 0
to this:
Code:
cr= (W==720) ? 0 : 0
__________________
AudioSlave
Reply With Quote
Someday, 12:01 PM
admin's Avatar
Site Staff / Ad Manager
 
Join Date: Dec 2002
Posts: 42
Thanks: ∞
Thanked 42 Times in 42 Posts
  #42  
09-22-2004, 01:54 PM
J-Wo J-Wo is offline
Free Member
 
Join Date: Nov 2002
Location: Toronto, Canada
Posts: 454
Thanks: 0
Thanked 0 Times in 0 Posts
Here's my take on the 704x480... There is absolutely no point in changing this back to 720x480, because all that is going to do is add 8 pixels of black border on both the left and right edge of the screen. Since your TV set in almost all circumstances cannot see those extreme left and right edges, it's best to simply leave them out since 704x480 is a perfectly accepted dvd compliant resolution. This way you'll have more space for encoding your movie, because keeping an unnecessary black border in an encode will take up more space than none.

Does this make sense? Am I correct in this assumption?
Reply With Quote
  #43  
09-22-2004, 01:56 PM
audioslave audioslave is offline
Free Member
 
Join Date: Mar 2003
Location: Sweden
Posts: 725
Thanks: 0
Thanked 0 Times in 0 Posts
@J-Wo
Yes, it sounds like you're making sense! I've never thought about it in that way before. Good point .

BTW I'm getting pretty ugly ghosting with this new version of ADS... Very noticable on scene changes!
__________________
AudioSlave
Reply With Quote
  #44  
09-22-2004, 02:03 PM
Peter1234 Peter1234 is offline
Free Member
 
Join Date: Feb 2003
Posts: 237
Thanks: 0
Thanked 0 Times in 0 Posts
J-Wo,
I agree that there is no point in changing 704x480 back to 720x480 after it has been reduced, but it would be better to do all of the processing at 720x480 so that none of the image information is lost. If there was no advantage to using 720x480 then all of the DVDs would be 704x480. When the image is displayed on a 16:9 HDTV those extra pixels are used.

@audioslave,
Thanks, I missed that.
Reply With Quote
  #45  
09-22-2004, 02:08 PM
J-Wo J-Wo is offline
Free Member
 
Join Date: Nov 2002
Location: Toronto, Canada
Posts: 454
Thanks: 0
Thanked 0 Times in 0 Posts
@Audioslave:

Wow, I'm glad I was actually able to assist someone!!!

@Incredible:

I would like to see some modification to the way you handle the cropping feature. My HD set can handle an overscan of 3 (24 pixels) on the left and right edge, but it's slightly too much on the top and bottom edges when viewing anamorphic 16:9 video. Optimally I can cut off 20 pixels from the top and bottom, so all my encodes lately have used the line crop(24,20,-24,-20). However I can't be so precise with ADS, because while it lets me enter 20 pixels for top and bottom (To, Bo), I'm only allowed to enter overscan for left/right. This means if I chose overscan 3, I'll essentially get crop(24,24,-24,-24) because it will override my To,Bo settings. As a compromise I enter overscan 2, giving me crop(16,20,-16,-20). I don't know if an extra 8 pixels removed on left/right will make that much of a difference in my encodes, but since you already allow the user to specify To,Bo why not Lo,Ro for Left/Right borders instead of Ovr for Overscan?
Reply With Quote
  #46  
09-22-2004, 02:33 PM
J-Wo J-Wo is offline
Free Member
 
Join Date: Nov 2002
Location: Toronto, Canada
Posts: 454
Thanks: 0
Thanked 0 Times in 0 Posts
@ inredible (or others!):

okay I have a problem using ADS with DVD-RB/RB-Opt. Some lines are too long for DVD-RB to be entered in its filter editor, because by god they have a stupid character limit! This splits up long lines with a carraige return, destroying the whole function. When I load the thing up in RB-Opt, I could fix each line but because it doesn't have a full text editor I have to add/delete lines one at a time. PAIN! Can someone explain how I save the entire ADS function into a plugin that I place in my Avisynth 2.5/plugins directory? That way when I call ADS all the code is there and I don't have to put it in my script. Thanks!
Reply With Quote
  #47  
09-22-2004, 02:45 PM
audioslave audioslave is offline
Free Member
 
Join Date: Mar 2003
Location: Sweden
Posts: 725
Thanks: 0
Thanked 0 Times in 0 Posts
@J-Wo
I am using this:
Code:
LoadPlugin("G:\DVD\Filter\ADS\FluxSmooth.dll")
LoadPlugin("G:\DVD\Filter\ADS\MaskTools.dll")
LoadPlugin("G:\DVD\Filter\ADS\MPEG2Dec3.dll")
LoadPlugin("G:\DVD\Filter\ADS\UnDot.dll")
LoadPlugin("G:\DVD\Filter\ADS\UnFilter.dll")
LoadPlugin("G:\DVD\Filter\ADS\VSFilter.dll")

Import("G:\DVD\Filter\ADS\ADS-2004-09-22.avsi")

Mpeg2Source("G:\DVD\Endast film\The Passion Of The Christ\VIDEO_TS\New\Christ.d2v")
ADS(72, 72, 2, False, 4, 2)
Letterbox(76, 76, 0, 0)
TextSub("G:\DVD\Endast film\The Passion Of The Christ\VIDEO_TS\Subs\Subs2.ssa")
In other words: Save the ADS script to an *.avs or *.avsi file and import it in your script .
__________________
AudioSlave
Reply With Quote
  #48  
09-22-2004, 02:59 PM
J-Wo J-Wo is offline
Free Member
 
Join Date: Nov 2002
Location: Toronto, Canada
Posts: 454
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks to both of you, it worked like a charm.
Reply With Quote
  #49  
09-22-2004, 02:59 PM
Peter1234 Peter1234 is offline
Free Member
 
Join Date: Feb 2003
Posts: 237
Thanks: 0
Thanked 0 Times in 0 Posts
J-Wo,
Another option. If you copy function into a text file using notepad and save as ADS.avsi and then put that file in the plugins folder inside the AviSynth program folder, you will be able to call the function using ADS(0,0,0,false,6,8 ), or what ever options you want inside parentheses, without needing the Import statement.
Reply With Quote
  #50  
09-22-2004, 03:01 PM
audioslave audioslave is offline
Free Member
 
Join Date: Mar 2003
Location: Sweden
Posts: 725
Thanks: 0
Thanked 0 Times in 0 Posts
@J-Wo
No, it's not a typo. I saved the ADS script as "ADS-2004-09-22.avsi" .
__________________
AudioSlave
Reply With Quote
  #51  
09-22-2004, 03:05 PM
Peter1234 Peter1234 is offline
Free Member
 
Join Date: Feb 2003
Posts: 237
Thanks: 0
Thanked 0 Times in 0 Posts
J-Wo,
audioslave's suggestion will work with .avs or .avsi ending.
Reply With Quote
  #52  
09-22-2004, 03:36 PM
audioslave audioslave is offline
Free Member
 
Join Date: Mar 2003
Location: Sweden
Posts: 725
Thanks: 0
Thanked 0 Times in 0 Posts
@Peter1234
Yep! What's the difference between the two extensions anyway?

@incredible
Any news on the ghosting?
__________________
AudioSlave
Reply With Quote
  #53  
09-22-2004, 05:04 PM
incredible incredible is offline
Free Member
 
Join Date: May 2003
Location: Germany
Posts: 3,189
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to incredible
Well in my tests I didn recognise any ghosting
But that depends for shure on the source!
So do tweak the temporalsoften(...) line in the script as you like it

According to 720px encodings.

As explained before ...

Example in PAL:

720 width gots an pixelAspect ratio of 128/117. Thats the value your PAL video will be stretched by your TV.

So 720x(128/117) results in 788 px! But a PAL TV only shows 768 px (seen digitally) so 20 px are OFF, EVEN if a TV would have NO overscan

Same logic in NTSC, just another pixAspectratio has to be used for calculating.

@ J-Wo

Just use your classic resizing (keep it mod 8! but you should even resize in FitCD or MS using resize MOD16! generally ) and use in ads() as first 3 values 0,0,0 where you add the borders afterwards.



I updated the function (leaving still the last one in here present so in case of ... )
I had a nice exchange with dideé at forum.gleitz.de where he recommended his Double Sobel Mask which gives even better detail detection by beeing still resistant against noise.

So the syntax is now:

ADS(int "Top", int "Bottom", int "Overscan", bool "Letterbox", int "Sharpen", int "Threshold", bool "HQmask", bool "Show")

The HQmask and Show parameter have been added.
HQmask=true means the usage of didées double sobel mask (slower but even more detailed!!!)
Show = true means, that the peview of the masked area is shown.

Example:
ADS(72,72,2,Letterbox=false,Sharpen=3,Threshold=4, HQmask=true,show=false)

Code:
# ADS Adaptive Denoise & Sharpen
# v 0.5 _ Sept.22 2004
# HQmask(Double Sobel) borrowed from Dideé

function ADS (clip c, 
\     int  "Top", 
\     int  "Bottom", 
\     Int  "Overscan", 
\     Bool "Letterbox", 
\     int  "sharpen", 
\     int  "threshold",
\     Bool "HQmask", 
\     Bool "Show") {

setmemorymax(128)

To  = default (Top,0)
Bo  = default (Bottom,0)
Ov  = default (Overscan,0)
Lb  = default (Letterbox,false)
sh  = default (sharpen,5)
th  = default (threshold,4)
Hq  = default (HQmask,false)
So  = default (Show,false)

Ov  = Ov*8
W   = width(c)
H   = height(c)
cr  = (W == 720) ? 8 : 0
c   = (To <= Ov && Bo <= Ov) ? crop(c,Ov+cr,Ov,-(Ov+cr),-Ov) : crop(c,Ov+cr,To,-(Ov+cr),-Bo)
Wcr = width(c)
Hcr = height(c)
c   = isyv12(c) ? c : ConvertToYV12(c)

m   = (Hq == true)  ? 
\     logic( DEdgeMask(c,0,255,0,255,"5 10 5 0 0 0 -5 -10 -5", divisor=2),
\     DEdgeMask(c,0,255,0,255,"5 0 -5 10 0 -10 5 0 -5", divisor=2),"max").levels(0,1.0,255,0,255,false) :                      
\     masktools_EdgeMask(c,thY1 = 0, thY2 = th, thC1 = 2, thC2 = 4, type= "sobel").blur(1.5)

f1  = c.undot().bicubicresize((Wcr/1),(Hcr/2),1,0).Temporalsoften(4,5,8,25,2).bicubicresize(Wcr,Hcr)
f2  = c.undot().unfilter(0,sh*10)

d   = masktools_MaskedMerge (f1,c,m)
d   = (sh == 0)    ? d : masktools_MaskedMerge (d,f2,m)
d   = (Lb == true) ? Lanczosresize(d,width(d)-cr*2,round(height(d)*0.75)) : d
d   = (so == true) ? masktools_MaskedMerge (c,m,m).subtitle(":-) show mask",(Width(c)/2)-round(width(c)/13),(height(c)/2)-round(height(c)/20)) : d
d   = Addborders(d,(round(W-width(d)-cr*2)/2),(round(H-height(d))/2), 
\    (round(W-width(d)-cr*2)/2),(round(H-height(d))/2))

return d
}

"Masktools" Plugin is needed for this Function.
http://jourdan.madism.org/~manao/MaskTools-v1.5.1.zip
Reply With Quote
  #54  
09-22-2004, 06:31 PM
J-Wo J-Wo is offline
Free Member
 
Join Date: Nov 2002
Location: Toronto, Canada
Posts: 454
Thanks: 0
Thanked 0 Times in 0 Posts
Inc: regarding values for Sharpen and Threshold... I've noticed that Threshold values above 2 smooth out too much detail on my DVDs. If I turn HQmask on should I then raise my Threshold? I also don't seem to notice as much effect of the Sharpen parameter than the Threshold one. But I have to say so far I like what I've been seeing.
Reply With Quote
  #55  
09-24-2004, 01:46 AM
Peter1234 Peter1234 is offline
Free Member
 
Join Date: Feb 2003
Posts: 237
Thanks: 0
Thanked 0 Times in 0 Posts
incredible,
Thanks for generating all of these functions. I did some more tests with your previous version using ADS(sh=6,th=12) on DV files with convert60ito24p() and I think it does improve the image quality. I also tried your newest version using ADS(0,0,0, Letterbox=false, Sharpen=6, Threshold=12, HQmask=true, show=false) on the DV files but I did not think the results were as good as with the previous version. No quantitative data to support that, just my impression. I assume that this only works on progressive sources, so if I want to use it on an interlaced source I should separate the fields and then use ADS on each field. Is that correct?
Reply With Quote
  #56  
09-24-2004, 03:47 AM
incredible incredible is offline
Free Member
 
Join Date: May 2003
Location: Germany
Posts: 3,189
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to incredible
Well the diff. between the previous and this version is that you got the option to choose dideés doble sobel mask ("HQmask") beside the normal mask.

You also can rise the threshold of the HQ mask if you rise the first value in Levels() of the function (ill integrate that as a parameter).


According to interlaced processing you should use


bob()
ADS(.......)
Separatefields().selectevery(4,0,3).weave()

I do set 4,0,3 as if using 4,1,2 the final fieldorder gets changed in case of bob(). Bob() is the choice as its stupid and not smart= best condition for handling the noise.

A perfect solution would be:

Sourceimport()
bob() # stupid bob
Denoisers(.......)
Separatefields().selectevery(4,0,3).weave()
Kernelbob() # or other smart bobbers
Resizers()
Separatefields().selectevery(4,0,3).weave() # or 4,1,2

BUT as ADS() does both denoise & resize I will integrate an interlaced option so the optimal bobbing will be intergated in the script.

you also should everytime check your fieldorder first before bobbing.
Reply With Quote
  #57  
09-24-2004, 04:22 AM
jorel jorel is offline
Invalid Email / Banned / Spammer
 
Join Date: Aug 2002
Location: Brasil - MG - third stone from the sun
Posts: 5,570
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by incredible
bob() # stupid bob
why " stupid bob " inc ?
Reply With Quote
  #58  
09-24-2004, 06:06 AM
Jellygoose Jellygoose is offline
Free Member
 
Join Date: Jun 2002
Location: Germany
Posts: 1,288
Thanks: 0
Thanked 0 Times in 0 Posts
@inc: Can I propose you to open a new thread for your function? this way it gets more transparent to people who want to try out your script. You could post your script, together with a short explanation on how it's supposed to be used/for what target and so on... also updates could be posted in that new thread more easily! just a tip!
good work, I'll try the function out very soon!
__________________
j3llyG0053
Reply With Quote
  #59  
09-24-2004, 06:12 AM
incredible incredible is offline
Free Member
 
Join Date: May 2003
Location: Germany
Posts: 3,189
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to incredible
A stupid bob just "seperates" the fields by keeping the fields position which seperatefields() doesnt and resizes using the bicubic std. interpolation.

A smart bobber does work adaptive to combings means does handle real combed areas different using interpolation between fields for instance = the XXXbob output will be more manipulated (said in easy words). And there are many diff bobbers containing each their diff. advantages. TmcKernelBOB(), TmcBOB(), KernelBob, MatchBob(), Tdeint(), DgBob() and so on, some of them are provided as dll's and some as functions based on tomsMoComb() for instance.

@ Jell (and Jorel)

I do see that its mega senseful to split this thread and so Ill do it

Yesterday I did some tests using diff. Temporaldenoisers and sharpeners, I do think Ill release the next beta this evening.

This script could be used for both, DVD inputs and captures, as everything depends on a right setting of the thresholds!

So the best way is to watch HOW much has the threshold to be rised till the noise is off, and that also can be figured out by watching the regular preview. This will keep as most detail as possible.
On DVDs you very often get more "spray" noise than like in captures where a "grainy" noise is oftener to be found.
Now as grainy noise itself is bigger, so you have to rise the threshold. And this wont make that much harm as captures do already have much less details then DVDs.

The only problem on captures is, that also the masked edges do contain very visible "grain" in the unfiltered state. So if sharpen that masked edge area of captures, mosquitos will result as remarked by Didée at forum.gleitz.de. So I've to find a spatial filtering solution in case of edges from captures! But already of no sharpen in case of captures is applied, the function does wonders when using the right threshold.

As said the threshold setting now only works on the normal mask mode.
If you want to enter the threshold of Dideés "HQmask", then do rise the threshold in the Levels(x,1.0,255,0,255) command where x could be rised or also or only the gamma ( the 1.0 value in levels() ).
Do use show=true and youll see how the threshold will affect the mask.


Yesterday I took a sliced part from "a new hope" of the starwars box set. The noise was off, details where even more enhanced and the compressibilty was ended up in ca. 68 MB, where undot().deen() gaves me 65 MB and so that little amount of filesize rise Ill take into account for myself as it stands in a relative GAIN of the quality rise. So u can assume how tiny will be the rise in Q of CCE.
Reply With Quote
  #60  
09-24-2004, 09:28 AM
jorel jorel is offline
Invalid Email / Banned / Spammer
 
Join Date: Aug 2002
Location: Brasil - MG - third stone from the sun
Posts: 5,570
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by incredible
@ Jell (and Jorel)

I do see that its mega senseful to split this thread and so Ill do it

Yesterday I did some tests using diff. Temporaldenoisers and sharpeners, I do think Ill release the next beta this evening.

This script could be used for both, DVD inputs and captures, as everything depends on a right setting of the thresholds!
very cool ink.
Reply With Quote
Reply




Similar Threads
Thread Thread Starter Forum Replies Last Post
Avisynth: No function called BlindPP ? WOWIEGURL Avisynth Scripting 4 04-02-2014 08:11 AM
Avisynth: PARanoia and ADS function comparison rds_correia Avisynth Scripting 10 10-09-2005 04:30 PM
Avisynth: Is is possible to use the trim() function with audio supermule Avisynth Scripting 3 09-10-2005 03:05 AM
Avisynth: funny denoising routines incredible Avisynth Scripting 44 11-15-2003 11:27 AM
Avisynth: Wavelet denoising? GFR Avisynth Scripting 28 01-08-2003 11:16 PM

Thread Tools



 
All times are GMT -5. The time now is 10:45 AM  —  vBulletin © Jelsoft Enterprises Ltd