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 4th April 2016, 12:48   #21  |  Link
MWilson
Registered User
 
Join Date: Mar 2016
Location: Arkansas
Posts: 95
Quote:
This would've made an awesome April Fool, though.
The Doctor Who video should give a better idea of how this works.
Because it does work , albeit not as well as I was hoping. It wasn't a joke.

Last edited by MWilson; 4th April 2016 at 12:56.
MWilson is offline   Reply With Quote
Old 4th April 2016, 12:50   #22  |  Link
Sparktank
47.952fps@71.928Hz
 
Sparktank's Avatar
 
Join Date: Mar 2011
Posts: 940
This is what the JP clip would look like greyscaled().

Code:
ImageSource("D:\Downloads\JP0_zpstys30smw(1).PNG")
Crop(0, 0, -0, -552) # crop out the previous result
Greyscale()
cmfullshift
__________________
Win10 (x64) build 19041
NVIDIA GeForce GTX 1060 3GB (GP106) 3071MB/GDDR5 | (r435_95-4)
NTSC | DVD: R1 | BD: A
AMD Ryzen 5 2600 @3.4GHz (6c/12th, I'm on AVX2 now!)
Sparktank is offline   Reply With Quote
Old 4th April 2016, 13:04   #23  |  Link
wonkey_monkey
Formerly davidh*****
 
wonkey_monkey's Avatar
 
Join Date: Jan 2004
Posts: 2,493
Quote:
Originally Posted by MWilson View Post
The Doctor Who video should give a better idea of how this works.
Because it does work , albeit not as well as I was hoping. It wasn't a joke.
Oh, no, I didn't mean to suggest it was - only that a deliberately obfuscated function similar to that could've fooled some people.

It is pretty amazing how well it manages to separate objects with such a seemingly simple script.
__________________
My AviSynth filters / I'm the Doctor
wonkey_monkey is offline   Reply With Quote
Old 4th April 2016, 13:35   #24  |  Link
MWilson
Registered User
 
Join Date: Mar 2016
Location: Arkansas
Posts: 95
Here's an example from a greyscale input ran through cmfullshift and given a minute in colormill.


And raw output from an old Sherlock Holmes episode.



Last edited by MWilson; 4th April 2016 at 14:11. Reason: Added photos
MWilson is offline   Reply With Quote
Old 4th April 2016, 18:42   #25  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,691
This technology sure is intriguing. While every tool has limitations, and that is surely the case here, I nonetheless think this could work even better if I could better understand a little about how it works. In particular, if I could both tune the script parameters AND also modify my B&W source prior to modifying it with this script so that it would be more acceptable to the script, I think I could get better results.

For instance ...

Here is a before/after snap of some B&W football film I happened to have lying around from some work I did for a major sports film collector:

Before Colorization


After Colorization


And here is a short video clip of the colorized version:

Colorized B&W Football Film

As you can see, the script does a pretty good job on the grass on the edge of the frame, and a credible job on the jerseys, but screws up on the grass in the middle of the frame. In looking at the original B&W (above), whatever exposure variation is causing this change in behavior is not obvious to me, but I have to think that if I could understand a little of the theory of operation, I could tune the script or prep the source to get the script to produce green across the entire width of the frame.
johnmeyer is offline   Reply With Quote
Old 4th April 2016, 20:39   #26  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
I would think that 8 bit Avisynth limitation would not help matters, wonder what a Vapoursynth mod would produce. (I can hear some scurrying around right now).

Quote:
StainlessS, did you pass the full colour version to cmfullshift?
Mea Culpa, after the first test I did not bother with initial GreyScale.

The Shirley Eaton Golden Girl frame was already B&W, source here (about 2048x1nnn):- https://www.google.co.uk/search?q=sh...ZYPqx62E4dM%3A

The movie though was in color.

Shirley refused to be re-painted for the intro and exit credits, so is a different girl.

The script also needs amending for the resizing (width/2 --->>> width/4*2) or similar.
Might also check suitable size before conversion to YV12, eg Crop(0,0,Width/4*2,Height/4/*2).ConvertToYV12.GrayScale

EDIT: There is at least one frame in given link of the color version of B&W Golden Girl image.
EDIT: Actually dont think there is a color version of exact same golden girl frame, looks like they made the most
of that paint job, and took a number of shots in slightly different locations.
__________________
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; 4th April 2016 at 22:17. Reason: Mia to Mea
StainlessS is offline   Reply With Quote
Old 4th April 2016, 21:24   #27  |  Link
Wilbert
Moderator
 
Join Date: Nov 2001
Location: Netherlands
Posts: 6,364
Quote:
The idea is that greyscale is actually not luma sans any color, but luma and chroma together unfiltered.
Please expand, what exactly do you mean by this?
Wilbert is offline   Reply With Quote
Old 4th April 2016, 21:39   #28  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
MW, I assume this is an error (I'm trying to mod your script a little just to make it clearer [for me] what its doing)

Code:
    z1=merge(b,b1)                                          # !!! CHANGED b1 to b !!! was z1=merge(b1,b1) which dont really make sense
__________________
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 ???
StainlessS is offline   Reply With Quote
Old 4th April 2016, 21:42   #29  |  Link
MWilson
Registered User
 
Join Date: Mar 2016
Location: Arkansas
Posts: 95
The idea is that we are viewing a record of the light captured at the time. Technicolor used prisms as well as color filters to separate the light into base components of color inside of the camera. My idea was that if this was possible, it might be possible to make a sort of "inverse" process from the recorded light in the greyscale.

Edit: StainlessS, I saw that just a minute ago. Yeah, it was a brain fart :P

Last edited by MWilson; 4th April 2016 at 21:45. Reason: Post Above
MWilson is offline   Reply With Quote
Old 4th April 2016, 21:46   #30  |  Link
Groucho2004
 
Join Date: Mar 2006
Location: Barcelona
Posts: 5,034
Quote:
Originally Posted by StainlessS View Post
Mia Culpa
Is that your girlfriend?

Sorry, couldn't resist.
Groucho2004 is offline   Reply With Quote
Old 4th April 2016, 21:48   #31  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Nah, I like my girls good, ol' fashioned, and silver.

EDIT: This aint me, he's a cheap fake. https://www.google.co.uk/search?q=ti...TTehiqTlv_M%3A

And oops, should be Mea Culpa (I know a girl named Mia [and yes, she is silver, we would make beautiful little tin cans]).
__________________
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; 4th April 2016 at 22:20.
StainlessS is offline   Reply With Quote
Old 4th April 2016, 22:33   #32  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,691
Not that it is relevant to this discussion, but since StainlessS seems obsessed with Shirley Eaton and his old girlfriend Mia Culpa (not to be confused with her mother, Mamma Mia), I thought he would appreciate this link to the scene I still remember when I saw this film, first run, in a theater back in 1964:

"Jill Masterson" painted gold

As for this "color from nothing" script, it reminds me of something else I saw a few times, at about the same time as I saw that film (i.e., very early 1960s). It was a device to turn your B&W TV into a color television. It was a large piece of clear plastic, tinted blue at the top, green at the bottom, and flesh colored in the middle. It was intended to "colorize" outdoor scenes.

Instant Color TV

This script obviously does a lot better job, and may actually be useful for certain situations, but only if we can collectively figure out how to tweak it. I think intelligent tweaking is the key for moving forward: how do we put controls or "dials" on the front end so we can tune it?

Finally, just to provide that last bit of my knowledge about strange ways to get color from B&W, there is the Fechner effect where rapidly flashing B&W images can cause your brain to perceive color. There were even a few commercials that attempted to exploit this ("our product is so great that you may be seeing color right now on your black and white TV!").
johnmeyer is offline   Reply With Quote
Old 4th April 2016, 22:54   #33  |  Link
MWilson
Registered User
 
Join Date: Mar 2016
Location: Arkansas
Posts: 95
johnmeyer, I can't say I appreciate the likening

But, what you said about people getting together and finding an intelligent solution is exactly the kind of thing I was hoping for.
MWilson is offline   Reply With Quote
Old 4th April 2016, 23:34   #34  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
This is what I've got so far (can you check it over).
Also, need some kind of direction on how to treat crop/resize/colorspace, there have to be some rules.

Code:
Function cmfull2(clip v2) {    # (c) MWilson, http://forum.doom9.org/showthread.php?t=173364
    v2    = v2.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)                                                              # !!! CHANGED b1 to b !!! was z1=merge(b1,b1)
    
    z2=overlay(v,z1,mode="multiply")                                            # x & y default 0
    y2=overlay(v,y1,mode="multiply")
    
#    x=mt_makediff(v,x1,Chroma="128").converttorgb().crop(BordW,BordH,-BordW,-BordH)     # Chroma planes = 128 (same as Grayscale), Else Garbage
#    y=mt_makediff(v,y2,Chroma="128").converttorgb().crop(BordW,BordH,-BordW,-BordH)
#    z=mt_makediff(v,z2,Chroma="128").converttorgb().crop(BordW,BordH,-BordW,-BordH)    
#    mergergb(x,y,z)
    
    x=mt_makediff(v,x1)                                                         # Garbage in U and V
    y=mt_makediff(v,y2)
    z=mt_makediff(v,z2)    
    mergergb(x,y,z)                                                             # Merge Luma planes to RGB
    crop(BordW,BordH,-BordW,-BordH)                                             # Remove borders
    
    lanczos4resize(v2.Width,v2.Height)
    converttoyv12()
    ColorYUV(autowhite=true)
#    tweak(sat=1.0)                                                             # What is this doing ?, Sat defaults 1.0, only affect Coring=True.
#    ax=last.sincresize(v2.Width,v2.Height)                                     # I think this may have NO EFFECT other than ax=Last (ie is already v2.width,v2.height)
    ax=Last
    bx=mergechroma(v2,ax,1.0)
    coloryuv(bx,autowhite=true)
    #Blank = merge(last,last.invert("YUV"))                                     # YUV=$808080
    #Blank = last.BlankClip(Pixel_type="YV12",Color_YUV=$808080)                # Does nothing
    #mergechroma(Blank,last,1.0)                                                # Does nothing (result chroma is from last, below luma discarded)                                                
    mergechroma(v2,last,1.0)
    return last
}
EDIT: We seem to be missing BLUE.

EDIT: "Jill Masterson Painted Gold", This Video Is Not Available, Sorry about that.
__________________
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; 4th April 2016 at 23:48.
StainlessS is offline   Reply With Quote
Old 4th April 2016, 23:40   #35  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,431
Thanks, MWilson.
I've been trying this out on some old B&W family photos and the results, though clearly not perfect, are quite amazing.

I've no idea how the method works, but there seems to be something wrong in the script:
Quote:
Originally Posted by MWilson View Post
Code:
function cmfullshift (clip v)
{
v=v.greyscale().converttoyv12()
cmfull(v)
u=last.utoy()
v2=last.vtoy()
ytouv(u,v2,v)
tweak(sat=3.5,interp=32)
coloryuv(autowhite=true)
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,.33)
coloryuv(autowhite=true)
return last
}
The lines in red have no effect, since their result is left in 'last', which is not used before being overwritten at the subsequent ytouv(u3,v3,v).
Perhaps it doesn't matter and these lines aren't really needed anyway, or is there something missing?
__________________
GScript and GRunT - complex Avisynth scripting made easier
Gavino is offline   Reply With Quote
Old 5th April 2016, 00:02   #36  |  Link
MWilson
Registered User
 
Join Date: Mar 2016
Location: Arkansas
Posts: 95
StainlessS: Thanks, that's amazing detective work. I ran a greyscaled clip through, it's amazing what you can find with a second pair of eyes!

Gavino: Thank you, and yes those lines do absolutely nothing. Sorry for any confusion. Mine is enough to go around
MWilson is offline   Reply With Quote
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
Old 5th April 2016, 02:18   #38  |  Link
SSH4
Registered User
 
Join Date: Nov 2006
Posts: 90
https://richzhang.github.io/colorization/
SSH4 is offline   Reply With Quote
Old 5th April 2016, 02:39   #39  |  Link
MWilson
Registered User
 
Join Date: Mar 2016
Location: Arkansas
Posts: 95
SSH4: That paper honestly freaked me out. But from what I could tell it used neural networks, which are way above my head.
MWilson is offline   Reply With Quote
Old 5th April 2016, 04:14   #40  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Post #37 updated and new Original script added (Identical to current, can then compare any changes with present state).

Had a few hiccoughs, but hopefully back with the program.
__________________
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:20.
StainlessS is offline   Reply With Quote
Reply

Tags
automated, color, colorization

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 11:59.


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