View Single Post
Old 16th February 2012, 16:01   #13  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Here from an example clip courtesy of JohnMeyer from his thread here:-
http://forum.doom9.org/showthread.php?t=162599




The clip in question is 3:2 pulldown that has been resized as if progressive.

Pic1 is the original, 2nd is a Blur(0,1) used as a Dectection clip,
3rd pic is ExBlend() output, and pic 4 is McDegrained ExBlend output.

ExBlend now outputs a command file for ClipClop() frame/range replacement plugin
so that you can use eg McDegrain on the clip and then pluck out the recovered frames
and put them back into the original clip again.
ExBlend also implements now native decimation, so that step is no longer necessary.
In addition, ExBlend, exposes some of it's inner working so that an advanced scriptor
could perhaps do some real clever deblending that is beyond ExBlend.

There follows a script that actually does the deblending itself, and the McDegrained
output of it is indistinguishable from the McDregrained ExBlend output.
There is a little redundancy in the script but I'll give it as supplied in the new version zip.

Code:
# ##########################################################################
# Unblend frames in script, use ExBlend() only for detection and decimation.
# Raw frames extracted from source/Dclip and unblended via script,
# then put back into decimated clip.
#
# Requires mt_MaskTools, MCDegrain, ClipClop() & Prune()
#
# ##########################################################################
Import("MCDegrain.avs")

AVISource("problem video.avi")
Crop(2,0,-2,-0) # VDUB DONT Like 636 width)

DCLIP=Blur(0.0,1.0) # Required as bad combing due to resize on Telecine clip.

#Return Exblend(mode=1,CompUB=2,Dclip=DCLIP) 			# 1st Pass to create ExBlend.XBD

ADJACENT=4
BLENDED=0
#
ORG=Exblend(mode=2,disp=0,CompUB=0,dclip=DCLIP) # Original combed Clip, Decimated
EXB=ClipClop(ORG,ExBlend(mode=2,CompUB=2,dclip=DCLIP).MCDegrain(3),CMD="ExBlend_Decimated.Txt") # ExBlend clip with denoising
# Above, Decimate=true, is default in Mode 2.
# Decimated clip with Frames Adjacent to Blend index 1 (from Dclip, [CompUB==2])
A1=Exblend(mode=2,disp=ADJACENT,Decimate=true,CompUB=2,dclip=DCLIP,Decompix=1)
# Decimated clip with Frames Blend index 1 (from Dclip, [CompUB==2])
IX1=Exblend(mode=2,disp=BLENDED,Decimate=true,CompUB=2,dclip=DCLIP,Decompix=1)
# Decimated clip with Frames Blend index 2 (from Dclip, [CompUB==2])
IX2=Exblend(mode=2,disp=BLENDED,Decimate=true,CompUB=2,dclip=DCLIP,Decompix=2)
# Decimated clip with Frames Adjacent to Blend index 2 (from Dclip, [CompUB==2])
A2=Exblend(mode=2,disp=ADJACENT,Decimate=true,CompUB=2,dclip=DCLIP,Decompix=2)
###########################################################################
# To recover a blend component frame, we use:
# (IX * 2) - A, ie ((blended_frame * 2) - Adjacent_frame)
#
# For Chroma,
# (((IX - 128) * 2) - (A - 128)) + 128
# IX*2 - (128 *2) - A + 128 + 128
# IX*2 - A - (128 *2) + 128 + 128
# IX*2 - A (ie same as for Luma).
###########################################################################
#Below 2 ClipClops NOT NECESSARY, X & Y same frame in non blended frames, however, including the
# ClipClop's, will be faster as non blended frames taken from A1 instead of mt_lutxy() output.
# As mt_lutxy affects all frames we recover the good non-blended frames from any decimated clip (A1), using ClipClop.
# 1st component unblended frames, (IX1 * 2) - A1
Component1=ClipClop(A1,mt_lutxy(IX1,A1,"x 2 * y -",Y=3, U=3, V=3),"ExBlend_Decimated.Txt")
# 2nd component unblended frames, (IX2 * 2) - A2
Component2=ClipClop(A1,mt_lutxy(IX2,A2,"x 2 * y -",Y=3, U=3, V=3),"ExBlend_Decimated.Txt")
###########################################################################
# Optional Denoise Component clips (Recovering from A1 again as McDegrain changes good frames too)
#Component1=ClipClop(A1,Component1.McDegrain(3),CMD="ExBlend_Decimated.Txt") # Can comment out
#Component2=ClipClop(A1,Component2.McDegrain(3),CMD="ExBlend_Decimated.Txt") # Can comment out

# Blend both component frames together to 'iron out' noise, [Should NOT alter good frames (same frame) ie (Z + Z) / 2 = Z].
Fixed = Merge(Component1,Component2) # (C1 + C2) / 2
###########################################################################
# Optional Denoise completely recovered clip. (Restore good frames again).
Fixed=ClipClop(A1,Fixed.McDegrain(3),CMD="ExBlend_Decimated.Txt") # Can Comment out

FixedFramesOnly = Prune(Fixed ,Fixed ,CMD="ExBlend_Decimated.Txt")
###########################################################################
#Return FixedFramesOnly
#Return Fixed

D=ClipDelta(EXB,Fixed)
TOP=Stackhorizontal(ORG,fixed)
BOT=Stackhorizontal(EXB,D)
return Stackvertical(TOP,BOT)
######################################
#   ORIGINAL CLIP  | SCRIPT UNBLEND  #
# ---------------------------------- #
# EXBLEND DENOISE  | Diff EXB-SCRIPT #
######################################

Function ClipDelta(clip clip1,clip clip2,bool "amp",bool "show") {
# Return Clip Difference of input clips (amp==true = Amplified, show==true = show background)
	amp=Default(amp,false)
	show=Default(show,false)
	c2=clip1.levels(128-32,1.0,128+32,128-32,128+32).greyscale()
	c1=clip1.subtract(clip2)
	c1=(amp)?c1.levels(127,1.0,129,0,255):c1
	return (show)?c1.Merge(c2):c1
}
Here @ full size. (Note the FixBlendIVTC version on John's thread has vertical blur applied to all frames
of the output, the above code affects (blur) only the de-blended ones and MCDegrain would have the
effect of sharpening those up again [I think])



See new version, on MediaFire via Sig

EDIT:- See also 2 previous posts (exceeded D9 limit post limit).

EDIT: Below links might be useful.
"Problem Video.AVI" (link already included with ExBlend, or get from John's Thread.)
http://www.mediafire.com/?5vaci1oepo3kjb1

ClipClop Plugin.
http://forum.doom9.org/showthread.php?t=162266

Prune Plugin:
http://forum.doom9.org/showthread.php?t=162446
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 14th December 2018 at 15:40.
StainlessS is offline   Reply With Quote