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. |
3rd April 2016, 23:42 | #1 | Link |
Registered User
Join Date: Mar 2016
Location: Arkansas
Posts: 95
|
Automated Colorization Script (Now ChromaJig)
Edit: Updated - See Post # 157
I've written a script that I think is pretty interesting. I should clean this up, but I'm away from my normal computer and I'm very used to using AVSPMod. Requirements are: defreq Masktools2 Code:
Function Cmx7Mod(clip c, Float "Sat",Bool "DownSz",Int "Pad") { # (c) MWilson, http://forum.doom9.org/showthread.php?t=173364 # Progressive Only : MUST be MOD 2 Width and Height, Otherwise will crop Mod 2 Sat = Default(Sat,0.33) # Default 0.33, 0.0 -> 1.0 DownSz = Default(DownSz,True) # Default true, True=Qwiker, False Precise Pad = (Default(Pad,2)+1)/2*2 # Round up next multiple of 2, Avoid green border. c = c.Crop(0,0,c.Width/2*2,c.Height/2*2).ConvertToYV12.GrayScale # Mod 2 smallc = (DownSz) ? c.sincresize((c.Width+3)/4*2,(c.Height+3)/4*2) : c # At least half size, Mod 2 Padc = (Pad>0) ? smallc.pointresize(smallc.Width+Pad*2,smallc.Height+Pad*2,-Pad,-Pad,smallc.Width+Pad*2,smallc.Height+Pad*2) : smallc r = Padc.defreq(fy=0,fx=39,sharp=100,dx=50,dy=50,cutx=0,cuty=0).Crop(Pad,Pad,-Pad,-Pad) r1 = Padc.defreq(fy=0,fx=47,sharp=100,dx=50,dy=50,cutx=0,cuty=0).Crop(Pad,Pad,-Pad,-Pad) g = Padc.defreq(fy=0,fx=37,sharp=100,dx=50,dy=50,cutx=0,cuty=0).Crop(Pad,Pad,-Pad,-Pad) g1 = Padc.defreq(fy=0,fx=85,sharp=100,dx=50,dy=50,cutx=0,cuty=0).Crop(Pad,Pad,-Pad,-Pad) b = Padc.defreq(fy=0,fx=65,sharp=100,dx=50,dy=50,cutx=0,cuty=0).Crop(Pad,Pad,-Pad,-Pad) b1 = Padc.defreq(fy=0,fx=59,sharp=100,dx=50,dy=50,cutx=0,cuty=0,fx2=100,fy2=0).Crop(Pad,Pad,-Pad,-Pad) x1 = merge(r,r1) y1 = merge(smallc.invert(),merge(g,g1)) z1 = merge(smallc.invert(),merge(b,b1)) y2 = overlay(smallc,y1,mode="multiply") z2 = overlay(smallc,z1,mode="multiply") x=mt_makediff(smallc,x1,Chroma="-128").converttorgb() # Full range RGB y=mt_makediff(smallc,y2,Chroma="-128").converttorgb() z=mt_makediff(smallc,z2,Chroma="-128").converttorgb() mergergb(x,y,z).ConvertToYV12 # RGB to YV12 TV Levels lanczos4resize(c.Width,c.Height) mergechroma(c,ColorYUV(autowhite=true)) return (Sat>0.0) ? mergechroma(c,tweak(sat=7.5,interp=32),Sat) : Last } The latest version: Code:
function fc1(clip v,float weight) {# (c) MWilson, http://forum.doom9.org/showthread.php?t=173364 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) converttorgb24() return last } function fc2(clip v) {# (c) MWilson, http://forum.doom9.org/showthread.php?t=173364 v=v.greyscale().converttoyv12() merge(v.invert().fc1(1).converttoyv12().coloryuv(cont_u=-128,cont_v=-128),v.fc1(1).converttoyv12()) converttoyv12() tweak(sat=5,interp=32) mergechroma(v,last.awarpsharp2(depth=48,chroma=4),.333) return last } function chromajig(clip y) {# (c) MWilson, http://forum.doom9.org/showthread.php?t=173364 y=y.greyscale().converttoyv12() y1=y.gaussresize(72,48) y1 fc2() #hqdn3d(0,28,0,4.5) gaussresize(width(y),height(y)) subtract(y.fc2(),last) mergeluma(y) return last } function cjbx(clip v) {# (c) MWilson, http://forum.doom9.org/showthread.php?t=173364 v=v.converttoyv12().greyscale() v1=v.spline36resize(240,240) y=v1.converttorgb() y.pointresize(8,8) invert() pointresize(16,16) chromajig() blur(1,1) invert() swapuv() #temporalsoften(10,0,20) spline36resize(width(y),height(y)) a=last y.pointresize(32,32) chromajig() blur(1,1) invert() spline36resize(width(y),height(y)) b=last y.pointresize(180,180) chromajig() blur(1,1) invert() swapuv() spline36resize(width(y),height(y)) c=last subtract(a,b) subtract(last,c) invert() spline36resize(width(y),height(y)) mergechroma(y.converttoyv12().greyscale(),last,.75) coloryuv(autowhite=true) spline36resize(width(v),height(v)) blur(1,1) mergechroma(v,last) return last } function colorfox(clip y) {# (c) MWilson, http://forum.doom9.org/showthread.php?t=173364 y=y.greyscale().converttoyv12() y.cjbx() a=last c1=a.converttorgb() r=showred(c1) g=showgreen(c1) b=showblue(c1) c=merge(r,merge(g,b).invert()) m=merge(g,merge(r,b).invert()) ye=merge(b,merge(r,g).invert()) mergergb(ye,m,c) subtract(last,c1) converttoyv12() invert("UV") subtract(a,last) swapuv() } function colorjig(clip v, float "Weight") {# (c) MWilson, http://forum.doom9.org/showthread.php?t=173364 Weight= Default(Weight,1) v=v.greyscale().converttoyv12() b=v.greyscale().colorfox().tweak(hue=90).invert("UV").coloryuv(autowhite=true).invert("V").converttoyv12() merge(b,b.chromajig()) coloryuv(autowhite=true) mergechroma(v,last,Weight) } function cfcf2(clip y) { y=y.greyscale().converttoyv12().invert().turnleft() a=y.cjbx().utoy() b=y.invert().TurnLeft().cjbx().TurnRight().invert().utoy() ytouv(a,b,y) mergechroma(y,last,.45) converttoyv12() c=last subtract(c,y.cjbx()) invert("UV") medianblur(0,10,10) mergechroma(c,last,.33) turnright() invert("Y") return last } Using the latest script, will update this post later. Edit: Updated to the latest version. A note: this is for colorization, don't expect miracles! Sorry if I was misleading in the beginning of this thread, it wasn't on purpose. I was confused as well! Edit: Sorry folks, as davidhorman pointed out this needs to have a call to greyscale! Code updated. Edit: Code Updated - See Posts #34 & #35 Edit: Updated - See Post #37 Edit: Updated - See Posts #66 & #69 Edit: Updated 4/18/16 Edit: Minor Changes Last edited by MWilson; 1st November 2017 at 15:01. Reason: Update |
4th April 2016, 00:32 | #2 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
I'm not gonna pretend that I know how it does it, but it is rather intriguing.
I provided it with a grayscale StarWars (not necessary as it GrayScales it anyway), and I got out a golden C-3PO. Just like magic EDIT: This is quite amazing, I tried with Jurassic Park and did a StackVertical of original and result, and the colors and color patterns on peoples shirts etc were 'sort of' the same, green trees etc. I say again, "Just like Magic". Would you care to elaborate upon how it does this (some kind of residual color stored in luma ?).
__________________
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 01:11. |
4th April 2016, 01:22 | #3 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
EDIT: The first two examples are misleading, I did not GrayScale beforehand and bug in script merged with original colored version.
The 3rd example was already Gray and so does not suffer from this problem. Here we go, get a load of this (original on top, recolored GrayScale on bottom) Not entirely successfull but "Worth waiting for". (from VCD B&W movie) EDIT: Misleading images removed.
__________________
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:20. |
4th April 2016, 03:11 | #5 | Link |
Registered User
Join Date: Mar 2016
Location: Arkansas
Posts: 95
|
Sure! It's all dependent on the greyscale. The photographs are records of light. The light contains all the information for color, but splitting it into chunks is/was mainly trial and error. My HDD can attest to that!
Edit: johnmeyer, I wish.... Last edited by MWilson; 4th April 2016 at 03:12. Reason: New post above |
4th April 2016, 03:12 | #6 | Link |
47.952fps@71.928Hz
Join Date: Mar 2011
Posts: 940
|
Interesting indeed!
linked images: Original (1080p bluray) cmfull cmfullshift Greyscale().cmfullshift spline36resize(854,480).cmfullshift for the good ol' SD look. There were some other TV-appearance functions I played with before... combining them all, I could make a nostalgic conversion. Make it look like a sdtv rip or something. Just need to make up a logo. EDIT: I used RGtools instead of RemoveGrain v1.0b.
__________________
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!)
|
4th April 2016, 03:19 | #7 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
How on earth does the script know that the beer crate in back RHS of first image is blue ?
(pretty much everything on the main table is very near original color). Searching Google on Automatic Colorization bring up quite a bit on using Neural Networks and teaching software what color something 'could be', but this is entirely different. A very big welcome to the forum MWilson, England Expects great things of you
__________________
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 ??? |
4th April 2016, 04:02 | #9 | Link | |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Are you 'Doc W Mastering' ?
From YouTube: "Doctor Who Automatically Colorized Using Avisynth" Quote:
I am not able to view above, just keep getting errors from YouTube (not just for this clip). Google search which discovered above:- https://www.google.co.uk/?gfe_rd=cr&...ization+dr+who EDIT: I thought I remembered something about recovering color from B&W Dr Who, some time ago. (think mentioned in a thread somewhere) EDIT: Another one here:- https://www.youtube.com/watch?v=qvx69sJInP8
__________________
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 04:32. |
|
4th April 2016, 04:29 | #11 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Yep, saw the comment, also managed to Download the clip even if I cant view on-line.
Wondering if bbc has managed to recover that one. Great job, well done.
__________________
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 ??? |
4th April 2016, 04:59 | #12 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
It seems to favour Gold, (although the Daleks come out a little bit pinkish).
Even catches the gold rim on top of the Carlsberg glass in B&W movie clip. I'm wondering how Shirley Eaton would turn out if turned to B&W (her big scene). Could not resist, here she is EDIT: I can see the BBC taking this up. EDIT: Actually I dont think there is an identical color version of that frame, looks to have been done several times where a little bit different setting.
__________________
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:22. |
4th April 2016, 05:47 | #14 | Link |
Registered User
Join Date: Feb 2002
Location: California
Posts: 2,695
|
StainlessS,
I won't be able to get to my editing computer until tomorrow. When you tested this code, were the colors in the resulting video fairly stable from frame-to-frame, or did they pulse, flicker, or change as the video played? [edit] Never mind. I forgot to look at his Dr. Who video. That answers my question. Last edited by johnmeyer; 4th April 2016 at 05:49. Reason: added a "never mind" at the end |
4th April 2016, 06:44 | #15 | Link |
I'm Siri
Join Date: Oct 2012
Location: void
Posts: 2,633
|
I'm just curious how this thing works,
Say Luma=c1*R+c2*G+c3*B while Luma, c1, c2 and c3 are constants, and R, G, B are the unknowns You simply cannot get a constant solution of RGB from the indeterminate equation above.. |
4th April 2016, 07:18 | #16 | Link |
Registered User
Join Date: Mar 2016
Location: Arkansas
Posts: 95
|
It's not perfect, but as far as completely automated colorization, I think it works well.
Here's a quick test: Code:
c=Blankclip().converttorgb().invert()## Quick white.... r=c.rgbadjust(b=0,g=0) g=c.rgbadjust(r=0,b=0) b=c.rgbadjust(g=0,r=0) original=stackhorizontal(r,g,b).sincresize(256,256) filter=original.greyscale().cmfullshift() stackvertical(original.converttoyv12(),filter) |
4th April 2016, 11:44 | #17 | Link | |
Formerly davidh*****
Join Date: Jan 2004
Posts: 2,496
|
Quote:
StainlessS, did you pass the full colour version to cmfullshift? Code:
function cmfullshift (clip v) { v=v.converttoyv12() # input clip - full colour? 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) # 2/3 of original chroma is restored coloryuv(autowhite=true) return last } |
|
4th April 2016, 12:41 | #20 | Link |
Registered User
Join Date: Mar 2016
Location: Arkansas
Posts: 95
|
Example: Left is untouched, Middle is cmfullshift with a greyscale call first, Right is without the greyscale call.
https://drive.google.com/open?id=0B7...VN1OFpURHhJOU0 https://drive.google.com/file/d/0B72PmD8lKDzSOXRXOG1PaTYtOUE/view?usp=sharing |
Tags |
automated, color, colorization |
Thread Tools | Search this Thread |
Display Modes | |
|
|