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 5th April 2016, 06:06   #41  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
I've just put the first Doctor clip through the mod, and to all intents and purposes came out exactly the same as YouTube version
(taking into account that it was encoded to MP4 between re-colorings)

Code:
Import("AutomaticColorization.avs")

AviSource("Doctor.avi")
Org=Last
GrayScale
cmfullshift2
D1=ClipDelta(Last,Org,False)
D2=ClipDelta(Last,Org,True)
T=StackHorizontal(ORG ,D1)
B=StackHorizontal(Last,D2)
Return StackVertical(T,B)

# 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
}
EDIT: Anybody got any Laurel & Hardy, Buster Keaton or similar to try out ?
(they never did anything but extract a grimace out of me, but might be interesting to see some real old footage colorized).
Or maybe the guy I used to see at Saturday morning matinee, said Shazam a lot (Captain Marvel or something like that),
he was in B&W I think.

And just to clarify for John Meyer, the girls in Ice Cold In Alex and Gold Finger are two different lassies, Sylvia Syms and Shirley Eaton (JFYI).

EDIT: I'm just trying with the 2nd YouTube example (Test 1) and its coming out more pink that the original Yellow cast clip.
Was anything else done to that clip ?

EDIT: After the initial scene in photo studio (which I think looked better on YouTube) the remaining scenes all looked better with current
script (or original supplied script, not quite so yellow).
Obviously quite ancient footage, thank you
Now all we gotta do is squeeze some blue out of them there clips.
__________________
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 07:13.
StainlessS is offline   Reply With Quote
Old 5th April 2016, 07:10   #42  |  Link
MWilson
Registered User
 
Join Date: Mar 2016
Location: Arkansas
Posts: 95


The first clip put on youtube was completely inaccurate.
I've got several scripts based on this and other ideas, most are bad, but there are a few that I like.

Example:

Code:
function wcf(clip v,float weight)
{
v=v.greyscale().converttoyv12()
af=v.defreq(fy=-.29,fx=.29,sharp=0,dx=.50,dy=.50,fy2=-.88,fx2=.88,dx2=.50,dy2=.50)
av=v.defreq(fy=-29,fx=29,sharp=0,dx=50,dy=50,fy2=-88,fx2=88,dx2=50,dy2=50)
ax=v.defreq(fy2=-88,fx2=88,sharp=0,dx2=50,dy2=50,fy=-58,fx=58,dx=0,dy=50)
a=mt_makediff(merge(af,av),v).converttorgb().converttoyv12()
m1=ytouv(av,a).converttoyv12().sincresize(width(v),height(v))
y2=ytouv(m1.invert(),av).converttoyv12().sincresize(width(v),height(v))
merge(m1,y2,.35)
converttoyv12(last)
coloryuv(autowhite=true)
tweak(sat=5,maxsat=59.5,interp=20)
merge(v.invert().converttoyv12(),last.converttoyv12())
converttorgb()
sb=showblue(last).invert()
sr=showred(last).invert()
sg=showgreen(last).invert()
mergergb(sb,sr,sg)
ConvertToYV12()
sx=last.converttorgb().invert("G").converttoyv12()
sy=last.converttoyv12()
mergechroma(sy,sx,.50).converttoyv12()
merge(last,v.invert().converttoyv12()).invert("UV").swapuv()
tweak(sat=7.5,maxsat=59.5,interp=20)
mergechroma(v.converttoyv12(),last,weight)
coloryuv(autowhite=true)
return last
}

function fc(clip v)
{
v=v.converttoyv12()
merge(v.invert().wcf(1).converttoyv12().coloryuv(cont_u=-128,cont_v=-128),v.wcf(1).converttoyv12().medianblur(0,12,12))
converttoyv12()
tweak(sat=5,interp=32)
mergechroma(v,last,.333)
return last
}
Note: This is something I wrote quite a while ago. It may look alright depending on what you're going for. And yes, redundancies abound.
MWilson is offline   Reply With Quote
Old 5th April 2016, 07:41   #43  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
You really are quite a magician.

Code:
ImageSource("Harold-Lloyd.jpg",end=0)
Crop(0,0,Width/4*4,Height/4*4)
wcf(1.0)
Return ConvertToRGB32
This squeezes out quite a bit of blue, if only we could get a better compromise

Wish I could understand that DeFreq thing, I've no idea at all how to use it (ignorance is seldom bliss).

Well think its time for bed 08:40AM.
bye.

EDIT: Can I make a suggestion, when you next up a clip to YouTube, why not do a side by side demo, B&W left and mod on right
much more impressive to see the result. You might even want to replace current clips if you are able to delete already uploaded clips.
I love the "Fathers Present" scene, looks great (the current script version not youtube upload).
EDIT: Maybe they resize to some standard size which would mess up your demo, perhaps a stack four with explanation
as to why it was necessary. (I've never uploaded anything to YouTube)

EDIT: Top Youtube source for GrayScale, bottom current script recolored from GrayScale


EDIT: Removed black border

And to get David Horman a little fired up, here a couple more


and his nemesis (a herd of pinkish Daleks)



EDIT: There is a chroma shift in the Doctor frame, we need to establish some rules for cropping I think, also same for Green edges.
__________________
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; 18th September 2018 at 20:52.
StainlessS is offline   Reply With Quote
Old 5th April 2016, 09:50   #44  |  Link
MWilson
Registered User
 
Join Date: Mar 2016
Location: Arkansas
Posts: 95
https://archive.org/details/Cmfull2Test

Quick test with the mod.

As for green edges (as well as other small noise),try medianblur with a small radius.

Edit: Tested a basic merge of cmfull2 and fc.




Last edited by MWilson; 5th April 2016 at 11:11. Reason: Added Images
MWilson is offline   Reply With Quote
Old 5th April 2016, 17:11   #45  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,696
Quote:
Originally Posted by StainlessS View Post
Anybody got any Laurel & Hardy, Buster Keaton or similar to try out ? (they never did anything but extract a grimace out of me, but might be interesting to see some real old footage colorized). Or maybe the guy I used to see at Saturday morning matinee, said Shazam a lot (Captain Marvel or something like that), he was in B&W I think.
I have a huge collection of both amateur and stock movie B&W footage from 1928 onward:

John Meyer Film Transfers

I would be happy to contribute any of these to the cause, especially if we can get blue to appear (as it does in the examples in one of the links posted that goes to a site where they describe a similar process), and if we can figure out why most of the results posted so far (including my own) seem to have green at the edges and purple in the center.
johnmeyer is offline   Reply With Quote
Old 5th April 2016, 17:58   #46  |  Link
MWilson
Registered User
 
Join Date: Mar 2016
Location: Arkansas
Posts: 95
Code:
function cmfull3(clip v2)
{
    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=44,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.invert().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.invert().defreq(fy=0,fx=74,sharp=100,dx=50,dy=50,cutx=0,cuty=0)           
    b1=v.defreq(fy=0,fx=68,sharp=100,dx=50,dy=50,cutx=0,cuty=0,fx2=100,fy2=0)        ##Almost entirely trial and error
    x1=merge(r,r1)
    y1=merge(g,g1)
    z1=merge(b,b1)    
    y2=overlay(v,y1,mode="multiply")                                            # x & y default 0 ##Overlay was originally used to cover artifacts
    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)    ##Try to make a difference signal
    mergergb(x,y,z).ConvertToYV12                                                   # RGB to YV12 TV Levels
    lanczos4resize(v2.Width,v2.Height)
    ColorYUV(autowhite=true)
    tweak(sat=7.5,interp=32)
    mergechroma(v2,last,.33)
    last
    }
Some modifications.

Edit:This may be silly. But if it helps it's worth it right?



Script Used:
Code:
function cmfullx (clip v) ###Originally written for a different script a while back
{
v=v.converttoyv12()
cmfull2(v)
u=last.utoy()
v2=last.vtoy()
u4=mt_merge(u,u.invert(),v.lanczosresize(width(v)/2,height(v)/2)) ##Merge the positive and negative values according to the mask
v4=mt_merge(v2,v2.invert(),v.lanczosresize(width(v)/2,height(v)/2)) ### Was looking at U and V channels of full color images to try to "match"
ytouv(u4,v4,v)
tweak(sat=7.5)
mergechroma(v,last,.75)
return last
}
merge(cmfull3(v),cmfullx(v)) ###Quick and dirty combination
medianblur(0,3,3) ### Cleaning up small noise
Edit:Removed image.

Last edited by MWilson; 6th April 2016 at 01:33. Reason: Explanation
MWilson is offline   Reply With Quote
Old 6th April 2016, 01:15   #47  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Would be good if you can in some way reveal the secrets that you have uncovered,
Me dont know if by trial an error or some kind of physical basis,
but to have the clever guys assist there has to be some kind of direction.
Request that you in-depth add as many comments on "EVERYTHING" in current script.
Give the lads some clue as to how your magic works. I am unlikely to be of further assistance,
me just too stupid. I can clean up and stuff like that but for the big-brain guys to get involved,
then they gotta have some idea what they are doin.

Really.

EDIT: If you dont know how your stuff works, then just give as much as you know or understand it.

EDIT: Perhaps Fizick could give his take on this, would love to hear how he interpret results.
__________________
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; 6th April 2016 at 01:42.
StainlessS is offline   Reply With Quote
Old 6th April 2016, 01:54   #48  |  Link
MWilson
Registered User
 
Join Date: Mar 2016
Location: Arkansas
Posts: 95
https://en.wikipedia.org/wiki/Visible_spectrum

The idea was that light could be separated by frequency.

By the way, I would also like to hear Fizick's interpretation.

MWilson is offline   Reply With Quote
Old 6th April 2016, 02:03   #49  |  Link
pwnsweet
Registered User
 
Join Date: Nov 2008
Posts: 101
I have a short clip (1mb) (below, left) where I would like to change the color of the eyes into darker shade like the image below. Could this script be used for something like this? (ignore the contrast and brightness change).

pwnsweet is offline   Reply With Quote
Old 6th April 2016, 02:14   #50  |  Link
MWilson
Registered User
 
Join Date: Mar 2016
Location: Arkansas
Posts: 95
pwnsweet, I'm sorry, this was written trying to get semi-natural color from black and white. But FWIW, the shirt and hair color are close...
MWilson is offline   Reply With Quote
Old 6th April 2016, 02:14   #51  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
I do not imagine that the script could be used for any kind of artificial clip (Cartoon, Anime).
The idea is that it recovers original color [EDIT: hidden in the source] , Anime/Cartoon dont have any original color, is purely artificial.
__________________
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; 6th April 2016 at 02:24.
StainlessS is offline   Reply With Quote
Old 6th April 2016, 02:27   #52  |  Link
pwnsweet
Registered User
 
Join Date: Nov 2008
Posts: 101
Thanks for the responses guys. In that I'll start a new thread regarding my issue.
pwnsweet is offline   Reply With Quote
Old 6th April 2016, 04:51   #53  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,696
I take a stab at deconstructing this tomorrow. I am pretty sure that it is not reconstructing color from any latent chroma information, unlike the BBC color recovery that depended on subtle interference patterns left over from how the chroma was embedded in the TV signal.

If I wanted to create something to recover color like the BBC did for old Dr. Who episodes, I would almost certainly look to Defreq as the function to create some sort of mask.

Here is a typical image showing dot crawl:



If you desaturate this image, the dot crawl remains. The trick in restoring the color from the B&W version is to figure out the relationship between the spacing and angle of the interference pattern, and the original color. You would then need to construct a function that can color the area under the interference, while simultaneously removing that interference.

This brings me to this mystery script.

As most of you know, Defreq was designed to "sync up" to herringbone interference patterns that often happened on OTA broadcasts due adjacent channel interference as well as certain types of dot crawl (although it had other causes). Here is a typical interference pattern



You "tune" defreq by specifying the angle of the lines and the distance between the lines. You then adjust the strength of the filter and it applies the appropriate gain functions to even out the exposure. StainlessS has various functions that I used to remove noise bars from an old Kinescope, so I know he is familiar with some of the issues of a function like this.

So, at this point, it is my belief that the code in this colorization script may have started out life as something designed to retrieve color from latent dot crawl or other patterns. When those patterns are not present (as they are not in the test cases we've been trying), it is possible that it finds other patterns that it latches onto, and is then able to construct some sort of color, albeit the wrong colors some of the time.

As for how it sometimes gets the color right, I don't know, but I do know that it also gets the color wrong almost as often as it gets it right. When we think it has "colorized" the scene, what we may be experiencing is similar to an effect I have observed when making music videos, namely that most people think I have perfectly synced the music to the motion in the video. My sync efforts are pretty lame, and most of the time it is the human brain making that association, finding sync where none exists and where none was intended. In a similar way, once we see color, our brain very quickly adapts to the fact that the grass is purple instead of green, and as long as there are a few colors that are correct, we perceive the video as being somewhat correctly colored, if that isn't too tortured a way of describing it.

So, if I get time tomorrow, I'll see if I can play with some of the parameters, and also have it spit out some of the intermediate results (the masks) and see if I can make sense of it.

Too bad Didée retired because he could have figured this out in his sleep.

Last edited by johnmeyer; 6th April 2016 at 04:51. Reason: typos
johnmeyer is offline   Reply With Quote
Old 6th April 2016, 16:27   #54  |  Link
TheFluff
Excessively jovial fellow
 
Join Date: Jun 2004
Location: rude
Posts: 1,100
Quote:
Originally Posted by johnmeyer View Post
As for how it sometimes gets the color right, I don't know, but I do know that it also gets the color wrong almost as often as it gets it right.
Well, yeah, pretty much. As far as I can tell the effect is just translating luma intensity into a hue. It's slightly better than picking colors at random, but not by very much.
TheFluff is offline   Reply With Quote
Old 6th April 2016, 17:33   #55  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
There is a little bit of info on interpreting Defreq Frequency Spectrum here:- http://forum.doom9.org/showthread.ph...006#post679006

And two posts further on, Trevlac posts a link (still working) of a VirtualDub filter Frequency Analyzer.
I've had crashes in VDub current but so far none in VDubMod.
Has additional display modes to those in DeFreq. (source also available)
__________________
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 6th April 2016, 18:25   #56  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,696
I spent some time trying to figure this out. I used all the different versions of the script presented so far, and also played around with turnright() turnleft(), as suggested by the OP. Using the football clip I presented earlier, the original script seems to do the best job of creating a "pleasing" result, although still a long way from being usable for anything.

I read the original thread on Defreq that StainlessS linked to and decided that figuring out how it works is above my pay grade. I can understand the FFT stuff, and in an overall sense understand what it is doing, but I don't understand it well enough to figure out what it is doing in this "off label" (pharmaceutical reference) application.

The conclusion for me, with my restoration business, is that this is a really neat parlor trick, but since there is obviously no relationship between the grayscale representation of an image and its original color, the colors produced by this technique are going to be random. Therefore it cannot be used to create a colorized movie that anyone will want to watch.

However, despite that negative assessment, the one thing that is truly amazing is that the function manages to do a great job of making the false colors stay with each "object" as things move around on the screen. I would have expected that things might radically change color from one frame to the next. The fact that they don't is quite an accomplishment.
johnmeyer is offline   Reply With Quote
Old 6th April 2016, 18:34   #57  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,696
P.S. I mentioned using turnleft() prior to the function call. Here is the result from the original script, followed by a version that was turned 90 degrees prior to applying the function. The result at the edges is not surprising, but there are some subtle differences in the uniform colors in the center of the frame where I would have expected the colors to be identical.

Original


Turnleft


For this particular source material, putting the greenish edges at the top and bottom works really well (like that tinted plastic from the 1960s that I mentioned in an earlier post). I then tried adjusting certain hues in post, using Vegas' secondary color corrector (e.g., eliminate the referee's yellow pants). The result actually looks OK, especially when I change the purple field to green.

[edit] Here's a version that takes the turnleft() output and then applies various filters using Vegas' Secondary Color Corrector to replace a color value with a different color:



This function might actually be useful if you could have a first pass that creates some sort of table of colors that are going to be used to color objects, followed by another table where you specify the colors you actually want to use for each object in the scene. The point of this idea is to use the "tracking" (not real tracking of course) where the function consistently assigns the same color as the object moves, and use the replacement table to have the color assigned be closer to an acceptable hue.

Last edited by johnmeyer; 6th April 2016 at 18:45. Reason: Added third photo
johnmeyer is offline   Reply With Quote
Old 6th April 2016, 18:59   #58  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
MWilson, can you replace script in first post with 2nd script in post #37 (org_cm.avs),
The current 1st post has bug where I forgot the TV->full scale RGB and back to TV YUV conversions.
(would be equiv to 'studio RGB' 16->235, converted to YUV via ConvertToYV12, ie wrong).

Was later fixed and post #37 updated as noted in post #40.
__________________
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 6th April 2016, 19:15   #59  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Is this at all more pleasing john,


As MW suggested

Code:
Import("AutomaticColorization.avs")     # Mod

Imagesource("Original Football.jpg",end=0)

Crop(0,0,Width/4*4,Height/4*4)
convertToYV12.GrayScale

A=cmfullshift2
b=TurnLeft.cmfullshift2.TurnRight
Merge(A,B)
EDIT: I suspect it might be better to always ensure mod 4 on both axis prior to call.

Oops, you already did that (did not notice)

EDIT: Arh I see, it was a later edit. Anyway shows interim step before Vegas.

EDIT: Misleading images removed from earlier post.
__________________
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; 18th September 2018 at 20:55.
StainlessS is offline   Reply With Quote
Old 6th April 2016, 19:21   #60  |  Link
MWilson
Registered User
 
Join Date: Mar 2016
Location: Arkansas
Posts: 95
Quote:
but since there is obviously no relationship between the grayscale representation of an image and its original color, the colors produced by this technique are going to be random. Therefore it cannot be used to create a colorized movie that anyone will want to watch.
johnmeyer, I completely disagree. It takes some heavy use of colormill to look good, but I have plenty of encodes to back me up.
MWilson 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 19:25.


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