kriNon

Untitled

Sep 25th, 2017
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.60 KB | None | 0 0
  1. import vapoursynth as vs
  2.  
  3. def retinex_y(clip, out_format = None):
  4.     #-------------------------------------------------------------------------------------------------------------------------------------
  5.    
  6.     core = vs.get_core()
  7.    
  8.     if out_format is None:
  9.         out_format = clip.format
  10.        
  11.     #-------------------------------------------------------------------------------------------------------------------------------------
  12.    
  13.     intformat = core.register_format(clip.format.color_family, vs.INTEGER, 16, 0, 0)
  14.    
  15.     clip_in = core.resize.Spline36(clip, format=intformat.id)
  16.     retinex = core.retinex.MSRCP(clip_in)
  17.     retinex_out = core.resize.Spline36(retinex, format=out_format.id)
  18.     clip_out = core.resize.Spline36(clip, format=out_format.id)
  19.     shuffled = core.std.ShufflePlanes([retinex_out, clip_out, clip_out], [0,1,2], colorfamily=out_format.color_family)
  20.    
  21.     return shuffled
  22.    
  23. # END OF retinex_y(clip, out_format = None)
  24. #=========================================================================================================================================
  25.  
  26. def cond_deint(clip, deinterlaced, cthresh = None, blockx = None, blocky = None, chroma = None, mi = None, metric = None):
  27.     core = vs.get_core()
  28.    
  29.     if not isinstance(clip, vs.VideoNode):
  30.         raise TypeError('''cond_deint: 'clip' argument is not a clip''')
  31.        
  32.     if not isinstance(deinterlaced, vs.VideoNode):
  33.         raise TypeError('''cond_deint: 'deinterlaced' argument is not a clip''')
  34.        
  35.     is_combed_arguments = {
  36.         'cthresh': cthresh,
  37.         'blockx': blockx,
  38.         'blocky': blocky,
  39.         'chroma': chroma,
  40.         'mi': mi,
  41.         'metric': metric,
  42.     }
  43.    
  44.     old_format = clip.format
  45.     new_format = core.register_format(old_format.color_family, vs.INTEGER, 16, old_format.subsampling_w, old_format.subsampling_h)
  46.    
  47.     refOriginal = core.resize.Point(clip, format=new_format.id)
  48.     refOriginal = core.tdm.IsCombed(refOriginal, **is_combed_arguments)
  49.     refEnhanced = retinex_y(clip, new_format)
  50.     refEnhanced = core.tdm.IsCombed(refEnhanced, **is_combed_arguments)
  51.    
  52.     def cond_deint_transfer_property(n, f):
  53.         fout = f[1].copy()
  54.         if f[0].props._Combed:
  55.             fout.props._Combed = True
  56.         return fout
  57.  
  58.     combProps = core.std.ModifyFrame(refEnhanced, [refOriginal, refEnhanced], cond_deint_transfer_property)
  59.    
  60.     final = core.std.FrameEval(clip, lambda n, f: deinterlaced if f.props._Combed else clip, combProps)
  61.    
  62.     return final
  63.    
  64. # END OF cond_deint(clip, deinterlaced, cthresh = None, blockx = None, blocky = None, chroma = None, mi = None, metric = None)
  65. #=========================================================================================================================================
Advertisement
Add Comment
Please, Sign In to add comment