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 > VapourSynth
Register FAQ Calendar Today's Posts Search

Reply
 
Thread Tools Search this Thread Display Modes
Old 25th October 2015, 15:48   #1  |  Link
bebs
Registered User
 
Join Date: Oct 2015
Location: Switzerland
Posts: 6
Check if porting is correct : ChubbyRain for VapourSynth

Here is my port from ChubbyRain (http://avisynth.nl/index.php/ChubbyRain)

Original code :
Code:
# http://avisynth.nl/index.php/ChubbyRain

function ChubbyRain(clip c, int "th", int "radius", bool "show", bool "interlaced")
{
	
	th = default(th,10)
	radius = default(radius,3)
	show = default(show,false)
	interlaced = default(interlaced, false)
	
	c = interlaced==true? c.separatefields() : c
	
	u = c.utoy()
	v = c.vtoy()
	
	uc = u.mt_convolution(horizontal="1",vertical="1 -2 1",Y=3,U=0,V=0)
	vc = v.mt_convolution(horizontal="1",vertical="1 -2 1",Y=3,U=0,V=0)
	
	cc = c.mt_convolution(horizontal="1",vertical="1 2 1",Y=2,U=3,V=3).temporalsoften(radius,0,255,2,2)
	
	rainbow = mt_lutxy(uc,vc,Yexpr=string("x y + "+string(th)+" > 256 0 ?")).pointresize(c.width,c.height).mt_expand(y=3,u=-128,v=-128)
	
	overlay(c,cc,mask=rainbow)
	
	output = show==true? rainbow : interlaced==true? last.weave() : last
  
    return output
	
}

My port :
Code:
def ChubbyRain(clip, th = 10, radius = 3 , show= False, interlaced = False, tff = True):
	core = vs.get_core()
	if interlaced is True:
		res = core.std.SeparateFields(clip=clip, tff=tff)
	else:
		res = clip
	
	y = core.std.ShufflePlanes(res, planes=0, colorfamily=vs.GRAY)
	u = core.std.ShufflePlanes(res, planes=1, colorfamily=vs.GRAY)
	v = core.std.ShufflePlanes(res, planes=2, colorfamily=vs.GRAY)
	
	uc = core.std.Convolution(u, [1,-2,1], mode = "v")
	vc = core.std.Convolution(v, [1,-2,1], mode = "v")
	

	ucc = core.std.Convolution(u, [1,2,1], planes=0, mode = "v")
	vcc = core.std.Convolution(v, [1,2,1], planes=0, mode = "v")
	
	cc = core.std.ShufflePlanes([y,ucc,vcc], planes=[0, 0, 0], colorfamily=vs.YUV)	
	cc = core.focus.TemporalSoften(cc, radius=radius,luma_threshold=0, chroma_threshold=255 ,scenechange=2 , mode=2)
	
	expr = "x y + " + str(th) + " > 256 0 ?"

	rainbow = core.std.Expr([uc,vc],expr)
	rainbow = core.resize.Point(rainbow, res.width, res.height)
	rainbow = core.generic.Maximum(rainbow)

	resfinal = core.std.MaskedMerge(res, cc, rainbow)
	#resfinal = Overlay(clipa=res, clipb=cc, mask=rainbow)
	
	if show is True:
		output = rainbow
	else:
		if interlaced is True:
			output = core.std.DoubleWeave(resfinal,tff=tff)
			output = core.std.SelectEvery(output, 2, 0)
		else:
			output = resfinal

	return output

Is this correct ?
Some rainbow are not catch but i don't understand why
bebs is offline   Reply With Quote
Reply


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 12:00.


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