View Single Post
Old 5th April 2016, 01:04   #37  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Is cmfull() intended to be called on its own, or only through cmfullshift2 ?

EDIT: I've upped two frames here, intended so that we all have same test frames [EDIT: Added color frames].
http://www.mediafire.com/download/3g...zation_Test.7z

Both already border cropped and GrayScaled. RGB24 BMP.

and test script for comparison

AutomaticColorization.avs
Code:
Function cmfull2(clip v2) {    # (c) MWilson, http://forum.doom9.org/showthread.php?t=173364
    # MUST be MOD 2 Width and Height
    v2    = v2.ConvertToYV12.GrayScale
    BordW = v2.width /4*2                                                      # Must be even, Avoid using Width and Height as variables (misleading)
    BordH = v2.height/4*2
    v=v2.sincresize(256,256).addborders(BordW,BordH,BordW,BordH)    
    r =v.defreq(fy=0,fx=39,sharp=100,dx=50,dy=50,cutx=0,cuty=0)                # DeFreq YV12 and YUY2, Plane default 0 = Y 
    r1=v.defreq(fy=0,fx=47,sharp=100,dx=50,dy=50,cutx=0,cuty=0)
    g =v.defreq(fy=0,fx=59,sharp=100,dx=50,dy=50,cutx=0,cuty=0)
    g1=v.defreq(fy=0,fx=51,sharp=100,dx=50,dy=50,cutx=0,cuty=0)    
    b =v.defreq(fy=0,fx=65,sharp=100,dx=50,dy=50,cutx=0,cuty=0)           
    b1=v.defreq(fy=0,fx=59,sharp=100,dx=50,dy=50,cutx=0,cuty=0,fx2=100,fy2=0)        
    x1=merge(r,r1)
    y1=merge(g,g1)
    z1=merge(b,b1)    
    y2=overlay(v,y1,mode="multiply")                                            # x & y default 0
    z2=overlay(v,z1,mode="multiply") 
    # Went back to this, Need Expand range YUV TV -> RGB Full range, and then convert back to YV12 TV levels. 
    # (previous mod missed out TV -> full range convert)     
    C="-128"
    x=mt_makediff(v,x1,Chroma=C).converttorgb().crop(BordW,BordH,-BordW,-BordH)     # Chroma planes = -(-128) (same as Grayscale), Else Garbage
    y=mt_makediff(v,y2,Chroma=C).converttorgb().crop(BordW,BordH,-BordW,-BordH)
    z=mt_makediff(v,z2,Chroma=C).converttorgb().crop(BordW,BordH,-BordW,-BordH)    
    mergergb(x,y,z).ConvertToYV12                                                   # RGB to YV12 TV Levels
    lanczos4resize(v2.Width,v2.Height)
    ColorYUV(autowhite=true)
    mergechroma(v2,last,1.0)
    return last
}

Function cmfullshift2 (clip v) {
    # MUST be MOD 2 Width and Height
    v=v.ConvertToYV12.GrayScale
    cmfull2(v)
    u =last.utoy()
    v2=last.vtoy()
    u3=repair(v.lanczosresize(width(v)/2,height(v)/2),u)
    v3=repair(v.lanczosresize(width(v)/2,height(v)/2),v2)
    ytouv(u3,v3,v)
    tweak(sat=7.5,interp=32)
    mergechroma(v,last,0.33)
    coloryuv(autowhite=true)
    return last
}
Mod of original script, use for comparison of future changes (pretty much identical to above script)

org_cm.avs
Code:
Function cmfull(clip v2) {
    # MUST be MOD 2 Width and Height
    v2    = v2.ConvertToYV12.GrayScale
    BordW = v2.width /4*2                                                      # Must be even, Avoid using Width and Height as variables (misleading)
    BordH = v2.height/4*2
    v=v2.sincresize(256,256).addborders(BordW,BordH,BordW,BordH)    
    r =v.defreq(fy=0,fx=39,sharp=100,dx=50,dy=50,cutx=0,cuty=0)                # DeFreq YV12 and YUY2, Plane default 0 = Y 
    r1=v.defreq(fy=0,fx=47,sharp=100,dx=50,dy=50,cutx=0,cuty=0)
    g =v.defreq(fy=0,fx=59,sharp=100,dx=50,dy=50,cutx=0,cuty=0)
    g1=v.defreq(fy=0,fx=51,sharp=100,dx=50,dy=50,cutx=0,cuty=0)    
    b =v.defreq(fy=0,fx=65,sharp=100,dx=50,dy=50,cutx=0,cuty=0)           
    b1=v.defreq(fy=0,fx=59,sharp=100,dx=50,dy=50,cutx=0,cuty=0,fx2=100,fy2=0)        
    x1=merge(r,r1)
    y1=merge(g,g1)
    z1=merge(b,b1)    
    y2=overlay(v,y1,mode="multiply")                                            # x & y default 0
    z2=overlay(v,z1,mode="multiply") 
    # Went back to this, Need Expand range YUV TV -> RGB Full range, and then convert back to YV12 TV levels. 
    # (previous mod missed out TV -> full range convert)     
    C="-128"
    x=mt_makediff(v,x1,Chroma=C).converttorgb().crop(BordW,BordH,-BordW,-BordH)     # Chroma planes = -(-128) (same as Grayscale), Else Garbage
    y=mt_makediff(v,y2,Chroma=C).converttorgb().crop(BordW,BordH,-BordW,-BordH)
    z=mt_makediff(v,z2,Chroma=C).converttorgb().crop(BordW,BordH,-BordW,-BordH)    
    mergergb(x,y,z).ConvertToYV12                                                   # RGB to YV12 TV Levels
    lanczos4resize(v2.Width,v2.Height)
    ColorYUV(autowhite=true)
#    bx=mergechroma(v2,Last,1.0)                                                    # AutoWhite twice, second time does nothing
#    coloryuv(bx,autowhite=true)
    mergechroma(v2,last,1.0)
    return last
}

Function cmfullshift (clip v) {
    # MUST be MOD 2 Width and Height
    v=v.ConvertToYV12.GrayScale
    cmfull(v)
    u =last.utoy()
    v2=last.vtoy()
    u3=repair(v.lanczosresize(width(v)/2,height(v)/2),u)
    v3=repair(v.lanczosresize(width(v)/2,height(v)/2),v2)
    ytouv(u3,v3,v)
    tweak(sat=7.5,interp=32)
    mergechroma(v,last,0.33)
    coloryuv(autowhite=true)
    return last
}
AutomaticColorization_Client.avs
Code:
Import("org_cm.avs")                    # Original script (with a few small mods)
Import("AutomaticColorization.avs")     # Mod


Imagesource("DQ-Tools_Color.BMP",end=0).convertToYV12
#Imagesource("JP_Test_Color.BMP",end=0).convertToYV12
Org=Last            # Display Color

AMP=true

GrayScale
#Org=Last           # Display GrayScale

A=cmfullshift
B=cmfullshift2

D=ClipDelta(B,A,amp=AMP)
L=StackVertical(ORG,D)
R=StackVertical(A,B)
Return StackHorizontal(L,R)

# Return Clip Difference of input clips (amp==true = Amplified, show==true = show background)
Function ClipDelta(clip clip1,clip clip2,bool "amp",bool "show") {
    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
}
Delta frame shows difference between original script and supplied, if eg more red then mod is more red.

EDIT: We dont seem to be getting any blues at all. Cyan in Delta frame would indicate Lack Of Red rather than Too Much Blue.

EDIT: Added color BMP's to the 7z

Updated
__________________
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; 5th April 2016 at 05:47. Reason: update
StainlessS is offline   Reply With Quote