PDA

View Full Version : Fix aliasing in DV (+ upscale)


2Bdecided
28th June 2009, 15:38
I've been trying to upscale some DV footage (following recent threads) and have found that the original DV footage contains horizontal aliasing.

Here's an example...

http://www.mediafire.com/?knwzgoogtyn
(3.5MB raw DV-AVI sample straight from camcorder)

..and it becomes really obvious when I try some upscaling like...

avisource("DV.2002-07-19 13-31.40 027 sample.avi")

#tempgaussmc_alpha3()

#turnright().nnedi2(field=0,dh=false).turnleft()

turnright().nnedi2(field=0,dh=true).turnleft().nnedi2(field=0,dh=true)

spline36resize(1280,720)

limitedsharpenfaster()


(obviously uncomment tgmca3 to deinterlace - but this isn't really relevant to the horizontal aliasing)


If you uncomment the line "turnright().nnedi2(field=0,dh=false).turnleft()" you can see my first attempt at anti-aliasing using nnedi2 - but while it does remove the aliasing, it also removes too much detail - look at the wavy line on the wall at the back - it's turned into a blur by my attempt at anti-aliasing, whereas it's preserved correctly in the aliased original.

So, any ideas?

(any ideas why my old camcorder did this?!)

(I'm not looking for upscaling suggestions - I've got plenty of those filed away - it's the aliasing in the original which is problematic - how can I remove it while maintaining whatever detail is present).

Cheers,
David.

2Bdecided
28th June 2009, 20:19
I've also tried this...

mt_convolution(horizontal= " 0.353677651315323 0 -0.454728408833987 0 0.636619772367581 0 -1.06103295394597 0 3.18309886183791 5.00000000000000 3.18309886183791 0 -1.06103295394597 0 0.636619772367581 0 -0.454728408833987 0 0.353677651315323 ", vertical= " 0.353677651315323 0 -0.454728408833987 0 0.636619772367581 0 -1.06103295394597 0 3.18309886183791 5.00000000000000 3.18309886183791 0 -1.06103295394597 0 0.636619772367581 0 -0.454728408833987 0 0.353677651315323 ", u=3, v=3)

from here...

http://forum.doom9.org/showthread.php?p=1237938#post1237938

...and while it fixed the aliasing and maintains the fine detail in the background, it introduces really objectionable ringing.

Maybe I'll try to make my own filter.

Strange thing is, the aliasing isn't always present - though I can't figure out why/when it is/isn't.

Cheers,
David.

kemuri-_9
28th June 2009, 20:41
since you're using nnedi2 to double the resolution, why not use the nnedi2_rpow2 function it has for upscaling instead of calling nnedi2 twice?
see here (http://forum.doom9.org/showthread.php?p=1296626#post1296626)

*.mp4 guy
28th June 2009, 20:50
lanczosresize(912, last.height, taps=7)
mt_convolution(horizontal="-0.006115357095830530 -0.024673115491434312 0.113584371263403900 -0.212888415536200140 0.219506807702501750 -0.109571633898304650 0.010642605289070215 -0.067401167433454492 0.243459172949253760 0.659245979862367660 0.243459172949253760 -0.067401167433454492 0.010642605289070215 -0.109571633898304650 0.219506807702501750 -0.212888415536200140 0.113584371263403900 -0.024673115491434312 -0.006115357095830530", vertical=" 1 ", u=3, v=3)
yahr()

lanczosresize(1280, 720, taps=7)
Yahr()

limitedsharpenfaster()


That should work well.

If it doesn't there are some other things that work well, but they are all, atleast for this sample, needlessly complicated.

Also, the FIR filter from that thread shouldn't maintain all of the detail in the source, If you are absolutely sure that it does, I might need to take another guess at what is wrong.

[edit]
This is more complicated, but probably better.


Function blurH(clip c, int "rad", Float "CW")
{

Rad = Default(rad, 1)
CW = Default(CW, 0.5)

Center = C
Left = C.PointResize(C.width, C.height, -rad, 0, C.width, C.height)
Right = C.PointResize(C.width, C.height, rad, 0, C.width, C.height)

Average(Center, CW/2, Left, (1-CW)/2, Right, (1-CW)/2, Center, CW/2)

Return(last)
}

Function NLLH(Clip C, int "rad")
{


Rad = Default(Rad, 1)

B1 = C.BlurH(1*rad, 0.444)
B2 = C.BlurH(3*rad, 0.850)
B3 = C.BlurH(5*rad, 0.898)
B4= C.BlurH(7*rad, 0.922)

B1_D = Mt_Makediff(B1, C)
B2_D = Mt_MakeDiff(C, B2)
B3_D = Mt_MakeDiff(B3, C)
B4_D = Mt_MakeDiff(C, B4)

B2_DT = Mt_LutXY(B1_D, B2_D, " X 128 - Y 128 - X 128 - abs Y 128 - abs * 1 + * X 128 - abs Y 128 - abs * Y 128 - abs 1.915 * X 128 - abs - 0 > Y 128 - abs 1.915 * X 128 - abs - 0 ? X 128 - abs 0 > X 128 - abs -1 X 128 - abs 0 > X 128 - 1 ? / ^ 1 ? / 1 * + 1 + / + 128 + ", u=2, v=2)
B3_DT = Mt_LutXY(B2_DT, B3_D, " X 128 - Y 128 - X 128 - abs Y 128 - abs * 1 + * X 128 - abs Y 128 - abs * Y 128 - abs 2.025 * X 128 - abs - 0 > Y 128 - abs 2.025 * X 128 - abs - 0 ? X 128 - abs 0 > X 128 - abs -1 X 128 - abs 0 > X 128 - 1 ? / ^ 1 ? / 1 * + 1 + / + 128 + ", u=2, v=2)
B4_DT = Mt_LutXY(B3_DT, B4_D, " X 128 - Y 128 - X 128 - abs Y 128 - abs * 1 + * X 128 - abs Y 128 - abs * Y 128 - abs 2.077 * X 128 - abs - 0 > Y 128 - abs 2.077 * X 128 - abs - 0 ? X 128 - abs 0 > X 128 - abs -1 X 128 - abs 0 > X 128 - 1 ? / ^ 1 ? / 1 * + 1 + / + 128 + ", u=2, v=2)

Mt_AddDiff(B4_DT, C)

Return(last)
}







NLLH()

mt_convolution(horizontal=" 0.000001065433025438 -0.000016063451766901 0.000104412436485276 -0.000360697507858256 0.000574268400669151 0.000417649745941195 -0.003967672586441010 0.007304608821868880 -0.000365443527698423 -0.023179560899734431 0.041660562157630920 -0.003967672586440983 -0.118038259446620930 0.269801735877990670 0.660062134265899660 0.269801735877990670 -0.118038259446620930 -0.003967672586440983 0.041660562157630920 -0.023179560899734431 -0.000365443527698423 0.007304608821868880 -0.003967672586441010 0.000417649745941195 0.000574268400669151 -0.000360697507858256 0.000104412436485276 -0.000016063451766901 0.000001065433025438", \
vertical=" 1 ", u=3, v=3)

mt_convolution(horizontal="-0.006115357095830530 -0.024673115491434312 0.113584371263403900 -0.212888415536200140 0.219506807702501750 -0.109571633898304650 0.010642605289070215 -0.067401167433454492 0.243459172949253760 0.659245979862367660 0.243459172949253760 -0.067401167433454492 0.010642605289070215 -0.109571633898304650 0.219506807702501750 -0.212888415536200140 0.113584371263403900 -0.024673115491434312 -0.006115357095830530", vertical=" 1 ", u=3, v=3)

lanczosresize(720, 720, taps=7)
Yahr
lanczosresize(1280, 720, taps=7)
Yahr

limitedsharpenfaster()