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.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 8th March 2014, 18:34   #1  |  Link
bxyhxyh
Registered User
 
Join Date: Dec 2011
Posts: 354
FadeDeRainbow - Derainbowing Script

My try to remove rainbows.
If you want to tweak this filter, you're welcome.
Default values work good.

Code:
# FadeDeRainbow v0.32
# 2014-08-14
# Requirements:
# mvtools 2.5.11.3 or mvtools 2.6.0.5 from Dither Tools or newer
# masktools2-a48 or TurboPascal's masktool2 or newer
# Progressive video

Function FadeDeRainbow(clip c, int "thsad", int "diff", int "th", bool "show")
{
  thsad = default(thsad,3000)      # thsad value for MDegrain, derainbowing strength
  diff  = default(diff,3)          # Range: 0-127, Difference between degrained and original. 
                                   # If you set it too high, it inpands mask, therefore it can't remove rainbows.
  show  = default(show,false)      # shows mask
  th    = default(th,10)           # threshold for chubbyrain2's mask
  frame = c.framecount-1
  bif   = c.bifrost(interlaced=false)
  bif
  ma=scriptclip("""
    c=last
    prev_frame=current_frame<>0 ? current_frame-1 : 0
    u=UToY8()
    v=VToY8()
    m1=mt_lutxy(u,getframe(u,prev_frame),"x y - 2 - 255 * y x - 2 - 255 * |u")
    m2=mt_lutxy(v,getframe(v,prev_frame),"x y - 2 - 255 * y x - 2 - 255 * |u")
    mask=mt_logic(m1,m2,"or").pointresize(c.width,c.height)
    mask.ConvertToYV12()
  """)

  uc    = c.UToY8().mt_convolution(horizontal="1",vertical="1 -2 1")
  vc    = c.VToY8().mt_convolution(horizontal="1",vertical="1 -2 1")

  mc    = mt_lutxy(uc,vc,"x y + "+string(th)+" > 256 0 ?").pointresize(c.width,c.height).mt_expand()

  uo    = bif.UToY8()
  vo    = bif.VToY8()

  super = bif.MSuper(sharp=2,rfilter=1)
  bv2   = super.Manalyse(isb=true,delta=2,overlap=8,blksize=16,truemotion=false)
  bv1   = super.Manalyse(isb=true,delta=1,overlap=8,blksize=16,truemotion=false)
  fv1   = super.Manalyse(isb=false,delta=1,overlap=8,blksize=16,truemotion=false)
  fv2   = super.Manalyse(isb=false,delta=2,overlap=8,blksize=16,truemotion=false)
  deg   = MDegrain2(bif,super,bv1,fv1,bv2,fv2,thsad=thsad,plane=3)

  ud    = deg.UToY8()
  vd    = deg.VToY8()

  diff  = string(diff)
  m1    = mt_lutxy(uo,ud,"x y - "+diff+" - 255 * y x - "+diff+" - 255 * |u")
  m2    = mt_lutxy(vo,vd,"x y - "+diff+" - 255 * y x - "+diff+" - 255 * |u")
  mb    = mt_logic(m1,m2,"or").pointresize(c.width,c.height)
  mask  = mt_logic(mt_logic(ma,mb,"and"),mc,"and")

  norainbow = Overlay(bif,deg,mask=mask)
  return !show ? norainbow : mask
}

Function getFrame(clip c, int frameNum)
{
   return frameNum<>0 ? c.trim(frameNum,frameNum) : c.trim(frameNum,-1)
}

Changelog:
v0.32: 2014-08-14
- Minor tweak
v0.31: 2014-06-28
- Little speed up
v0.3: 2014-05-09
- Took chubbyrain2's masking
- Uses 2 times low memory
- Added Bifrost()
- Fixed chroma ghost bug... i hope
- Removed interlaced parameter which caused weird artifact
v0.24: 2014-04-20
- Changed default thsad value
v0.23: 2014-04-19
- Calls 2 resize functions instead of 8.
- If mask is too big make it black mask, because rainbows don't appear in big area.
v0.22: 2014-04-03
- Replaced subtract() with mt_lutxy()
v0.21: 2014-03-13
- minor bug fix
v0.2: 2014-03-11
- added interlaced parameter
- minor tweak
v0.1: 2014-03-09
- Initial Release

Last edited by bxyhxyh; 14th August 2014 at 17:31. Reason: new version
bxyhxyh is offline   Reply With Quote
Old 20th May 2014, 15:38   #2  |  Link
bxyhxyh
Registered User
 
Join Date: Dec 2011
Posts: 354
Previous versions caused ghosting artifact.
Now, this v0.3 is something usable.
bxyhxyh is offline   Reply With Quote
Reply

Tags
derainbow

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:08.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.