Log in

View Full Version : Question about Shodan's Derainbow function


Chainmax
6th May 2005, 00:42
In case you guys don't remember it, here's the script:

function DeRainbow(clip org, int "thresh")
{
assert(org.isYV12(),"DeRainbow() requires YV12 input!")
thresh = default(thresh, 10)

org_u = utoy(org)
org_v = vtoy(org)

msharpen(org, threshold = thresh, mask=true)
reduceby2()
greyscale()
uv = blur(1.5).levels(0,2.0,255,0,255, coring=false).blur(1.5).blur(1.5).levels(50,2.0,255,0,255, coring=false)

filtered_u = org_u.mipsmooth(spatial=255, temporal=255, scenechange=3, show=false, method="strong", scalefactor=0.5)
filtered_v = org_v.mipsmooth(spatial=255, temporal=255, scenechange=3, show=false, method="strong", scalefactor=0.5)

u_final = MaskedMerge(org_u, filtered_u, uv)
v_final = MaskedMerge(org_v, filtered_v, uv)

return ytouv(u_final, v_final, org)
}


function DeRainbowYUY2(clip org, int "thresh")
{
assert(org.isyuy2(),"DeRainbowYUY2() requires YUY2 input!")
thresh = default(thresh, 10)

org_yv12 = org.converttoyv12()
org_u = utoy(org).converttoyv12()
org_v = vtoy(org).converttoyv12()

msharpen(org_yv12, threshold = thresh, mask=true)
bilinearresize(last.width/2, last.height)
greyscale()
uv = blur(1.5).levels(0,2.0,255,0,255, coring=false).blur(1.5).blur(1.5).levels(50,2.0,255,0,255, coring=false)

filtered_u = org_u.mipsmooth(spatial=255, temporal=255, scenechange=3, show=false, method="superstrong", scalefactor=0.5)
filtered_v = org_v.mipsmooth(spatial=255, temporal=255, scenechange=3, show=false, method="superstrong", scalefactor=0.5)

u_final = MaskedMerge(org_u, filtered_u, uv).converttoyuy2()
v_final = MaskedMerge(org_v, filtered_v, uv).converttoyuy2()

return ytouv(u_final, v_final, org)
}

I am currently trying to process a source with some very nasty rainbowing, and the default thresh setting (10) isn't enough. I tried different settings and it seems that using higher settings remove less rainbows. I assume then that I need lower settings, but I wanted to make sure. Does anyone know if I'm right?

tritical
6th May 2005, 16:22
hm, thresh controls the threshold for the edge mask that msharpens makes... so increasing it will mean fewer pixels will be marked in the mask and decreasing means more pixels will be. That mask (after a little extra processing with blur and levels) is used to select which filtered pixels vs original pixels are used in the final output. So basically, decreasing thresh will mean more pixels will be be replaced with filtered pixel values. You might try using msharpen alone or viewing only the mask (the uv clip) to make sure the threshold is catching all areas that contain rainbows... if it already is, then lowering thresh isn't gonna help.

Chainmax
7th May 2005, 03:01
Thanks for the explanation :).