View Single Post
Old 9th February 2007, 21:08   #11  |  Link
*.mp4 guy
Registered User
 
*.mp4 guy's Avatar
 
Join Date: Feb 2004
Posts: 1,348
Thanks for the help (!) dctfilter doesn't crash avisynth on frames larger then 352*192 now .

The script cleanup is quite nice aswell. One question though, how do you set which dct dctfilter uses?

Minor update to resizing function, defaults improved, it is now possible to set the initial taps, non mod 16 imput resolutions now work, rep code had a minor cleanup and halo removal strength is now a variable:
Code:
function wdresize(clip clp, float "sharpness", bool "u64dct", int "warp", int "thresh", int "rep", int "antihalo", int "taps", int "dehalo"){
	sharpness = default(sharpness, 2)
	u64dct = default(u64dct, true)
	warp = default(warp, 4)
	thresh = default(thresh, 50)
	rep = default(rep, 1)
	antihalo = default(antihalo, 150)
	taps = default(taps, 4)
    dehalo = default(dehalo, rep)

	cw = clp.width
	ch = clp.height

	(taps <=3) ? clp.dctus(sharpness=sharpness, u64dct=u64dct).DeHalo_alpha(ss=1, lowsens=antihalo, highsens=antihalo, rx=2, ry=2) : last

	(taps >=3) ? clp.pointresize(cw*2, ch*2).dctlimit(use64dct=u64dct, dct2=1, dct3=1, dct4=sharpness, dct5=0) : last
	
    (dehalo >=1) ? last.DeHalo_alpha(ss=1, lowsens=round((antihalo/2)*3), highsens=round((antihalo/2)*3), rx=2, ry=2) : last

	w = last.width
	h = last.height

	(taps <=3) ? pointresize(w/2, h/2) : last

	OX = m(16,Clp.Width)
	OY = m(16,Clp.Height)
	dx = ox - clp.width
	dy = oy - clp.height

	addborders(dx, dy, 0, 0)

	(rep>=2) ? last.dctlimit(use64dct=u64dct, dct2=1, dct3=1, dct4=0.5, dct5=sharpness).dctlimit(use64dct=u64dct, dct2=1, dct3=1, dct4=sharpness, dct5=0) : last
    (dehalo >=2) ? last.DeHalo_alpha(ss=1, lowsens=antihalo, highsens=antihalo, rx=2, ry=2) : last

	(rep>=3) ? last.dctlimit(use64dct=u64dct, dct2=1, dct3=1, dct4=0.5, dct5=sharpness).dctlimit(use64dct=u64dct, dct2=1, dct3=1, dct4=sharpness, dct5=0) : last
    (dehalo >=3) ? last.DeHalo_alpha(ss=1, lowsens=round((antihalo/2)*3), highsens=round((antihalo/2)*3), rx=2, ry=2) : last

	(rep>=4) ? last.dctlimit(use64dct=u64dct, dct2=1, dct3=1, dct4=0.5, dct5=sharpness).dctlimit(use64dct=u64dct, dct2=1, dct3=1, dct4=sharpness, dct5=0) : last
    (dehalo >=4) ? last.DeHalo_alpha(ss=1, lowsens=round((antihalo/2)*3), highsens=round((antihalo/2)*3), rx=2, ry=2) : last

	(rep>=5) ? last.dctlimit(use64dct=u64dct, dct2=1, dct3=1, dct4=0.5, dct5=sharpness).dctlimit(use64dct=u64dct, dct2=1, dct3=1, dct4=sharpness, dct5=0) : last
    (dehalo >=5) ? last.DeHalo_alpha(ss=1, lowsens=round((antihalo/2)*3), highsens=round((antihalo/2)*3), rx=2, ry=2) : last

	(rep>=6) ? last.dctlimit(use64dct=u64dct, dct2=1, dct3=1, dct4=0.5, dct5=sharpness).dctlimit(use64dct=u64dct, dct2=1, dct3=1, dct4=sharpness, dct5=0) : last
    (dehalo >=6) ? last.DeHalo_alpha(ss=1, lowsens=round((antihalo/2)*3), highsens=round((antihalo/2)*3), rx=2, ry=2) : last
    
    (rep>=7) ? last.dctlimit(use64dct=u64dct, dct2=1, dct3=1, dct4=0.5, dct5=sharpness).dctlimit(use64dct=u64dct, dct2=1, dct3=1, dct4=sharpness, dct5=0) : last
    (dehalo >=7) ? last.DeHalo_alpha(ss=1, lowsens=round((antihalo/2)*3), highsens=round((antihalo/2)*3), rx=2, ry=2) : last
    
    (rep>=8) ? last.dctlimit(use64dct=u64dct, dct2=1, dct3=1, dct4=0.5, dct5=sharpness).dctlimit(use64dct=u64dct, dct2=1, dct3=1, dct4=sharpness, dct5=0) : last
    (dehalo >=8) ? last.DeHalo_alpha(ss=1, lowsens=round((antihalo/2)*3), highsens=round((antihalo/2)*3), rx=2, ry=2) : last


	crop(dx, dy, 0, 0)

	awarpsharp(depth=warp, cm=0, blurlevel=1)
	awarpsharp(depth=warp, cm=0, blurlevel=1)
	awarpsharp(depth=warp, cm=0, blurlevel=1)
	awarpsharp(depth=warp, cm=0, blurlevel=1)

	mergechroma(lanczosresize(clp,clp.Width*2 ,clp.Height*2), 1)

	return(last)}
on the todo list -
-intelligent masking to tone down halos and ringing (this is going to be really hard, but worth it if I figure something out)
-chroma processing
-investigate the effects of dct-idct precision on visible artifacts after multiple frequency seperation repetitions
-tone down the flattening caused by dehaloing. (see 1)
-look into 16*16 idct speed versus 8*8 idct speed.


[edit] upsizing function updated again, now suppots up to 8 reps (which very surprisingly actually looks good on some images, though I'm beginning to suspect that the reason lenna image is used so frequently in digital image processing is that it is perfectly lowpassed... it makes every image processing algorithm look like a miracle worker)

Last edited by *.mp4 guy; 10th February 2007 at 17:45.
*.mp4 guy is offline   Reply With Quote