Advertisement
Guest User

SwitchHead v1.0 with additional top mod

a guest
Apr 10th, 2016
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ImageSource("Switch Noise.png").ConvertToYV24()
  2.  
  3. # Correct the bottom.
  4. SwitchHead(2)
  5.  
  6. full = last
  7.  
  8. # Correct the top.
  9. # This is inefficient (slow) and an ugly way to script this.
  10.  
  11. good = 3
  12.  
  13. full.Crop(0,good,-0,-0) # crop off "good" lines at the very top
  14. SwitchHead_Top(1) # actual correction
  15. StackVertical(full.Crop(0,0,-0,good),last) # stack the original "good" lines with the lower corrected lines
  16.  
  17.  
  18.  
  19. # SwitchHead v1.0
  20. #
  21. #   Parameters are number of discolored bottom-lines to correct, and the method to be used.
  22. #
  23. #   method = 0: grab N lines from above correction area, *reflect* them downward to fill correction area
  24. #   method = 1: grab N lines from above correction area, *stretch* them downward to fill correction area
  25. #  
  26. #   Note: lines parameter must adhere to cropping requirements for the input pixel format (mod2 for YV12).
  27. #
  28. function SwitchHead(clip c, int lines, int "method") {
  29.    method = Default(method,0)
  30.  
  31.    U = c.UtoY() # separate U channel
  32.    V = c.VtoY() # separate V channel
  33.  
  34.    U = U.Crop(0,0,-0,-lines) # remove discolored portion
  35.    extra1 = U.FlipVertical().Crop(0,0,-0,lines) # the last 'lines' pixels of the U channel *reflected*
  36.    extra2 = U.Crop(0,U.height-lines,-0,-0).PointResize(U.width,lines) # the last 'lines' pixels of the U channel *stretched*
  37.    U1 = StackVertical(U,extra1)
  38.    U2 = StackVertical(U,extra2)
  39.  
  40.    V = V.Crop(0,0,-0,-lines) # remove discolored portion
  41.    extra1 = V.FlipVertical().Crop(0,0,-0,lines) # the last 'lines' pixels of the V channel *reflected*
  42.    extra2 = V.Crop(0,V.height-lines,-0,-0).PointResize(V.width,lines) # the last 'lines' pixels of the V channel *stretched*
  43.    V1 = StackVertical(V,extra1)
  44.    V2 = StackVertical(V,extra2)
  45.  
  46.    method == 0 ? YtoUV(U1,V1,c) : YtoUV(U2,V2,c) # mix the separate U and V with the original Y
  47. }
  48.  
  49. # SwitchHead_Top v1.0
  50. #
  51. #   Parameters are number of discolored top-lines to correct, and the method to be used.
  52. #
  53. #   See SwitchHead for more info...
  54. #
  55. function SwitchHead_Top(clip c, int lines, int "method") {
  56.    method = Default(method,0)
  57.    
  58.    U = c.UtoY() # separate U channel
  59.    V = c.VtoY() # separate V channel
  60.    
  61.    U = U.Crop(0,lines,-0,-0) # remove discolored portion
  62.    extra1 = U.Crop(0,0,-0,lines).FlipVertical() # the first 'lines' pixels of the U channel *reflected*
  63.    extra2 = U.Crop(0,0,-0,lines).PointResize(U.width,lines) # the first 'lines' pixels of the U channel *stretched*
  64.    U1 = StackVertical(U,extra1)
  65.    U2 = StackVertical(U,extra2)
  66.    
  67.    V = V.Crop(0,lines,-0,-0) # remove discolored portion
  68.    extra1 = V.Crop(0,0,-0,lines).FlipVertical() # the first 'lines' pixels of the V channel *reflected*
  69.    extra2 = V.Crop(0,0,-0,lines).PointResize(V.width,lines) # the first 'lines' pixels of the V channel *stretched*
  70.    V1 = StackVertical(V,extra1)
  71.    V2 = StackVertical(V,extra2)
  72.    
  73.    method == 0 ? YtoUV(U1,V1,c) : YtoUV(U2,V2,c) # mix the separate U and V with the original Y
  74. }[/code]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement