Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
16th September 2008, 03:10 | #1 | Link |
Registered User
Join Date: Nov 2003
Posts: 324
|
Rainbow Removers
Some persons here have asked recently for "derainbowing" scripts. Some have "rainbow" problems but didn't know how to describe the problem.
There have been many scripts. Some work only for some specific videos. Others seem to work "in general." Some are simple filters, others are functions. I've not indicated in functions which plugins are required. I'm sorry about that. Most often you will need some version of masktools. Older scrips will need older versions. Here are those that I've collected: == # ChubbyDeRain by lothar 04Jan05 Function ChubbyDeRain(clip c, int "th", int "radius", bool "show") { #based on Sh0dan's DeRainbow & Mug Funky's ChubbyRain th = default(th,5) radius = default(radius,3) show = default(show,false) u = c.utoy() v = c.vtoy() uc = u.yv12convolution(horizontal="1",vertical="1 -2 1",Y=3,U=0,V=0) #,usemmx=true vc = v.yv12convolution(horizontal="1",vertical="1 -2 1",Y=3,U=0,V=0) cc2 = c.yv12convolution(horizontal="1",vertical="1 2 1",Y=2,U=3,V=3).mipsmooth(spatial=255, temporal=255, scenechange=3, show=false, method="strong", scalefactor=0.5) rainbow=yv12lutxy(uc,vc,Yexpr=string("x y + "+string(th)+" > 256 0 ?")).bicubicresize(c.width,c.height).expand(y=3,u=-128,v=-128) ms = MaskedMerge(c,cc2,rainbow, Y=1, U=3, V=3) show==true? rainbow : ms } == ChubbyRain2 # === by Lothar #based on Mug Funky's ChubbyRain # requires MaskTools 1.5.6, Bifrost, CNR2 # clip must be YV12 function ChubbyRain2(clip c, int "th", int "radius", bool "show", int "sft") { th = default(th,10) radius = default(radius,10) show = default(show,false) sft = default (sft, 10) u = c.utoy() v = c.vtoy() uc = u.yv12convolution(horizontal="1",vertical="1 -2 1",Y=3,U=0,V=0) vc = v.yv12convolution(horizontal="1",vertical="1 -2 1",Y=3,U=0,V=0) cc = c.yv12convolution(horizontal="1",vertical="1 2 1",Y=2,U=3,V=3).Bifrost(interlaced=false).cnr2().temporalsoften(radius,0,sft,2,2) rainbow=yv12lutxy(uc,vc,Yexpr=string("x y + "+string(th)+" > 256 0 ?")).pointresize(c.width,c.height).expand(y=3,u=-128,v=-128)#.blur(1.5) overlay(c,cc,mask=rainbow) show==true? rainbow : last } == #--- yv12 only # by Shodan 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) } == For yuy2 only: (shodan?) 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) } == For yv12 only: (shodan?) function DeRainbowYV12(clip org) { org_u = utoy(org) org_v = vtoy(org) msharpen(org, threshold = 10, mask=true) reduceby2() greyscale() uv = blur(1.5).levels(0,2.0,255,0,255).blur(1.5) filtered_u = org_u.blur(1.5).blur(1.5).blur(1.5).temporalsoften(2,255,0,3,2) filtered_v = org_v.blur(1.5).blur(1.5).blur(1.5).temporalsoften(2,255,0,3,2) u_final = MaskedMerge(org_u, filtered_u, uv) v_final = MaskedMerge(org_v, filtered_v, uv) return ytouv(u_final, v_final, org) } / suggestion: change blur(1.5) to blur(1.47) === # mfRainbow v0.31 by mf # Derainbows in areas of high Y, U and V frequencies, which fluctuate heavily. # # I don't claim copyright but I ask you to treat my script # fairly. # # Changelog: Tweakable scenechange detection for tough sources # # Requires MaskTools.dll , Warpsharp.dll function mfRainbow(clip input, string "mode", int "strength", int "scd", bool "post") { strength = Default(strength, 255) # processing strength, 0-255 scd = Default(scd, 10) # scenechange detection input.UnsharpMask(200).UnsharpMask(200).EdgeMask(3, 255, 255, 255, "roberts", Y=3, V=1,\ U=1).Deflate().Levels(0, 1.0, 45, 0, 255).Blur(1.0).Deflate().Levels(0, 1.0, 75, 0, \ 255).Deflate().Deflate().Deflate().Greyscale() ymask = last input.UToY() u = last u.Unsharpmask(500).Unsharpmask(500).EdgeMask(3, 255, 255, 255, "roberts", \ Y=3, V=1, U=1).Levels(0, 1.0, 100, 0, 255).Greyscale() LanczosResize(input.width, input.height) umask = last input.VToY() v = last v.Unsharpmask(500).Unsharpmask(500).EdgeMask(3, 255, 255, 255, "roberts", \ Y=3, V=1, U=1).Levels(0, 1.0, 75, 50, 255).Greyscale() LanczosResize(input.width, input.height) vmask = last Overlay(ymask, umask, mode="lighten") yumask = last Overlay(yumask, vmask, mode="hardlight") yuvmask = last u.TemporalSoften(4,4,0, 12, 2).TemporalSoften(4,10,0, 12, 2) YV12Subtract(last, u) PointResize(input.width, input.height) Levels(100, 1, 155, 0, 255, false) MotionMask(thY1=0, thY2=255, y=3,u=1,v=1) Levels(0, 1, 25, 0, 255, false) GreyScale() uflucts = last v.TemporalSoften(4,4,0, 12, 2).TemporalSoften(4,10,0, 12, 2) YV12Subtract(last, v) PointResize(input.width, input.height) Levels(100, 1, 155, 0, 255, false) MotionMask(thY1=0, thY2=255, y=3,u=1,v=1) Levels(0, 1, 25, 0, 255, false) GreyScale() vflucts = last Overlay(uflucts, vflucts, mode="lighten") uvflucts = last Overlay(yuvmask, uvflucts, mode="hardlight") Inflate().Inflate().Levels(0, 1, 100, 0, 255, false) Greyscale() bigedgemask = last LanczosResize(u.width, u.height) edgemask = last input.UToY().temporalsoften(50,255,1,scd,2) derainbowu = last input.VToY().temporalsoften(50,255,1,scd,2) derainbowv = last edgerainbowu = MaskedMerge(u, derainbowu, edgemask, Y=3, U=1, V=1) edgerainbowv = MaskedMerge(v, derainbowv, edgemask, Y=3, U=1, V=1) edgerainbow = YToUV(edgerainbowu, edgerainbowv, input.Greyscale()) input.MergeChroma(edgerainbow) } === More derainbow: Convolution3D(1, 0, 255, 0, 20, 50, 0) deen("a3d",1,0,10) MergeChroma(MSmooth()) === # RainbowRemove # fft3dfilter over U and V planes very effective against VHS rainbows FFT3DFilter(sigma=1,bt=3,bw=32,bh=32,ow=16,oh=16) === ############################################################################ # This is a script which works with SSIQ. The basic problem with SSIQ is # that it can alter the color on the entire picture, which is a very very # bad thing. # All we want to do is remove rainbows, while leaving everything else alone. # This filter first applies SSIQ to the entire picture. Then it locates the # edges. # Finally, it layers ONLY the de-rainbowed edges onto the orig video. # # # Filter Requirements: SSIQ() ############################################################################ #LoadPlugin("mt_masktools.dll") #LoadPlugin("SSIQ.dll") #input = DirectShowSource("...") #SmartSSIQ(input, 1) function SmartSSIQ(clip input, int "strength") { strength = default(strength, 1) #processing strength, 0-255 # apply rainbow remover to the entire video derainbow = input.SSIQ(11, 300, false) # create an edge mask from the rainbow video lutexpr = "x .2 ^ 110 *" # uncomment to use masktools 1 edgemask = input.edgemask(thY1=1, thY2=255, type="sobel").inflate().yv12lut(yexpr=lutexpr).GreyScale() #edgemask = input.mt_edge(thY1=1, thY2=255, mode="sobel").mt_inflate().mt_lut(yexpr=lutexpr).GreyScale() # apply ssiq only to masked area, using "strength" result = overlay(input, derainbow, mode="blend", mask=edgemask, opacity=strength/255.0).Limiter() return result } === Non-Interlaced Video: BiFrost(interlaced=false,scenelumathresh=6,variation=10) temporalsoften(15,20,35,10,2) #radius,luma_thresh,chroma_thresh,scenechange,mode / can cause "ghosts" === Rainbow Killer by sh0dan: requires msharpen by Donald Graft and MaskTools by Kuruso and YV12 org = last org_u = utoy(org) org_v = vtoy(org) msharpen(threshold = 10, mask=true) reduceby2() greyscale() uv = blur(1.5).levels(0,2.0,255,0,255).blur(1.5) filtered_u = org_u.blur(1.5).blur(1.5).blur(1.5).temporalsoften(2,255,0,3,2) filtered_v = org_v.blur(1.5).blur(1.5).blur(1.5).temporalsoften(2,255,0,3,2) u_final = MaskedMerge(org_u, filtered_u, uv) v_final = MaskedMerge(org_v, filtered_v, uv) ytouv(u_final, v_final, org) / suggestion: change blur(1.5) to blur(1.47) == # Rainbow remover by foxyshadis # requires MaskTools, function SmartSSIQ(clip input, int "strength") { strength = default(strength, 255) #processing strength, 0-255 # apply rainbow remover to the entire video derainbow = input.SSIQ(11, 300, false) # create an edge mask from the rainbow video edgemask = input.msharpen().mt_edge(thY1=0, thY2=255, thC1=255, thC2=255, mode="sobel").mt_inflate().GreyScale().Levels(0, 5, 255, 0, 255, coring=false) # now layer the mask onto the input result = overlay(input, derainbow, mode="blend", mask=edgemask, opacity=strength/255.0).Limiter() return result } == # Anti-Rainbow: avisource("your.avi") fft3dfilter(sigma=3,sigma2=3,sigma3=12,sigma4=3,bt=3,plane=1) fft3dfilter(sigma=3,sigma2=3,sigma3=12,sigma4=3,bt=3,plane=2) == # Rainbow remover by foxyshadis # requires MaskTools, function SmartSSIQ(clip input, int "strength") { strength = default(strength, 255) #processing strength, 0-255 # apply rainbow remover to the entire video derainbow = input.SSIQ(11, 300, false) # create an edge mask from the rainbow video edgemask = input.msharpen().mt_edge(thY1=0, thY2=255, thC1=255, thC2=255, mode="sobel").mt_inflate().GreyScale().Levels(0, 5, 255, 0, 255, coring=false) # now layer the mask onto the input result = overlay(input, derainbow, mode="blend", mask=edgemask, opacity=strength/255.0).Limiter() return result } === Well, that's my collection, except for one that I can't find on this forum. As posted above, "Most often you will need some version of masktools." That's because a number of these scripts use an old version of Masktools and the new versions don't always work the same as the new versions. Usually, for the older versions, only 1.4.16, 1.5.6 and 1.5.8 only are needed. The later MT_Masktools_2 do not interfere and/or may be used in later Rainbow Killing scripts. I just don't have the time, at the moment to give the full requirements for each script as they have been gathered over time. An aside: There was one script that doesn't seem to be on the server that I definitely modified to help someone a few years back. It was sh0dan's and and worked well for one section of a clip, but the thread seems to be gone. Don't consider this as the last word; experiment! |
Thread Tools | Search this Thread |
Display Modes | |
|
|