Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ImageSource("Switch Noise.png").ConvertToYV24()
- # Correct the bottom.
- SwitchHead(2)
- full = last
- # Correct the top.
- # This is inefficient (slow) and an ugly way to script this.
- good = 3
- full.Crop(0,good,-0,-0) # crop off "good" lines at the very top
- SwitchHead_Top(1) # actual correction
- StackVertical(full.Crop(0,0,-0,good),last) # stack the original "good" lines with the lower corrected lines
- # SwitchHead v1.0
- #
- # Parameters are number of discolored bottom-lines to correct, and the method to be used.
- #
- # method = 0: grab N lines from above correction area, *reflect* them downward to fill correction area
- # method = 1: grab N lines from above correction area, *stretch* them downward to fill correction area
- #
- # Note: lines parameter must adhere to cropping requirements for the input pixel format (mod2 for YV12).
- #
- function SwitchHead(clip c, int lines, int "method") {
- method = Default(method,0)
- U = c.UtoY() # separate U channel
- V = c.VtoY() # separate V channel
- U = U.Crop(0,0,-0,-lines) # remove discolored portion
- extra1 = U.FlipVertical().Crop(0,0,-0,lines) # the last 'lines' pixels of the U channel *reflected*
- extra2 = U.Crop(0,U.height-lines,-0,-0).PointResize(U.width,lines) # the last 'lines' pixels of the U channel *stretched*
- U1 = StackVertical(U,extra1)
- U2 = StackVertical(U,extra2)
- V = V.Crop(0,0,-0,-lines) # remove discolored portion
- extra1 = V.FlipVertical().Crop(0,0,-0,lines) # the last 'lines' pixels of the V channel *reflected*
- extra2 = V.Crop(0,V.height-lines,-0,-0).PointResize(V.width,lines) # the last 'lines' pixels of the V channel *stretched*
- V1 = StackVertical(V,extra1)
- V2 = StackVertical(V,extra2)
- method == 0 ? YtoUV(U1,V1,c) : YtoUV(U2,V2,c) # mix the separate U and V with the original Y
- }
- # SwitchHead_Top v1.0
- #
- # Parameters are number of discolored top-lines to correct, and the method to be used.
- #
- # See SwitchHead for more info...
- #
- function SwitchHead_Top(clip c, int lines, int "method") {
- method = Default(method,0)
- U = c.UtoY() # separate U channel
- V = c.VtoY() # separate V channel
- U = U.Crop(0,lines,-0,-0) # remove discolored portion
- extra1 = U.Crop(0,0,-0,lines).FlipVertical() # the first 'lines' pixels of the U channel *reflected*
- extra2 = U.Crop(0,0,-0,lines).PointResize(U.width,lines) # the first 'lines' pixels of the U channel *stretched*
- U1 = StackVertical(U,extra1)
- U2 = StackVertical(U,extra2)
- V = V.Crop(0,lines,-0,-0) # remove discolored portion
- extra1 = V.Crop(0,0,-0,lines).FlipVertical() # the first 'lines' pixels of the V channel *reflected*
- extra2 = V.Crop(0,0,-0,lines).PointResize(V.width,lines) # the first 'lines' pixels of the V channel *stretched*
- V1 = StackVertical(V,extra1)
- V2 = StackVertical(V,extra2)
- method == 0 ? YtoUV(U1,V1,c) : YtoUV(U2,V2,c) # mix the separate U and V with the original Y
- }[/code]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement