View Single Post
Old 6th October 2004, 10:25   #5  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,389
Quote:
Originally posted by SpikeSpiegel
Anyway, give a try to antialias (the last "version") with a hi-medium resolution source: this script is meant for good quality movies, that why it didn't perform well with the WB sample.
Erh, sorry. If the quality of that sample is not sufficient for your script, then your script is useless. The given sample is perfectly valid (It's the original PAL trailer of HPII, in full resolution. I just cropped down to an 'interesting' area).
In fact, most sources that do need antialiasing will be of not-so-impressing quality to start with - most probably they'll be of lower quality than the sample I used. And just discarding one field from a progressive sequence, as I did here, is a good simulation of common aliasing problems (capturing only one field, dumb bobbing, one field useless due to fieldblending, etc. pp.)


However, your script has a couple of issues that could be improved:


1.
You're offering the aa threshold for sangnom, but it is not used in the script. Your call of SangNom should read

SangNom(order,aath)


2.
Chroma probably is just passed through (it IS on that P-III I'm sitting at right now).
Better would be:

c=edgemask(...).FitY2UV()

I've found that in many cases, it's better to use the luma edges for chroma also, insted of creating edges on chroma directly.

If you prefer to use "native" chroma edges, then you must still write

c=edgemask(... , Y=3,U=3,V=3)

Else, you won't get any edges on the chroma planes at all (as in your posted script).

Finally, you should write

MaskedMerge(a,b,c, Y=3,U=3,V=3)

AFAIK, MaskedMerge's default is to leave chroma alone, unless one specifies U|V=3.


3.
As it is typical for EDI resamplers, SangNom too delivers an output that is spatially shifted from the input. This would not be a big issue ... if you would create the edgemask on the shifted frame. But you are creating it on the not-shifted input, and apply it later on the shifted output. That's not ideal. So, the declaration of "c" better should read

c=b.edgemask( .. ) ..


Below script addresses abovementioned issues, and includes these additional changes:

- added "HQedge" [bool]. It's slower, reckognizes edges better, is more robust against noise ... and perhaps is not suited at all for this application. So, it's just for testing & playing.
- normal edgemask is created on the original sized frame. HQedgemask is created on the (for sangnom) double-sized frame.

Without much testing:
Code:
function antialiasing( clip orig, int "th_luma", int "th_croma", string "type", int "order", int "aath", bool "HQedge") 
{

# "th_luma" and "th_croma" affect directly the edge detection: higher values = more edges filtered 
# set "order = 0" for Top Field First; order = 1 --> Bottom Field First
# aath = anti-aliasing strenght (default should be fine)


th_luma  = Default(th_luma, 20)
th_croma = Default(th_croma, 20)
type     = Default(type, "sobel")
order    = Default(order, 1)
aath     = Default(aath, 48)
HQedge   = Default(HQedge, false)
ox = orig.width
oy = orig.height
dx = orig.width * 2
dy = orig.height * 2

orig.convertToYV12()
a=last
b=lanczos4Resize(dx, dy).TurnLeft().SangNom(order,aath).TurnRight().SangNom(order,aath)

# native chroma edges:
#c=b.lanczosresize(ox,oy).EdgeMask(0, th_luma, 0, th_croma, type,Y=3,U=3,V=3)

# use luma edges for chroma:
c=b.lanczosresize(ox,oy).EdgeMask(0, th_luma, 0, th_croma, type,Y=3,U=1,V=1).FitY2UV()

d= logic( b.DEdgeMask(0,255,0,255,"5 10 5 0 0 0 -5 -10 -5", divisor=4,Y=3,U=1,V=1)
 \       ,b.DEdgeMask(0,255,0,255,"5 0 -5 10 0 -10 5 0 -5", divisor=4,Y=3,U=1,V=1)
 \       ,"max").greyscale.levels(0,0.8,128,0,255,false).FitY2UV().lanczosresize(ox,oy)
b=b.lanczosresize(ox,oy)

HQedge ? MaskedMerge(a,b,d,Y=3,U=3,V=3) : MaskedMerge(a,b,c,Y=3,U=3,V=3)
}
Just some suggestions.
__________________
- 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; 6th October 2004 at 10:29.
Didée is offline   Reply With Quote