View Full Version : Automated Colorization Script (Now ChromaJig)
MWilson
3rd April 2016, 23:42
Edit: Updated - See Post # 157 (http://forum.doom9.org/showthread.php?p=1775733#post1775733)
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
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
}
Thanks to StainlessS for the mod :)
The latest version:
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
}
:thanks:
Using the latest script, will update this post later.
http://i64.tinypic.com/8xlmvr.jpg
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
StainlessS
4th April 2016, 00:32
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 ?).
StainlessS
4th April 2016, 01:22
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)
https://s20.postimg.cc/enzxknvct/Worth_Waiting_For_zpscvdf3qbs.png (https://postimg.cc/image/enzxknvcp/)
EDIT: Misleading images removed.
johnmeyer
4th April 2016, 03:05
Trying to understand this script reminds me of reading through some of Didée's genius code: I know it works, but I'll be darned if I can figure out how.
This one is beyond my pay grade.
MWilson
4th April 2016, 03:11
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....
Sparktank
4th April 2016, 03:12
Interesting indeed!
linked images:
Original (1080p bluray)
https://i.imgur.com/WuLA3eol.png (https://imgur.com/WuLA3eo)
cmfull
https://i.imgur.com/CSnQVe8l.png (https://imgur.com/CSnQVe8)
cmfullshift
https://i.imgur.com/DPun8Wel.png (https://imgur.com/DPun8We)
Greyscale().cmfullshift
https://i.imgur.com/kWU5Dtql.png (https://imgur.com/kWU5Dtq)
spline36resize(854,480).cmfullshift
for the good ol' SD look.
https://i.imgur.com/uDQgdXBl.png (https://imgur.com/uDQgdXB)
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. :D:devil:
EDIT: I used RGtools instead of RemoveGrain v1.0b.
StainlessS
4th April 2016, 03:19
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 :)
MWilson
4th April 2016, 03:34
Thanks StainlessS!:eek: I'll try not to let England down!:D
StainlessS
4th April 2016, 04:02
Are you 'Doc W Mastering' ?
From YouTube: "Doctor Who Automatically Colorized Using Avisynth"
I hope you enjoy the video! No audio, as you can tell. I've been working on this for four years, and what you are seeing is the raw untouched output from the original greyscale video. Feedback is not only welcome but encouraged!
P.S. I am not affiliat
Here:- https://www.youtube.com/watch?v=idpNPicSzxU
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&ei=KRd1VKG6N5HCVND3gGA&gws_rd=ssl#q=automatic+colorization+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
MWilson
4th April 2016, 04:07
Yep. I also tweet as analogmoe.
Edit: Check the comments on the first link...
StainlessS
4th April 2016, 04:29
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.
StainlessS
4th April 2016, 04:59
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 :)
https://s20.postimg.cc/nx23us48t/Shirley0_zpshcip3byy.png (https://postimg.cc/image/8bksatsah/)
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.
johnmeyer
4th April 2016, 05:33
Wow, I just saw that movie on BBC America. How the heck can it know that her skin is gold and not flesh-colored??
This is FM (the M stands for magic; you can insert your own word for the F).
johnmeyer
4th April 2016, 05:47
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.
feisty2
4th April 2016, 06:44
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..
MWilson
4th April 2016, 07:18
It's not perfect, but as far as completely automated colorization, I think it works well.
Here's a quick test:
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)
Bring the saturation up. Red and Blue look fairly close, green will show up orange-yellow.
wonkey_monkey
4th April 2016, 11:44
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).
Hang on a minute...
StainlessS, did you pass the full colour version to cmfullshift?
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
}
v (the input clip) never gets reassigned, so that last bolded line is just putting back 2/3 of the original chroma.
MWilson
4th April 2016, 12:20
^^^^^^^^
He's right :(
wonkey_monkey
4th April 2016, 12:38
^^^^^^^^
He's right :(
This would've made an awesome April Fool, though.
MWilson
4th April 2016, 12:41
Example: Left is untouched, Middle is cmfullshift with a greyscale call first, Right is without the greyscale call.
https://drive.google.com/open?id=0B72PmD8lKDzScVN1OFpURHhJOU0
https://drive.google.com/file/d/0B72PmD8lKDzSOXRXOG1PaTYtOUE/view?usp=sharing (https://drive.google.com/file/d/0B72PmD8lKDzSOXRXOG1PaTYtOUE/view?usp=sharing)
MWilson
4th April 2016, 12:48
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.
Sparktank
4th April 2016, 12:50
This is what the JP clip would look like greyscaled().
ImageSource("D:\Downloads\JP0_zpstys30smw(1).PNG")
Crop(0, 0, -0, -552) # crop out the previous result
Greyscale()
cmfullshift
https://i.imgur.com/ZHYT13j.png (https://imgur.com/ZHYT13j)
wonkey_monkey
4th April 2016, 13:04
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.
MWilson
4th April 2016, 13:35
Here's an example from a greyscale input ran through cmfullshift and given a minute in colormill.
http://i1053.photobucket.com/albums/s461/Morgan_Dale_Wilson/dead%20alive%20recolor%20-%20colormill_zpsb2gckjqb.png (http://s1053.photobucket.com/user/Morgan_Dale_Wilson/media/dead%20alive%20recolor%20-%20colormill_zpsb2gckjqb.png.html)
And raw output from an old Sherlock Holmes episode.
http://i1053.photobucket.com/albums/s461/Morgan_Dale_Wilson/New%20File%209004326_zpsvczazmlq.png (http://s1053.photobucket.com/user/Morgan_Dale_Wilson/media/New%20File%209004326_zpsvczazmlq.png.html)
http://i1053.photobucket.com/albums/s461/Morgan_Dale_Wilson/New%20File%209011292_zpsdpole7my.png (http://s1053.photobucket.com/user/Morgan_Dale_Wilson/media/New%20File%209011292_zpsdpole7my.png.html)
http://i1053.photobucket.com/albums/s461/Morgan_Dale_Wilson/New%20File%209030429_zpsr7uhwauj.png (http://s1053.photobucket.com/user/Morgan_Dale_Wilson/media/New%20File%209030429_zpsr7uhwauj.png.html)
johnmeyer
4th April 2016, 18:42
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
http://i177.photobucket.com/albums/w208/johnmeyer/Test%20Original%20BampW_zpsjes3qrqh.jpg
After Colorization
http://i177.photobucket.com/albums/w208/johnmeyer/test%20Uncorrected%20Colorized_zpssnfhgbv7.jpg
And here is a short video clip of the colorized version:
Colorized B&W Football Film (https://youtu.be/l-6RWz8ZKpQ)
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.
StainlessS
4th April 2016, 20:39
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).
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=shirley+eaton&biw=1280&bih=839&tbm=isch&imgil=8cXZYPqx62E4dM%253A%253B2LFWJRk_HmaIzM%253Bhttp%25253A%25252F%25252Fwww.topbondgirls.com%25252Fjill-masterson-shirley-eaton%25252F&source=iu&pf=m&fir=8cXZYPqx62E4dM%253A%252C2LFWJRk_HmaIzM%252C_&usg=__rxd6C8lu_EVwpk5s-8oevL44atc%3D&dpr=1&ved=0ahUKEwi4ifOz3PXLAhVD0hoKHWWfC7wQyjcIggE&ei=EcECV_i8HMOka-W-ruAL#imgrc=8cXZYPqx62E4dM%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.
Wilbert
4th April 2016, 21:24
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?
StainlessS
4th April 2016, 21:39
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)
z1=merge(b,b1) # !!! CHANGED b1 to b !!! was z1=merge(b1,b1) which dont really make sense
MWilson
4th April 2016, 21:42
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
Groucho2004
4th April 2016, 21:46
Mia Culpa
Is that your girlfriend? :D
Sorry, couldn't resist.
StainlessS
4th April 2016, 21:48
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=tin+man&biw=1280&bih=839&tbm=isch&imgil=POoTTehiqTlv_M%253A%253BD8RUg_IOnXU1PM%253Bhttp%25253A%25252F%25252Fhardcoversandheroines.com%25252F2014%25252F08%25252F25%25252Fmarry-date-or-dump-the-scarecrow-the-tin-man-the-lion%25252F&source=iu&pf=m&fir=POoTTehiqTlv_M%253A%252CD8RUg_IOnXU1PM%252C_&usg=__23CKP07jxidLzoT_hCyiHKnITfk%3D&ved=0ahUKEwixgObk7fXLAhXInBoKHUQIANIQyjcIKQ&ei=S9MCV_GuGci5asSQgJAN#imgrc=POoTTehiqTlv_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]).
johnmeyer
4th April 2016, 22:33
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 (https://www.youtube.com/watch?v=USD2Y7wRNgk)
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 (https://trulyskrumptious.wordpress.com/2012/11/29/instant-color-tv-screen/)
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!").
MWilson
4th April 2016, 22:54
johnmeyer, I can't say I appreciate the likening:devil:
But, what you said about people getting together and finding an intelligent solution is exactly the kind of thing I was hoping for.:)
StainlessS
4th April 2016, 23:34
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.
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.
Gavino
4th April 2016, 23:40
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:
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?
MWilson
5th April 2016, 00:02
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!:p
Gavino: Thank you, and yes those lines do absolutely nothing. Sorry for any confusion. Mine is enough to go around:p
StainlessS
5th April 2016, 01:04
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/3gprxpkzmom1bqj/AutomaticColorization_Test.7z
Both already border cropped and GrayScaled. RGB24 BMP.
and test script for comparison
AutomaticColorization.avs
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
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
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
SSH4
5th April 2016, 02:18
https://richzhang.github.io/colorization/
MWilson
5th April 2016, 02:39
SSH4: That paper honestly freaked me out. But from what I could tell it used neural networks, which are way above my head.
StainlessS
5th April 2016, 04:14
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.
StainlessS
5th April 2016, 06:06
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)
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.
MWilson
5th April 2016, 07:10
https://jordibatllecaminal.files.wordpress.com/2014/12/harold-lloyd.jpg
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:
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.
StainlessS
5th April 2016, 07:41
You really are quite a magician.
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
https://s20.postimg.org/6xt5fit19/Fathers_Present_2_zpsznpvsbgm.png (https://postimg.org/image/clzg6exdl/)
EDIT: Removed black border
And to get David Horman a little fired up, here a couple more
https://s20.postimg.cc/8qw23ue7x/Doctor_zpsrvligw9k.png (https://postimg.cc/image/x7e7ybeyh/)
and his nemesis (a herd of pinkish Daleks)
https://s20.postimg.cc/uel0eaem5/Daleks_zpsnzw7elpb.png (https://postimg.cc/image/urcekgwvt/)
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.
MWilson
5th April 2016, 09:50
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.
http://i1053.photobucket.com/albums/s461/Morgan_Dale_Wilson/BK%2022000027_zpsbjuqg9lb.png (http://s1053.photobucket.com/user/Morgan_Dale_Wilson/media/BK%2022000027_zpsbjuqg9lb.png.html)
http://i1053.photobucket.com/albums/s461/Morgan_Dale_Wilson/BK%2022001940_zpsrndjnfnk.png (http://s1053.photobucket.com/user/Morgan_Dale_Wilson/media/BK%2022001940_zpsrndjnfnk.png.html)
johnmeyer
5th April 2016, 17:11
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 (https://www.youtube.com/playlist?list=PL230DED9513ECA2CB)
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.
MWilson
5th April 2016, 17:58
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?
http://i1053.photobucket.com/albums/s461/Morgan_Dale_Wilson/New%20File%205004600_zpsdhdicl9z.png (http://s1053.photobucket.com/user/Morgan_Dale_Wilson/media/New%20File%205004600_zpsdhdicl9z.png.html)
Script Used:
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.
StainlessS
6th April 2016, 01:15
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.
MWilson
6th April 2016, 01:54
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.
:thanks:
pwnsweet
6th April 2016, 02:03
I have a short clip (1mb) (https://mega.nz/#!ZZ5HCQYZ!vQZE31rhcPIfgEEaUDMp6sE68DE3pMgJEpQXM282x5k) (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).
http://i68.tinypic.com/2yzms8y.jpghttp://i64.tinypic.com/2h2fjgo.png
MWilson
6th April 2016, 02:14
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... :o
StainlessS
6th April 2016, 02:14
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.
pwnsweet
6th April 2016, 02:27
Thanks for the responses guys. In that I'll start a new thread regarding my issue.
johnmeyer
6th April 2016, 04:51
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:
https://upload.wikimedia.org/wikipedia/commons/thumb/c/c4/Crawl.jpg/300px-Crawl.jpg
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
https://i.ytimg.com/vi/DmwFda51SqA/hqdefault.jpg
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.
TheFluff
6th April 2016, 16:27
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.
StainlessS
6th April 2016, 17:33
There is a little bit of info on interpreting Defreq Frequency Spectrum here:- http://forum.doom9.org/showthread.php?p=679006#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)
johnmeyer
6th April 2016, 18:25
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
6th April 2016, 18:34
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
http://i177.photobucket.com/albums/w208/johnmeyer/Original%20Football_zpsiznluamr.jpg
Turnleft
http://i177.photobucket.com/albums/w208/johnmeyer/Turnleft_zps0ncrkwmg.jpg
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:
http://i177.photobucket.com/albums/w208/johnmeyer/Post%20Production%20Version_zpsoy1t8hsm.jpg
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.
StainlessS
6th April 2016, 18:59
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.
StainlessS
6th April 2016, 19:15
Is this at all more pleasing john,
https://s20.postimg.cc/cd1vghkl9/Football_zpsnfcbqqdl.png (https://postimg.cc/image/ph7ft6cmx/)
As MW suggested
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.
MWilson
6th April 2016, 19:21
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.
johnmeyer
6th April 2016, 19:25
I did actually try a merge of the turned and un-turned versions, but didn't care for what I got in the center of the screen.
All of these attempts (by all of us) are interesting, but without understanding how the script makes its color assignments, we're just throwing random numbers at the problem: some script variations make the result in a particular scene look better; some make it look worse.
BTW, there were several posts a few days ago about the lack of blue, but when I look at the individual RGB channels, color actually looks pretty evenly distributed between each channel. Put another way, blue is not absent.
StainlessS
6th April 2016, 19:42
I dont think looking at RGB helps at all, the mod is to UV, viewing RGB you are looking at plenty of blue from Y,
having said that, there also seems plenty of U+V above and below 128.
EDIT: UV merged with original luma.
EDIT: Histogram(Mode="Levels") # view YUV
johnmeyer
6th April 2016, 19:46
johnmeyer, I completely disagree. It takes some heavy use of colormill to look good, but I have plenty of encodes to back me up.I certainly don't want to start an argument, especially since what you've done is so amazing. However, the one article you linked to provided absolutely no support for the notion that color clues are buried in a grayscale representation of a color image.
From everything I know (which is more than a little, but less than a lot), there is no way it can be.
Here is an image I just created using pure blue for one line, then pure green, and pure red. I then desaturated the result. There is no way anyone can know which line was originally which color because the grayscale representation of each color is now identical. Nothing is latent or buried to allow recovery of the original colors.
http://i177.photobucket.com/albums/w208/johnmeyer/test_zpszow0e1ba.jpg
Now it is quite clear that the script does assign colors based on some change in luma (that's what defreq does), and it does it in a very consistent basis. It is possible that it might be able sense something that happens when, as an example, red is adjacent to blue, and a few pixels at the boundary overlap (although I just tried this with some test clips, and it failed). However, until or unless someone can reverse engineer the script, or until you can provide a little more help in understanding the theory of operation, it will be impossible to make it work better.
MWilson
6th April 2016, 20:36
function cf(clip v)
{
v=v.greyscale().converttoyv12()
v2=v.sincresize(256,256)
g=v2.defreq(fy=0,fx=59,sharp=100,dx=50,dy=50,cutx=0,cuty=0,info=false)
b=v2.defreq(fy=0,fx=57,sharp=100,dx=50,dy=50,cutx=0,cuty=0,info=false)
r=v2.defreq(fy=0,fx=39,sharp=100,dx=50,dy=50,cutx=0,cuty=0)
g1=v2.defreq(fy=0,fx=49,sharp=100,dx=50,dy=50,cutx=0,cuty=0)
b1=v2.defreq(fy=0,fx=65,sharp=100,dx=50,dy=50,cutx=0,cuty=0,fx2=100,fy2=0)
r1=v2.defreq(fy=0,fx=47,sharp=100,dx=50,dy=50,cutx=0,cuty=0)
x1=merge(r1,r)
y1=merge(g,g1)
z1=merge(b1,b1)
x=mt_makediff(v2,x1).converttorgb()
y=mt_makediff(v2,y1).converttorgb()
z=mt_makediff(v2,z1).converttorgb()
mergergb(x,y,z)
converttoyv12()
ColorYUV(autogain=false,autowhite=true)
sincresize(width(v),height(v))
mergechroma(v,last,1)
return last
}
This may not help at all. It's the first script I wrote,and has some severe problems. Only changes made are the resize and the addition of mergechroma.
Edit: Would produce clips 256*256, so edited again.
StainlessS
6th April 2016, 21:06
Note without mt_makediff(...,Chroma="-128") or similar, will have garbage in UV, only because earlier clips are grayscale might you escape
having crud in UV, and sometimes you will not escape. (convertToRGB will use garbage if there)
John, had a bit of a problem downloading your wiggly line drawing, I usually double click url I think in PhotoBucket and it copies as
...
Cannot download yours because it is inserted as http: etc, downloads web page instead.
I think I had to set some setting or other when I first joined to make [IMG] tag the default.
EDIT: I got it now, inserted link into one of my posts, and enclosed in [IMG] tags, saveas and then remove link.
StainlessS
6th April 2016, 22:55
Would you like to try this out, combined into single function, and attempted a little speed up (not too successful, about 0.5 FPS faster on Doctor Who clip,
DFreq take most time).
Rename as you will, perhaps could change Bool Full arg to some Float arg for Tweak and/or Merge Weight arg, and do shift or not based on that. (LINES IN BLUE, ie make more user configurable)
Function CmMod(clip c, Bool "Full") { # (c) MWilson, http://forum.doom9.org/showthread.php?t=173364
# Progressive Only : MUST be MOD 4 Width and Height, Otherwise will crop Mod 4
c = c.Crop(0,0,c.Width/4*4,c.Height/4*4).ConvertToYV12.GrayScale
Full = Default(Full,True)
BordW = c.width /2 # Must be even, Avoid using Width and Height as variables (misleading)
BordH = c.height /2
smallc= c.sincresize(256,256)
Padc = smallc.addborders(BordW,BordH,BordW,BordH)
# Crop Padding off again, less work below (crop is qwik)
r = Padc.defreq(fy=0,fx=39,sharp=100,dx=50,dy=50,cutx=0,cuty=0).crop(BordW,BordH,-BordW,-BordH)
r1 = Padc.defreq(fy=0,fx=47,sharp=100,dx=50,dy=50,cutx=0,cuty=0).crop(BordW,BordH,-BordW,-BordH)
g = Padc.defreq(fy=0,fx=59,sharp=100,dx=50,dy=50,cutx=0,cuty=0).crop(BordW,BordH,-BordW,-BordH)
g1 = Padc.defreq(fy=0,fx=51,sharp=100,dx=50,dy=50,cutx=0,cuty=0).crop(BordW,BordH,-BordW,-BordH)
b = Padc.defreq(fy=0,fx=65,sharp=100,dx=50,dy=50,cutx=0,cuty=0).crop(BordW,BordH,-BordW,-BordH)
b1 = Padc.defreq(fy=0,fx=59,sharp=100,dx=50,dy=50,cutx=0,cuty=0,fx2=100,fy2=0).crop(BordW,BordH,-BordW,-BordH)
x1 = merge(r,r1)
y1 = merge(g,g1)
z1 = 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)
ColorYUV(autowhite=true)
mergechroma(c,last,1.0)
Last = (Full) ? Eval ("""
u = utoy()
v = vtoy()
u3=repair(c.lanczosresize(c.width/2,c.height/2),u)
v3=repair(c.lanczosresize(c.width/2,c.height/2),v)
ytouv(u3,v3,c)
tweak(sat=7.5,interp=32)
mergechroma(c,last,0.33)
coloryuv(autowhite=true)
Return Last
""") : Last
return last
}
johnmeyer
6th April 2016, 23:02
I tried CmMod. Much faster. Seems like the same color/quality results as the original script. Was that the intent?
StainlessS
6th April 2016, 23:07
Oh, only about 0.5 FPS faster on my Core Duo.
No attempt to change functionality, only wanted to clarify and perhaps speed up a bit, also do away with one of the ConvertToYV12 and GrayScale calls.
I've still no idea why the padding is necessary.
EDIT: Although I only timed it for a few seconds.
EDIT: And yes, I tried comparison with previous script, bit for bit identical on downsized GoldFinger frame (org 2048xnnnn).
And MW's little test modded a bit
r=Blankclip(Color=$FF0000)
g=Blankclip(Color=$00FF00)
b=Blankclip(Color=$0000FF)
original=stackhorizontal(r,g,b).sincresize(256,256)
filter=original.greyscale().CmMod()
tw=Filter.Tweak(Sat=4.0)
stackvertical(original.converttoyv12(),filter,tw)
return last
We do get some blue, but rotten green :)
MWilson
7th April 2016, 00:46
Function Cm3Mod(clip c, Bool "Full") { # (c) MWilson, http://forum.doom9.org/showthread.php?t=173364
# Progressive Only : MUST be MOD 4 Width and Height, Otherwise will crop Mod 4
c = c.Crop(0,0,c.Width/4*4,c.Height/4*4).ConvertToYV12.GrayScale
Full = Default(Full,True)
BordW = c.width /2 # Must be even, Avoid using Width and Height as variables (misleading)
BordH = c.height /2
smallc= c.sincresize(256,256)
Padc = smallc.addborders(BordW,BordH,BordW,BordH)
# Crop Padding off again, less work below (crop is qwik)
r = Padc.defreq(fy=0,fx=39,sharp=100,dx=50,dy=50,cutx=0,cuty=0).crop(BordW,BordH,-BordW,-BordH)
r1 = Padc.defreq(fy=0,fx=47,sharp=100,dx=50,dy=50,cutx=0,cuty=0).crop(BordW,BordH,-BordW,-BordH)
g1 = Padc.defreq(fy=0,fx=51,sharp=100,dx=50,dy=50,cutx=0,cuty=0).crop(BordW,BordH,-BordW,-BordH)
b1 = Padc.defreq(fy=0,fx=59,sharp=100,dx=50,dy=50,cutx=0,cuty=0,fx2=100,fy2=0).crop(BordW,BordH,-BordW,-BordH)
x1 = merge(r,r1)
y1 = merge(smallc.invert(),g1)
z1 = merge(smallc.invert(),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)
ColorYUV(autowhite=true)
mergechroma(c,last,1.0)
Last = (Full) ? Eval ("""
u = utoy()
v = vtoy()
u3=repair(c.lanczosresize(c.width/2,c.height/2),u)
v3=repair(c.lanczosresize(c.width/2,c.height/2),v)
ytouv(u3,v3,c)
tweak(sat=7.5,interp=32)
mergechroma(c,last,0.33)
coloryuv(autowhite=true)
Return Last
""") : Last
return last
}
StainlessS, try the same test with the above mod.
Edit: B and G became pointless using above. Doh! Updated.
StainlessS
7th April 2016, 03:27
MW, Sorry can you clarify. Are you saying previous post is misake or that the original CmMod is in error (I took it to be the former).
I've looked at comparison with original CmMod and in first scene after credits, white is better but guys forehead is somewhat overbright.
In doctor scenes, get rid of mid pinkish stuff but doctor is flaring a little more orange.
If previous post is the mistake, then delete and I'll delete this post.
Going to bed soon.
MWilson
7th April 2016, 04:01
StainlessS, I actually meant the latter.
http://i1053.photobucket.com/albums/s461/Morgan_Dale_Wilson/cm3mod2_zps5q9ivoyb.png (http://s1053.photobucket.com/user/Morgan_Dale_Wilson/media/cm3mod2_zps5q9ivoyb.png.html)
Top: Original Middle: cmmod Bottom: cm3mod
Bottom two used the tweak values of 4 for sat.
StainlessS
7th April 2016, 04:23
Yeh but it really screws up some other colors, see the Kodak type (DQ-Tools.bmp)
and basically most of the others (Jurassic park the stuff of nightmares) and eg football field beetroot midfield.
Beddy byes ZZZzzzzz.
EDIT: I mean with a tweak of sat=4.0.
And the eg bright blue in kodak thing is still black (other saturated similar probs).
That fix just fixes that little demo.
TheFluff
7th April 2016, 04:39
Yeh but it really screws up some other colors, see the Kodak type (DQ-Tools.bmp)
and basically most of the others (Jurassic park the stuff of nightmares) and eg football field beetroot midfield.
That's because this script is just cargo cult programming. Restoring color information that doesn't exist is obviously impossible. What this script does is just make colors up. In some rare cases it gets some colors not entirely wrong, if you muck around with the parameters enough, which was apparently enough to make OP think this approach could be made to work in general. It can't.
Automatically restoring color information to a grayscale image or image sequence requires some kind of clues from its original color form (such as in that BBC case which used crosstalk for this purpose) or it's pure guesswork. The neural network approach is guesswork, but it's educated guesswork based on a very large dataset of grayscale/color image pairs. This, on the other hand, is astonishingly bad guesswork and a waste of time.
MWilson
7th April 2016, 04:55
Function CmxMod(clip c, Bool "Full") { # (c) MWilson, http://forum.doom9.org/showthread.php?t=173364
# Progressive Only : MUST be MOD 4 Width and Height, Otherwise will crop Mod 4
c = c.Crop(0,0,c.Width/4*4,c.Height/4*4).ConvertToYV12.GrayScale
Full = Default(Full,True)
BordW = c.width /2 # Must be even, Avoid using Width and Height as variables (misleading)
BordH = c.height /2
smallc= c.sincresize(256,256)
Padc = smallc.addborders(BordW,BordH,BordW,BordH)
# Crop Padding off again, less work below (crop is qwik)
r = Padc.defreq(fy=0,fx=39,sharp=100,dx=50,dy=50,cutx=0,cuty=0).crop(BordW,BordH,-BordW,-BordH)
r1 = Padc.defreq(fy=0,fx=47,sharp=100,dx=50,dy=50,cutx=0,cuty=0).crop(BordW,BordH,-BordW,-BordH)
g = Padc.defreq(fy=0,fx=59,sharp=100,dx=50,dy=50,cutx=0,cuty=0).crop(BordW,BordH,-BordW,-BordH)
g1 = Padc.defreq(fy=0,fx=51,sharp=100,dx=50,dy=50,cutx=0,cuty=0).crop(BordW,BordH,-BordW,-BordH)
b = Padc.defreq(fy=0,fx=65,sharp=100,dx=50,dy=50,cutx=0,cuty=0).crop(BordW,BordH,-BordW,-BordH)
b1 = Padc.defreq(fy=0,fx=59,sharp=100,dx=50,dy=50,cutx=0,cuty=0,fx2=100,fy2=0).crop(BordW,BordH,-BordW,-BordH)
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)
ColorYUV(autowhite=true)
mergechroma(c,last,1.0)
Last = (Full) ? Eval ("""
u = utoy()
v = vtoy()
u3=repair(c.lanczosresize(c.width/2,c.height/2),u)
v3=repair(c.lanczosresize(c.width/2,c.height/2),v)
ytouv(u3,v3,c)
tweak(sat=7.5,interp=32)
mergechroma(c,last,0.33)
coloryuv(autowhite=true)
Return Last
""") : Last
return last
}
Try this out.
That's because this script is just cargo cult programming. Restoring color information that doesn't exist is obviously impossible. What this script does is just make colors up. In some rare cases it gets some colors not entirely wrong, if you muck around with the parameters enough, which was apparently enough to make OP think this approach could be made to work in general. It can't.
Automatically restoring color information to a grayscale image or image sequence requires some kind of clues from its original color form (such as in that BBC case which used crosstalk for this purpose) or it's pure guesswork. The neural network approach is guesswork, but it's educated guesswork based on a very large dataset of grayscale/color image pairs. This, on the other hand, is astonishingly bad guesswork and a waste of time.
Does this say anywhere (BTW, I mean anywhere) that it is color restoration. No! It is colorization, plain and simple.
Trying to make it better should not be met with this much hatred.
TheFluff
7th April 2016, 05:35
I don't hate you, I'm just telling it like it is, dude. Earlier in the thread you said this, though:
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.
Which kinda called for some harsh truths. If you're now aware that you're just adding random colors, then my work here is done and you can keep on keeping on. It's your video, if doing things to it makes it look better to you I'm certainly not going to stop you.
MWilson
7th April 2016, 05:52
If you're now aware that you're just adding random colors, then my work here is done and you can keep on keeping on.
Not random.
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.
Yep. It's using the light.
Just because I'm not astonishing at this doesn't mean it couldn't work.
And you are correct that I was trying to achieve color restoration.
vcmohan
7th April 2016, 12:32
I am rather surprised at the frequency domain filtered results are used for this. The borders of colored parts actually are reflected in the frequency domain. It does not discriminate between colors as the colors have no special rendering in the input. Ascribing colors to the segments of frequency ranges does not give any consistent colored image. Yes it will give some color. More easily the input image can be segmented based on the Y values and colors attached as per the intensity range. I do not see any logic in resorting to the frequency domain operations for this type of image manipulation.
MWilson
7th April 2016, 14:09
Function Cmx5Mod(clip c, Bool "Full") { # (c) MWilson, http://forum.doom9.org/showthread.php?t=173364
# Progressive Only : MUST be MOD 4 Width and Height, Otherwise will crop Mod 4
c = c.ConvertToYV12.GrayScale
Full = Default(Full,True)
smallc= c.sincresize(256,256)
# Crop Padding off again, less work below (crop is qwik)
r = smallc.defreq(fy=0,fx=39,sharp=100,dx=50,dy=50,cutx=0,cuty=0)
r1 = smallc.defreq(fy=0,fx=47,sharp=100,dx=50,dy=50,cutx=0,cuty=0)
g = smallc.defreq(fy=0,fx=37,sharp=100,dx=50,dy=50,cutx=0,cuty=0)
g1 = smallc.defreq(fy=0,fx=85,sharp=100,dx=50,dy=50,cutx=0,cuty=0)
b = smallc.defreq(fy=0,fx=65,sharp=100,dx=50,dy=50,cutx=0,cuty=0)
b1 = smallc.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(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)
ColorYUV(autowhite=true)
mergechroma(c,last,1.0)
Last = (Full) ? Eval ("""
u = utoy()
v = vtoy()
u3=repair(c.lanczosresize(c.width/2,c.height/2),u)
v3=repair(c.lanczosresize(c.width/2,c.height/2),v)
ytouv(u3,v3,c)
tweak(sat=7.5,interp=32)
mergechroma(c,last,0.33)
coloryuv(autowhite=true)
Return Last
""") : Last
return last
}
The borders were just slowing down the filter.:o
This needs a bit of color correction after the fact, FWIW.
StainlessS
8th April 2016, 02:14
What the previous members have said is completely correct, but that does not make this a complete waste of time and space,
it still does create some really magnificent results, maybe just by accident, but pretty damn good just the same.
Dont let TheFluff bother you, he treats everyone with equal disdain (not just you, a 'Fluff' is a fart [Brit], silent but very unpleasant,
such is his nature, just a shame that the silent part is not given equal weight).
johnmeyer
8th April 2016, 02:48
What the previous members have said is completely correct, but that does not make this a complete waste of time and space ... it still does create some really magnificent results, maybe just by accident, but pretty damn good just the same.I still think adding a replacement table after this script has completed might make the results much more useful.
My idea is based on these observations:
1. The gamut of colors created is quite narrow. It really only seems to create three or four colors.
2. The colors seem to track objects remarkably well; green leaves don't suddenly turn purple.
So, if we could list the small range of colors used (some of StainlessS functions seem to be designed for this sort of thing) and then create a table that says, "replace these five colors with five different colors," then we might have something.
The one issue I see that keeps this script from being useful, even in its current state, is the odd tendency to put green at the edges and purple in the middle. If that could be smoothed out, then even with the faux colors, it could be useful, and if a replacement table could be created, it would almost be marketable.
StainlessS
8th April 2016, 03:11
VcMohan has a similar type plugin, FFTQuiver (or similar) and it also has 1D version (which I think this uses [fy=0 in all cases]),
dont know if can be directly converted, but if can then I am guessing that it could be quicker (even if the plugin 2D version is slower, dont know if so).
I think it also has (from memory) the ability to supply some kind of mask which allows to select frequencies (2D version).
Anyway, might be worth a look.
MWilson
8th April 2016, 03:19
The one issue I see that keeps this script from being useful, even in its current state, is the odd tendency to put green at the edges and purple in the middle
I just tried the version I posted last and it doesn't seem to have this problem.
Edit: Updated first post.
StainlessS
8th April 2016, 03:42
Just had a look at Cmx5,
Whites are sometimes too white (glaring, ie 'burnt out'), we lost some colors that were previously correct, but cant help that (Dr Who green swamp grass).
Center pink mostly gone. Green edges better. (perhaps due to high frequencies on frame edge), other green areas seem to mostly have disappeared.
Overall, better, methinks (Shirley is still gold, and that is all that really matters :) ).
Now mainly sepia recolor replacement alternative (BUT better, and consistent).
Nice job.
EDIT: Dr W, at 1:00 extra presence of greenish tinge, methinks maybe responsible for the 'burnt out' whites, perhaps slight reduction in
green if possible.
EDIT: Perhaps need some kind of legal YUV restrictor (some YUV combos do not convert to RGB, eg Y=$FF, U=$81, pure white +
additional U).
EDIT: Green edges are not a problem, thats what crop is for.
EDIT: Pinkish Daleks seem to be a thing of the past :)
EDIT: Green edges, perhaps add some Padding.
function Padding(clip c, int left, int top, int right, int bottom) {
# Didee: http://forum.doom9.org/showthread.php?p=1596804#post1596804
# eg, Padding(32,32,0,0).Padding(0,0,32,32)
w = c.width()
h = c.height()
c.pointresize( w+left+right, h+top+bottom, -left, -top, w+left+right, h+top+bottom )
}
StainlessS
8th April 2016, 04:54
No more green borders (at all).
Function Padding(clip c, int left, int top, int right, int bottom) {
# Didee: http://forum.doom9.org/showthread.php?p=1596804#post1596804
# eg, Padding(32,32,0,0).Padding(0,0,32,32)
w = c.width()
h = c.height()
c.pointresize( w+left+right, h+top+bottom, -left, -top, w+left+right, h+top+bottom )
}
Function Cmx6Mod(clip c, Bool "Full",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
Full = Default(Full,True)
DownSz=Default(DownSz,True)
Pad=Default(Pad,2) # Multiples of 2 only
c = c.Crop(0,0,c.Width/2*2,c.Height/2*2).ConvertToYV12.GrayScale.Padding(Pad,Pad,Pad,Pad)
smallc = (DownSz) ? c.sincresize(c.Width/4*2,c.Height/4*2) : c
r = smallc.defreq(fy=0,fx=39,sharp=100,dx=50,dy=50,cutx=0,cuty=0)
r1 = smallc.defreq(fy=0,fx=47,sharp=100,dx=50,dy=50,cutx=0,cuty=0)
g = smallc.defreq(fy=0,fx=37,sharp=100,dx=50,dy=50,cutx=0,cuty=0)
g1 = smallc.defreq(fy=0,fx=85,sharp=100,dx=50,dy=50,cutx=0,cuty=0)
b = smallc.defreq(fy=0,fx=65,sharp=100,dx=50,dy=50,cutx=0,cuty=0)
b1 = smallc.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(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)
ColorYUV(autowhite=true)
mergechroma(c,last,1.0)
Last = (Full) ? Eval ("""
u = utoy()
v = vtoy()
u3=repair(c.lanczosresize(c.width/2,c.height/2),u)
v3=repair(c.lanczosresize(c.width/2,c.height/2),v)
ytouv(u3,v3,c)
tweak(sat=7.5,interp=32)
mergechroma(c,last,0.33)
coloryuv(autowhite=true)
Return Last
""") : Last
return last.Crop(Pad,Pad,-Pad,-Pad)
}
EDIT: Added DownSz Bool. Without down size likely fewer higher frequencies, maybe less noise
EDIT: or maybe more high freq ?, is SincResize sharp ?
EDIT: Added Pad Int.
EDIT: Definite difference (ClipDelta) between DownSz True/False, but cant really see it.
EDIT: Doc W, 2:30, change in fringing evident around the doctor with DownSz=False, not sure if better or worse,
also seems to be change in skin color.
EDIT: Some things seem a little more orange with DownSz=False, and more blue(looking white) with DownSz=True.
StainlessS
8th April 2016, 20:27
Here Cmx7Mod, a lil bit faster.
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
smallc = (Pad>0) ? smallc.pointresize(smallc.Width+Pad*2,smallc.Height+Pad*2,-Pad,-Pad,smallc.Width+Pad*2,smallc.Height+Pad*2) : smallc
r = smallc.defreq(fy=0,fx=39,sharp=100,dx=50,dy=50,cutx=0,cuty=0)
r1 = smallc.defreq(fy=0,fx=47,sharp=100,dx=50,dy=50,cutx=0,cuty=0)
g = smallc.defreq(fy=0,fx=37,sharp=100,dx=50,dy=50,cutx=0,cuty=0)
g1 = smallc.defreq(fy=0,fx=85,sharp=100,dx=50,dy=50,cutx=0,cuty=0)
b = smallc.defreq(fy=0,fx=65,sharp=100,dx=50,dy=50,cutx=0,cuty=0)
b1 = smallc.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(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
Crop(Pad,Pad,-Pad,-Pad) # Crop padding
lanczos4resize(c.Width,c.Height)
ColorYUV(autowhite=true)
mergechroma(c,last,1.0)
Last = (Sat>0.0) ? Eval ("""
# Removed Rubbish from here (did nothing). Repair was repairing temp downsized source Luma, not created chroma.
# If reversed, everything purple.
# Did not make sense anyway, luma rel 0, chroma rel 128.
tweak(sat=7.5,interp=32) # Perhaps this needs lowering somewhat.
mergechroma(c,last,Sat)
# coloryuv(autowhite=true) # Dont really do much but waste time (only tweaked and MergeChroma)
Return Last
""") : Last
return Last
}
I seem to be suffering from a Defreq bug, with Access violations in MPC-HC and VDMod (not yet in VD current).
Can anyone else verify same ? (They seem to just happen randomly, works ok one minute, next run exact same script crash)
Here MPC-HC debug output (sometimes sends multiple error reports over the net).
ntdll!RtlpCoalesceFreeBlocks+0x36e
ntdll!RtlFreeHeap+0x2e9
msvcrt!free+0xc3
WARNING: Following frames may be wrong.
fftw3!fftwf_printer_destroy+0x4cd3
defreq+0x1c27
avisynth!DllGetClassObject+0xee916
ntdll!RtlpDeCommitFreeBlock+0x2e3
ntdll!RtlFreeHeap+0x3a2
msvcrt!free+0xc3
WARNING: Following frames may be wrong.
fftw3!fftwf_printer_destroy+0x71a3
defreq+0x1c34
avisynth!DllGetClassObject+0xee916
ntdll!RtlFreeHeap+0x354
msvcrt!free+0xc3
WARNING: Following frames may be wrong.
fftw3!fftwf_assertion_failed+0x1c84
defreq+0x1c27
avisynth!DllGetClassObject+0xee916
ntdll!RtlFreeHeap+0x354
msvcrt!free+0xc3
WARNING: Following frames may be wrong.
fftw3!fftwf_printer_destroy+0x71a3
defreq+0x1c27
avisynth!DllGetClassObject+0xee916
avisynth!avs_at_exit+0x7e027
avisynth!DllGetClassObject+0xee916
ntdll!RtlpCoalesceFreeBlocks+0x36e
ntdll!RtlpDeCommitFreeBlock+0x371
ntdll!RtlFreeHeap+0x3a2
msvcrt!free+0xc3
WARNING: Following frames may be wrong.
fftw3!fftwf_free+0x14
defreq+0x1c4e
avisynth!DllGetClassObject+0xee916
WARNING: Following frames may be wrong.
fftw3!fftwf_plan_awake+0x17
WARNING: Following frames may be wrong.
fftw3!fftwf_assertion_failed+0x1128
defreq+0x1c27
avisynth!DllGetClassObject+0xee916
avisynth!avs_at_exit+0x7e027
avisynth!DllGetClassObject+0xee916
ntdll!RtlpCoalesceFreeBlocks+0x231
ntdll!RtlFreeHeap+0x2e9
msvcrt!free+0xc3
WARNING: Following frames may be wrong.
fftw3!fftwf_free+0x14
defreq+0x1c4e
avisynth!DllGetClassObject+0xee916
Groucho2004
8th April 2016, 21:49
I seem to be suffering from a Defreq bug, with Access violations in MPC-HC and VDMod (not yet in VD current).
Can anyone else verify same ? (They seem to just happen randomly, works ok one minute, next run exact same script crash)
I can't reproduce your problem but please try this (https://www.dropbox.com/s/t3z6amnsakinv9z/defreq.dll?dl=0) version of defreq. It's an ICL11 build, also a bit faster than the original.
StainlessS
8th April 2016, 22:11
Thatks Groucho, but crash on 3rd run with this.
Avisource("Doctor.avi")
crop(0,0,-2,-2) # Non mod 4
SAT=0.33
GrayScale
Cmx7Mod
Return Last
got to dash bus coming in 3 mins.
Groucho2004
8th April 2016, 23:30
I seem to be suffering from a Defreq bug, with Access violations in MPC-HC and VDMod (not yet in VD current).
Can anyone else verify same ? (They seem to just happen randomly, works ok one minute, next run exact same script crash)
I can reproduce it now on XP32. Before I was on XP64 where I couldn't make it crash. Odd.
MWilson
9th April 2016, 00:53
function cma (clip c)
{
c=c.greyscale().converttoyv12()
v=c.converttoyv12().greyscale().sincresize(512,512)
r=v.F2Quiver(2,2,39,47,0,3,3,100,188,0,rescale=false,frad=16)
g=v.F2Quiver(2,3,118,128,0,3,2,74,128,0,rescale=false,frad=64)
b=v.F2Quiver(2,2,96,128,0,2,3,128,130,0,3,3,74,128,0,rescale=false,frad=64)
mergergb(r,g,b)
autolevels()
converttoyv12()
coloryuv(autowhite=true)
tweak(sat=4.5,interp=32)
bilinearresize(width(c),height(c))
mergechroma(c,last,.5)
}
function cmx (clip c)
{
c=c.greyscale()
merge(c.turnleft().cma().turnright(),c.cma())
return last
}
Edit: Very much improved. May work...
Edit: Updated to use new version of F2Quiver...
Experimental, uses F2Quiver, I would suggest using HQDN3D at max on chroma. Needs more work... :)
StainlessS
9th April 2016, 03:18
MW, I will try that, but not this day.
This day is for rest and relaxation, (that and its now 03:15, need some sleep).
Just the same, take a look at prev script, works quite well apart from the crashes.
Ill get to cmx presently. Peace Bro.
Also, did you try 1D FFTQuiver thing, no go ?
G2004, I'll maybe come back, gorra get some shut eye.
Come back already, G, does that look like Defreq bug to you (I was not sure enough and did not want to cry WOLF !!!)
EDIT: It was actually doin it a bit a few days back but I dismissed it as an MPC peculiarity, without even looking at error report.
(MPC sometime is a bit annoying).
The Licensing hours in this country are so very very bad, but at least they dont shut at 22:30 hours any more.
Everywhere else, seems to be so much more civilized (you can get drunk as a skunk, and for longer).
22:30 hrs, I once saw a guy drink 5 bottles of Newcastle Brown Ale (Brown Dog ) in 20 mins, just to fulfill his
evenings quota before time was called.
(Them woz the daze).
Groucho2004
9th April 2016, 08:44
Come back already, G, does that look like Defreq bug to you (I was not sure enough and did not want to cry WOLF !!!)
EDIT: It was actually doin it a bit a few days back but I dismissed it as an MPC peculiarity, without even looking at error report.
I played around with it for a while. The crashes are random and appear to be related to the multiple calls to defreq. Replacing the last 2 or 3 defreq calls with dummies and it won't crash.
vcmohan
9th April 2016, 14:59
Experimental, uses F2Quiver, seems to reproduce fairly accurate colors. I would suggest using HQDN3D at max on chroma. Needs more work... :)
I find you are using the older version of FFTQuiver plugin. Results may not be different with newer version.
StainlessS
9th April 2016, 15:53
MW, I shall be using the v2.6 version FFTQuiver from here:- http://www.avisynth.nl/users/vcmohan/
(current cmx does not work with it.
EDIT: Cmx7Mod., Tried older FFTW.dll same problem.
Current FFTW.dll, Using VDub current on Duel Core Core Duo 2.4Ghz, Plays about realtime speed for about 2 seconds, and freezes
for about 1 second, repeatedly (although has not as yet crashed in VDub current).
vcmohan
10th April 2016, 07:05
To day I have modified the html write up file of 2.6 and avs+ versions of FFTQuiver.
raffriff42
10th April 2016, 18:05
https://www.dropbox.com/s/sha7a9nb7izccb8/cmx-test-stack9.jpg?raw=1
Huh, post #1 gets the blue(ish) sky and post #89 gets the rainbow (kinda).
"even a broken clock is right twice a day (https://www.quora.com/What-does-the-phrase-even-a-broken-clock-is-right-twice-a-day-mean)"
jones1913
10th April 2016, 18:36
Hehe fun to play with...
Here with an X-Files episode (broadcasted in b/w)
http://s9.postimg.org/tcg1q1ybz/cmx.jpg
StainlessS
10th April 2016, 21:04
At least as it curently stands, think Cmx7Mod provides more hopeful future (if bug can be fixed, tried fftw.dll v3.0.1, as supplied by my original FFT3DFilter, same access violations).
Here cmx modified a bit.
Function cmx(clip c, Float "Sat",Int "Pad") { # (c) MWilson, http://forum.doom9.org/showthread.php?t=173364
# Progressive Only : MUST be MOD 4 Width and Height, Otherwise will crop Mod 4 (F2Quiver limitation)
Function cmx_Lo_Level(clip v,Int Pad) {
# Parmameters in bunches of 5,
# 1) Symmetry. [1, Circular, 2. Horizontal, 3, Vertical, 4. Linear Fan, 5. Point].
# 2) Type. [1. low cut, 2. High cut, 3. Band Pass, 4, Band stop, 5. Notch].
# 3) Notch freq, [low freq of band, or X freq of point or angle1 for linear fan].
# 4) High freq of band, or angle2 for linear fan, or y freq of point.
# 5) Degree of Shaprness. 0 to 24. If 0 Gaussian filter otherwise Butterworth filter is designed.
r=v.F2Quiver(2,2, 39, 47,0, 3,3,100,188,0, rescale=false,frad=16)
g=v.F2Quiver(2,3,118,128,0, 3,2, 74,128,0, rescale=false,frad=64)
b=v.F2Quiver(2,2, 96,128,0, 2,3,128,130,0, 3,3,74,128,0, rescale=false,frad=64)
mergergb(r,g,b) # Result is TV Levels RGB, 16 -> 235
(Pad > 0) ? crop(pad,pad,-pad,-pad) : NOP # Must remove padding before autolevels
autolevels() # Stretch 0 -> 255
ConvertToYV12 # TV Levels YV12
coloryuv(autowhite=true) # Center chroma
tweak(sat=3.5,interp=32) # pump up sat
}
Sat = Default(Sat,0.33) # Default 0.33, 0.0 -> 1.0
Pad = (Default(Pad,4)+1)/2*2 # Round up next multiple of 2, Avoid green border.
c = c.Crop(0,0,c.Width/4*4,c.Height/4*4).ConvertToYV12.GrayScale
smallc = c.sincresize(512,512)
smallc = (Pad>0) ? smallc.pointresize(smallc.Width+Pad*2,smallc.Height+Pad*2,-Pad,-Pad,smallc.Width+Pad*2,smallc.Height+Pad*2) : smallc
chroma_1 = smallc.cmx_Lo_Level(Pad)
chroma_2 = smallc.turnleft().cmx_Lo_Level(Pad).turnright()
merge(chroma_1,chroma_2)
lanczos4resize(c.width,c.height)
c.mergechroma(last,Sat)
return last
}
Avisource("Doctor.avi")
cmx(Pad=8)
Quite a bit of fringing.
EDIT: Made a couple of small changes.
EDIT: RaffRiff42, Cmx7Mod is quite a bit better than Cmx5Mod (if you dont count Access Violations in Defreq).
vcmohan
11th April 2016, 05:27
Gaussian filters which you are using in F2Quiver are supposed to deliver outputs with no or least ringing. Butterworth as sharpness increases results in more ringing.
I read in one of the posts of freezing of frames. This may be because of multiple calls to FFTW3 dll in 2.6 version. Instead of avisynth 2.6 if you use avisynth+, either 32 bit or 64 bit versions and FFTQuiver is designed to work in multi thread mode under it. Most likely freezes may not occur. The following lines of code may be added to script after loading plugins
SetFilterMTMode("F1Qiver",2)
SetFilterMTMode("F2Qiver",2)
SetFilterMTMode("F2QTest",3)
SetFilterMTMode("F1QTest", MT_SERIALIZED)
StainlessS
11th April 2016, 05:39
OK, then someone else should take over script cleanups/mods, I use neither Avisynth+ nor MT.
Freezing is much more evident in Defreq Cmx7Mod script (along with the access violations).
EDIT: Although when not freezing Cmx7Mod plays at almost realtime speed on my sedate running Core Duo 2.4GHz m/c.
FFTQuiver cmx runs a lot more slowly. [EDIT: May be due to use of AutoLevels]
EDIT: MWilson, you seem to be using vertical symmetry (mode 3) along with TurnLeft/TurnRight, is this really as intended ?
StainlessS
11th April 2016, 06:50
Just tried compile Defreq using VS 6.0.
Replaced Avisynth header VERSION 2, with VERSION 3 (v2.58),
and also replaced old Info.h with IanB refactored version of Oct 2010.
Still have Access Violations in Release dll, but not in Debug dll (Debug dll almost as fast as release for Cmx7Mod).
I'll see if v2.6 Avisynth VERSION 6 header makes any difference.
EDIT: Nope, still crashes on exit from v2.6 compiled DeFreq (release mode).
EDIT: In v2.6 Debug dll, get and awful lot of these identical messages to debug window
First-chance exception in VirtualDubMod.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.
And by 'Awful Lot' I mean hundreds, is that 'Normal' ? (still seems to run alright though)
EDIT: Darn it, getting the odd crash (on close) in Debug dll.
StainlessS
12th April 2016, 05:48
Small mod to Cmx7Mod, functionally pretty much the same, moved pad cropping, removed Eval. Still Has Access Violation on closure (sometimes)
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
}
Here is the Crashing code, the destructor
// This is where any actual destructor code used goes
DeFreq::~DeFreq() {
// This is where you can deallocate any memory you might have used.
fftwf_destroy_plan(plan);
fftwf_destroy_plan(plani);
fftwf_free(in);
fftwf_free(out);
free(psd);
if (hinstLib != NULL)
FreeLibrary(hinstLib);
}
Can crash pretty much anywhere in that code fragment.
EDIT: Stuttering does not seem as bad as it was, pretty reasonable speed, almost realtime on Core Duo 2.4Ghz.
vcmohan
12th April 2016, 05:52
Why not a code like this?
v= convertto Y8
F2Quiver(v
r=Convertto RGB
F2Quiver(v
g=Convertto RGB
F2Quiver(v,
b=Convertto RGB
mergergb
By standard Y8 must have dimensions in multiples of 4.
StainlessS
12th April 2016, 06:02
I'll leave that part to MWilson, I'll just tidy up script afterwards.
I'm assuming that MW is getting acquainted with F2Quiver as he has not been around recently.
He spent 4 years getting to grips with DFreq, and so is more familiar with that.
To me, both are a mystery :).
MWilson
12th April 2016, 07:08
function dsl (clip v)
{
v=v.greyscale().converttoyv12()
ds=v.gaussresize(width(v)/8,height(v)/8).blur(.25,.5).cmx7mod().gaussresize(width(v),height(v)).blur(.25,.5)
mergechroma(v,ds,1)
return last
}
Here's a quick script that could be helpful.
And StainlessS, you've got it exactly :)
Edit: The blur is probably too much.
StainlessS
12th April 2016, 10:47
Hi MW,
Thats a lot of downsize/upsize-ing.
Downsize by 8(Gauss), then Downsize 2(Sinc) and still has to be mod 2 result (ie should be ideally mod 32 input, else maybe weird chroma shifts).
Can you decide on either Gauss or Sinc, doing both probably aint a good idea (I'm assuming a single downsize, Gauss).
Also is there any relation between required downsize and BlurH/V.
StainlessS
12th April 2016, 11:24
Function Cmx8Mod(clip c, Float "Sat",Int "DownSz",Float "HBlur",Float "VBlur",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
myName="Cmx8Mod: "
Sat = Default(Sat,0.33) # Default 0.33, 0.0 -> 1.0
DownSz = Default(DownSz,8) # 1 (no downsize) or more
HBlur = Float(Default(HBlur,0.25)) # 0.25, 0.0 -> 1.58
VBlur = Float(Default(VBlur,HBlur*2.0)) # HBlur*2.0, 0.0 -> 1.58
Pad = (Default(Pad,2)+1)/2*2 # Round up next multiple of 2, Avoid green border.
Assert(Sat>=0.0&&Sat<=1.0,myName+"0.0 <= Sat <= 1.0")
Assert(DownSz>=1,myName+"1 <= DownSz")
Assert(HBlur>=0.0&&HBlur<=1.58,myName+"0.0 <= HBlur <= 1.58")
Assert(VBlur>=0.0&&VBlur<=1.58,myName+"0.0 <= VBlur <= 1.58")
c = c.Crop(0,0,c.Width/2*2,c.Height/2*2).ConvertToYV12.GrayScale # Mod 2
smallc = (DownSz>1) ? c.GaussResize((c.Width+DownSz-1)/(DownSz*2)*2,(c.Height+DownSz-1)/(DownSz*2)*2) : c # Mod 2
smallc = (HBlur!=0.0||VBlur!=0.0) ? smallc.Blur(HBlur,VBlur) : smallc
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
Gaussresize(c.Width,c.Height)
(HBlur!=0.0||VBlur!=0.0) ? Blur(HBlur,VBlur) : Last
mergechroma(c,ColorYUV(autowhite=true))
return (Sat>0.0) ? mergechroma(c,tweak(sat=7.5,interp=32),Sat) : Last
}
Shirley mostly still Gold, but showing a little bit of Envy :)
EDIT: Say what mods required.
EDIT: Is second blur really necessary after Gauss upsize ? (just comment out that line to test)
Overall better more natural colours but sometimes a little bit green.
Below B&W movie mostly converts "not so well", over bright desert scenes tend to be a lot green, but
below frame not so bad (indoors).
Get the Gold rimmed glasses and Anthony Quayle's great skin color (the guy looking away) :)
https://s20.postimg.cc/3w2d5kfwd/Alex0_zpsqpaibuot.png (https://postimg.cc/image/wlp927jw9/)
Here is current client script for testing
Import("AC7.avs") # Cmx7Mod.avs
#Imagesource("ShirleyEaton.jpg",end=0) crop(0,0,Width/2*2,Height/2*2).convertToYV12.BilinearResize(400,272)
#Imagesource("DQ-Tools_Color.BMP",end=0).convertToYV12
#Imagesource("JP_Test_Color.BMP",end=0).convertToYV12
#Imagesource("harold-lloyd.jpg",end=0) crop(0,0,Width/2*2,Height/2*2).convertToYV12
#Imagesource("Original Football.jpg",end=0).convertToYV12
#Avisource("Doctor.avi").convertToYV12
#Avisource("Test1.avi").convertToYV12
Avisource("IceColdInAlex_VCD.avi").convertToYV12
Org=Last # Display Color
AMP=True
GrayScale
#Org=Last # Display GrayScale
A=Cmx7Mod
B=Cmx8Mod
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
}
A bit Envious, but still better I think than the red gold of Cmx7Mod
https://s20.postimg.org/tt0mvx8xp/Envy0_zpskrenx25o.png (https://postimg.org/image/98vsxft6h/)
Not so pink
https://s20.postimg.cc/6stzjlb3x/Unpink0_zpsyqie2hyf.png (https://postimg.cc/image/5qjt11sah/)
MWilson
14th April 2016, 02:55
function cmf2x(clip v, Bool "UpSz", Bool "AutoLevels", int "UVBlur", float "Weight")
{# (c) MWilson, http://forum.doom9.org/showthread.php?t=173364
UpSz= Default (UpSz,False)
AutoLevels=Default (AutoLevels,True)
UVBlur=Default (UVBlur,12)
Weight=Default (Weight,.45)
v=v.converttoyv12().greyscale()
c=(AutoLevels) ? v.autolevels(12) : v
smallc=c.converttoy8()
cpad=(UpSz==True) ? c.sincresize(smallc.Width*2,smallc.Height*2) : c
g=cpad.F2Quiver(1,3,96,250,0,frad=16)
b=cpad.F2Quiver(1,3,110,250,0,frad=16)
r=cpad.F2Quiver(1,3,76,250,0,frad=16) ### may be lower
mergergb(r,g,b)
autolevels(12,autogamma=true)
converttoyv12()
coloryuv(autowhite=true)
tweak(sat=9.5,interp=32)
tweak(sat=10,interp=32)
converttorgb()
invert("G")
converttoyv12()
medianblur(0,UVBlur,UVBlur)
bilinearresize(width(c),height(c))
coloryuv(autowhite=true)
converttorgb()
autolevels(autogamma=true)
converttoyv12()
mergechroma(c,last,Weight)
}
Edit: Should also note that clip must be progressive.
Edit: Added Options, may need hue changes for different clips.
Edit: Extreme Makeover...
StainlessS
14th April 2016, 20:13
Not exactly a vast improvement
https://s20.postimg.cc/nhvffi7p9/Alex_Red0_zps73y2xy9l.png (https://postimg.cc/image/cv1ma2zjt/)
Perhaps we are using different versions of something.
EDIT: Added some Sleep(100) calls to destructor of Defreq, no joy I'm afraid, still produces Access Violations.
DeFreq::~DeFreq() {
// This is where you can deallocate any memory you might have used.
Sleep(100);
fftwf_destroy_plan(plan);
Sleep(100);
fftwf_destroy_plan(plani);
Sleep(100);
fftwf_free(in);
Sleep(100);
fftwf_free(out);
Sleep(100);
free(psd);
Sleep(100);
if (hinstLib != NULL)
FreeLibrary(hinstLib);
Sleep(100);
}
MWilson
15th April 2016, 10:41
http://i1053.photobucket.com/albums/s461/Morgan_Dale_Wilson/Dalek_zpsptfes3je.png (http://s1053.photobucket.com/user/Morgan_Dale_Wilson/media/Dalek_zpsptfes3je.png.html)
Seems to work fairly well. :)
StainlessS
15th April 2016, 10:54
That looks pretty nifty, what version of F2Quiver are you using ?
(and was script exact same as given ?)
MWilson
15th April 2016, 11:00
The 2.6 version. And yes, that is the raw output of the above script, but for some things I would recommend a hue change and/or rgbadjust. :)
http://i1053.photobucket.com/albums/s461/Morgan_Dale_Wilson/Examples_zpse75oggxi.png (http://s1053.photobucket.com/user/Morgan_Dale_Wilson/media/Examples_zpse75oggxi.png.html)
Edit: An odd example, it won't get colorbars, but it will get Dad's Army. (I'm Using Defaults)
MWilson
16th April 2016, 23:36
I've updated the first post. It might be beneficial merging the results of both.:)
Edit: This may be helpful, a quick and (admittedly) dirty blend.
:)
function CmB(clip v, String "Preset", float "Weight", int "CBlur",Bool "TS", int "TT", Bool "ALevel")
{# (c) MWilson, http://forum.doom9.org/showthread.php?t=173364
###Source Must Be Progressive
Preset= Default (Preset,"Normal")
Speed=(Preset=="Fast") ? 0: \
(Preset=="Normal") ? 1: \
(Preset== "Slow") ? 2: 3
Assert(Speed<3, "Invalid Preset: Valid Presets are Fast , Normal or Slow ")
Select(Speed,"Fast","Normal","Slow")
ALevel=Default (ALevel,False)
CBlur=Default (CBlur,15) ### Very dependent on source
Weight=Default (Weight,.45)
TR= Speed > 1 ? 5 : 10
TT=Default (TT,25)
TS=Default (TS,True)
LRad= Speed < 2 ? 4 : 12
v=v.converttoyv12().greyscale()
c=(ALevel==True) ? v.autolevels(12) : v
cpad=Speed < 2 ? c.bilinearresize(400,400) : c
g=cpad.F2Quiver(1,3,96,250,0,frad=16)
b=cpad.F2Quiver(1,3,110,250,0,frad=16)
r=cpad.F2Quiver(1,3,76,250,0,frad=16)
mergergb(r,g,b)
autolevels(LRad,autogamma=true)
converttoyv12()
coloryuv(autowhite=true)
tweak(sat=10,interp=32)
tweak(sat=10,interp=32)
converttorgb()
invert("G")
mergergb(showgreen,showred,showblue)
converttoyv12()
tweak(hue=90)
converttoyv12()
medianblur(0,CBlur,CBlur)
bilinearresize(width(c),height(c))
coloryuv(autowhite=true)
temporalsoften(last,TR,0,TT)
cc=Speed > 0 ? c.cmx7mod() : c
mergechroma(cc,Last,Weight)
}
Edit: Updated - Color Correction will more than likely be necessary.
StainlessS
17th April 2016, 10:31
Ill get back to this soon, bit busy at the moment.
MWilson
20th April 2016, 01:36
I still think adding a replacement table after this script has completed might make the results much more useful.
My idea is based on these observations:
1. The gamut of colors created is quite narrow. It really only seems to create three or four colors.
2. The colors seem to track objects remarkably well; green leaves don't suddenly turn purple.
So, if we could list the small range of colors used (some of StainlessS functions seem to be designed for this sort of thing) and then create a table that says, "replace these five colors with five different colors," then we might have something.
The one issue I see that keeps this script from being useful, even in its current state, is the odd tendency to put green at the edges and purple in the middle. If that could be smoothed out, then even with the faux colors, it could be useful, and if a replacement table could be created, it would almost be marketable.
johnmeyer, I just tried the filter in my latest post on your tennis match video and it (at least to me) seems like it may be getting closer. Though, I must admit it's far from "marketable" :o
Edit: Tested with a grayscaled babelcolour clip, stacked side by side and the results actually shocked me! Admittedly not the same, but close enough for me to freak out (especially considering the time differences). The input video seems to have been smoothed(?), and is slightly brighter than the standard clips. I will most definitely look into this!
Link to original video: Original Video (https://www.youtube.com/watch?v=SJhtkJ7Vg6E)
Edit: Nevermind, the test is simple enough ;)
StainlessS
20th April 2016, 21:34
Few small mods to cmB, did not quite work as planned [Calling cmx7mod threw away results of cmx7mod script, ie used luma from it instead of chroma].
Import("Cmx7Mod.avs")
Function CmB(clip v, Int "Speed", float "Weight", int "CBlur",Bool "TS", int "TT", Bool "ALevel") { # (c) MWilson, http://forum.doom9.org/showthread.php?t=173364
###Source Must Be Progressive
Speed= Default (Speed,1) # 0 = fast, 1 normal, 2 slow.
Assert(Speed>=0 && Speed <=2, "Speed, 1 <= Speed <= 2")
Weight=Float(Default (Weight,0.45))
CBlur = Default (CBlur,15) ### Very dependent on source
TS = Default (TS,True)
TT = Default (TT,25)
ALevel= Default (ALevel,False)
TR = Speed > 1 ? 5 : 10
LRad = Speed < 2 ? 4 : 12
#
v = v.Crop(0,0,v.Width/2*2,v.Height/2*2).ConvertToYV12.GrayScale # Mod 2, must be same as cmx7mod returns
c=(ALevel==True) ? v.autolevels(12) : v
cpad = Speed < 2 ? c.bilinearresize(400,400) : c
g=cpad.F2Quiver(1,3,96, 250,0,frad=16)
b=cpad.F2Quiver(1,3,110,250,0,frad=16)
r=cpad.F2Quiver(1,3,76, 250,0,frad=16)
mergergb(r,g,b)
autolevels(LRad,autogamma=true)
converttoyv12()
coloryuv(autowhite=true)
tweak(sat=10,interp=32).tweak(sat=10,interp=32)
converttorgb()
invert("G")
mergergb(showgreen,showred,showblue)
converttoyv12()
tweak(hue=90)
converttoyv12()
medianblur(0,CBlur,CBlur)
bilinearresize(width(c),height(c))
coloryuv(autowhite=true)
temporalsoften(last,TR,0,TT)
# cc=Speed > 0 ? c.cmx7mod() : c
# mergechroma(cc,Last,Weight)
Speed > 0 ? Last.Merge(c.cmx7mod(),0.5) : Last
mergechroma(c,Last,Weight)
}
#AviSource("Doctor.avi")
AviSource("BabelColour.avi")
Crop(0,0,Width/4*4,Height/4*4)
convertToYV12
Org=Last # Display Color
AMP=true
GrayScale
#Org=Last # Display GrayScale
A=CMB(0)
B=CMB(1)
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
}
but close enough for me to freak out
Yes indeed :)
Above shows BabelColour clip, Amp'ed diff, Cmb (Top R) and Cmb+cmx7mod (Bot R)
MWilson
20th April 2016, 23:26
Yep, merge(), not mergechroma() :D
StainlessS, your post is helpful as always :)
cork_OS
21st April 2016, 00:24
CMB(0) sometimes looks better than CMB(1):
http://i1376.photobucket.com/albums/ah1/Ivan_Nemow/th_Beware%20of%20the%20Car_zpsjdhhx4t7.png (http://s1376.photobucket.com/user/Ivan_Nemow/media/Beware%20of%20the%20Car_zpsjdhhx4t7.png.html)
StainlessS
21st April 2016, 01:28
Yes, also maybe good idea to drop reliance upon Defreq if it is gonna have access violations quite often.
I've found that the key phrase to search for when trying to understand what them there wierd FFT images are supposed to mean
is "2d frequency domain", plenty on google about that. But here two links that might be of interest (come up early in the google search).
1) :- http://dsp.stackexchange.com/questions/1637/what-does-frequency-domain-denote-in-case-of-images
2) :- http://wayback.archive.org/web/20130513181427id_/http://sharp.bu.edu/~slehar/fourier/fourier.html#filtering
EDIT: The Virtual Magnifying Glass app (2nd last post in "New Plugin and Utilities" thread) might be handy to see the individual
pixels set in the 2d Freq Domain images.
TheFluff
21st April 2016, 03:24
How have you still not figured out out that applying a bandpass filter isn't a good way to generate colors? I think you've fundamentally misunderstood the Fourier theory and what you can actually use a bandpass filter for. There is no correlation between frequency bands and RGB colors. You can keep tweaking the parameters and generate six colors that happen to almost fit a particular scene by pure coincidence, but this approach can never work in general. You're trying to extract information that doesn't exist. You'd be better off colorizing manually, because that's essentially what you're doing, except in an unnecessarily complicated way.
StainlessS
21st April 2016, 04:07
@Fluffy, Righty-O.
MWilson,
Here, mod.
Dont do any more 'lets add one of the previous versions for fun', will only slow down doing crops, resize, grayscale etc multiple times
and probably little good would come of it.
Here last two joined, see if you can get rid of some of it.
Function Cm_v100(clip c, Int "Speed", float "Weight", int "CBlur",Bool "TS", int "TT", Bool "ALevel",Float "Sat") {
# (c) MWilson, http://forum.doom9.org/showthread.php?t=173364
# Progressive Only : MUST be MOD 2 Width and Height, Otherwise will crop Mod 2
GScript("""
c = c.Crop(0,0,c.Width/2*2,c.Height/2*2).ConvertToYV12.GrayScale # Mod 2, must be same as cmx7mod returns
Speed= Default (Speed,1) # 0 = fast, 1 normal, 2 slow.
Assert(Speed>=0 && Speed <=2, "Speed, 1 <= Speed <= 2")
Weight=Float(Default (Weight,0.45))
CBlur = Default (CBlur,15) ### Very dependent on source
TS = Default (TS,True)
TT = Default (TT,25)
ALevel= Default (ALevel,False)
TR = Speed > 1 ? 5 : 10
LRad = Speed < 2 ? 4 : 12
Sat = Default(Sat,0.33) # Default 0.33, 0.0 -> 1.0
c2=(ALevel==True) ? c.autolevels(12) : c
c3 = Speed < 2 ? c2.bilinearresize(400,400) : c2 # This assumes that source is greater than 400x400, there reallys need to be a reason for resize.
g=c3.F2Quiver(1,3,96, 250,0,frad=16)
b=c3.F2Quiver(1,3,110,250,0,frad=16)
r=c3.F2Quiver(1,3,76, 250,0,frad=16)
mergergb(r,g,b)
autolevels(LRad,autogamma=true)
converttoyv12()
coloryuv(autowhite=true)
tweak(sat=10,interp=32).tweak(sat=10,interp=32)
converttorgb()
invert("G")
mergergb(showgreen,showred,showblue)
converttoyv12()
tweak(hue=90)
converttoyv12()
medianblur(0,CBlur,CBlur)
coloryuv(autowhite=true)
temporalsoften(last,TR,0,TT)
if(Speed > 0) {
Chroma1 = Last
P2c = c3 # Which source clip should we be using
r = P2c.F2Quiver(1,3,39,0,24,frad=16)
r1 = P2c.F2Quiver(1,3,47,0,24,frad=16)
g = P2c.F2Quiver(1,3,37,0,24,frad=16)
g1 = P2c.F2Quiver(1,3,85,0,24,frad=16)
b = P2c.F2Quiver(1,3,65,0,24,frad=16)
b1 = P2c.F2Quiver(1,3,59,0,24,frad=16)
x1 = merge(r,r1)
y1 = merge(P2c.invert(),merge(g,g1))
z1 = merge(P2c.invert(),merge(b,b1))
y2 = overlay(P2c,y1,mode="multiply")
z2 = overlay(P2c,z1,mode="multiply")
x = mt_makediff(P2c,x1,Chroma="-128").converttorgb() # Full range RGB
y = mt_makediff(P2c,y2,Chroma="-128").converttorgb()
z = mt_makediff(P2c,z2,Chroma="-128").converttorgb()
mergergb(x,y,z).ConvertToYV12 # RGB to YV12 TV Levels
mergechroma(P2c,ColorYUV(autowhite=true))
Last = (Sat>0.0) ? mergechroma(P2c,tweak(sat=7.5,interp=32),Sat) : Last
Last.Merge(Chroma1,0.5)
}
bilinearresize(c.width,c.height)
mergechroma(c,Last,Weight)
""")
Return Last
}
#AviSource("Doctor.avi")
AviSource("BabelColour.avi")
Crop(0,0,Width/4*4,Height/4*4).convertToYV12
Org=Last # Display Color
AMP=true
GrayScale
#Org=Last # Display GrayScale
A=CM_v100(0)
B=CM_v100(1)
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
}
MWilson
21st April 2016, 06:18
You'd be better off colorizing manually, because that's essentially what you're doing, except in an unnecessarily complicated way.
I may be wrong, but you are as well. Manual colorization of a program would take (in general) thousands of manually colorized frames.
StainlessS, I am working on making an F2Quiver version of cmx7mod. For the moment cmb is my go to. The second part of what you posted "CM_V100" was quickly deleted. The reason behind the deletion was that it did nothing.
FWIW, I'm trying my best :)
Edit: StainlessS, I mean no ill will, you have been nothing but kind :)
StainlessS
21st April 2016, 12:13
I mean no ill will
I know.
The reason behind the deletion was that it did nothing.
Yeh, but if you decide to go that way again, do that method, using already cropped/resized/grayscaled clips,
and dont be bothered about using GScript (an additional filter), that could be gotten rid of when it works better, if necessary.
Of course the Fluffy one is correct in saying the colors etc are totally fake but it is still worth pursuing for its novelty value.
(and as for coloring everything by hand, 'Not tonight Josephine').
vcmohan
21st April 2016, 14:02
@stainless
The F2Quiver parameters used are not proper. I found that due to a bug such values were allowed. I will upload corrected dll of FFTQuiver.
The calls specified above are
r = P2c.F2Quiver(1,3,39,0,24,frad=16)
r1 = P2c.F2Quiver(1,3,47,0,24,frad=16)
g = P2c.F2Quiver(1,3,37,0,24,frad=16)
g1 = P2c.F2Quiver(1,3,85,0,24,frad=16)
b = P2c.F2Quiver(1,3,65,0,24,frad=16)
b1 = P2c.F2Quiver(1,3,59,0,24,frad=16)
The second digit specifies band pass. The third digit should be lower freq of band and the 4 th value must be the higher freq of band. 4th value must be higher than 3rd. Due to a bug in checking parameters this was allowed to pass even though it should have been stopped.
Just replace F2Quiver with F2QTest and return each call separately to see the filter and see how the filter looks like. For each of those lines a filter with almost zero value is produced. Therefore the results that are obtained may be unpredictable random.
StainlessS
21st April 2016, 15:12
Yeh maybe I should have spotted that, but I dont bother looking at the FFT stuff, leave that to MWilson.
Dont know where I got this from, but included it in one of the scripts.
# Parameters in bunches of 5,
# 1) Symmetry. [1, Circular, 2. Horizontal, 3, Vertical, 4. Linear Fan, 5. Point].
# 2) Type. [1. low cut, 2. High cut, 3. Band Pass, 4, Band stop, 5. Notch].
# 3) Notch freq, [low freq of band, or X freq of point or angle1 for linear fan].
# 4) High freq of band, or angle2 for linear fan, or y freq of point.
# 5) Degree of Shaprness. 0 to 24. If 0 Gaussian filter otherwise Butterworth filter is designed.
Thank you for your attention vc.
EDIT: MWilson seems to have figured it out
Older code
r = P2c.F2Quiver(1,3,39,0,24,frad=16)
r1 = P2c.F2Quiver(1,3,47,0,24,frad=16)
g = P2c.F2Quiver(1,3,37,0,24,frad=16)
g1 = P2c.F2Quiver(1,3,85,0,24,frad=16)
b = P2c.F2Quiver(1,3,65,0,24,frad=16)
b1 = P2c.F2Quiver(1,3,59,0,24,frad=16)
Newer code
g=c3.F2Quiver(1,3,96, 250,0,frad=16)
b=c3.F2Quiver(1,3,110,250,0,frad=16)
r=c3.F2Quiver(1,3,76, 250,0,frad=16)
EDIT: I got the Parameters in 1st code block from current FFTQuiver docs, however was a little confused as I seem to have
an old version docs in my plugin docs folder (using strings as args).
StainlessS
22nd April 2016, 23:58
If Fisick is watching, would be lovely if Access Violatons could be cured. (Defreq)
EDIT: I have looked at it, I'm not clever enough.
vcmohan
23rd April 2016, 12:31
I have stopped updating 2.5 version plugins and their documents. You might have got the old version.
StainlessS
23rd April 2016, 12:37
Yes, I have both versions v2.5 and v2.6, was somehow though reading wrong docs containing this
The valid filter names are:
gp0, gp1, gp2, gp3, gp4, gp5, gp6, gp7, gp8, gp9
gcb, gcn, gch, gcl, gll, glh,glb0,glb1,..glb9, gln0,gln1,..gln9
bp0, bp1, bp2, bp3, bp4, bp5, bp6, bp7, bp8, bp9
bcb, bcn, bch, bcl, bll, blh,blb0,blb1,..blb9, bln0,bln1,..bln9
bvh, bvl, gvh, gvl, bhh, ghh, ghl, bhl
Got the correct docs now.
StainlessS
24th April 2016, 00:03
Here some extra info on F2Quiver, deduced from source code.
Parmameters in bunches of 5, (max 12 sets)
1) Symmetry. [1, Circular, 2. Horizontal, 3, Vertical, 4. Linear Fan, 5. Point].
2) Type. [1. low cut, 2. High cut, 3. Band Pass, 4, Band stop, 5. Notch].
3) Notch freq, [low freq of band, or X freq of point or angle1 for linear fan]. 0 -> 127 or if angle then 0->89 OR 92 ->177
4) High freq of band, or angle2 for linear fan, or y freq of point. (angle must be higher 1 to 15 higher than low angle)
5) Degree of Shaprness. 0 to 24. If 0 Gaussian filter otherwise Butterworth filter is designed.
Frad Default 32, 16 to 128 in steps of 4 and less than 1/8 of frame dimension.
Symmetry:- 1, Circular, 2. Horizontal, 3, Vertical
Type:- 1. low cut, 2. High cut
Parm 3, LowFreq:- 0 -> 127
Parm 4, HighFreq:- NOT USED.
Type:- 3. Band Pass, 4, Band stop, 5. Notch
Parm 3, LowFreq:- 0 -> 127
Parm 4, HighFreq:- LowFreq+1 -> ???
Symmetry:- 4. Linear Fan
Type:- NOT USED [EDIT: But has to be 1->5].
Parm 3, Angle1:- 0 -> 89 and 92 -> 177
Parm 4, Angle2:- Greater than Angle1 AND 0 -> 89 and 92 -> 177 (NOTE, Angle2-Angle1 range 1 -> 15 ONLY)
Symmetry:- 5. Point
Type:- NOT USED. [EDIT: But has to be 1->5].
Parm 3, XFreq:- -127 -> 127
Parm 4, YFreq:- -127 -> 127
I'm not sure that arg parsing in F2Quiver is correct (in fact vcMohan has said as much in post #123), above is deduced from source as it currently stands,
I think that the 127 and -127 should perhaps be 128 and -128, and maybe 177 and -177 should be 178 and -178 (when source corrected).
vcmohan
24th April 2016, 14:13
Parameter checking for filter type 3 (band pass) has been corrected.
I have limited all frequencies to 127 as it is considered most safe , and normally adhered to in seismic data processing. This restriction can be relaxed up to 256. if so desired I can make the required changes. Specifying a value for 1 to 5 for type for all filters is to make my coding simpler. Also it will ensure that while scripting one does not forget which integer value one is specifying.
StainlessS
24th April 2016, 17:03
I'm not sure that arg parsing in F2Quiver is correct (in fact vcMohan has said as much in post #123), above is deduced from source as it currently stands,
I think that the 127 and -127 should perhaps be 128 and -128, and maybe 177 and -177 should be 178 and -178 (when source corrected).
The 127, -127, and 177, -177, values above are correct, but error messages give valid range as eg 0 -> 128 (when was eg 128 that caused the error), this is reason I was not sure about what the valid values should be.
PM sent to vcMohan, will no doubt be fixed in due time.
I needed to scan through all possible valid modes of F2Quiver, and so needed to know exactly what is possible without errors.
EDIT: @vc, I'm quite happy with 127.
StainlessS
27th April 2016, 19:21
Here slight mod of cm() in first post.
Function cm(clip v, float "Weight", int "CBlur",Bool "TS", int "TR", int "TT", Bool "UpSz", Bool "ALevel",
\ Int "p3R",Int "p3G",Int "p3B") {# (c) MWilson, http://forum.doom9.org/showthread.php?t=173364
###Source Must Be Progressive
UpSz= Default (UpSz,False)
ALevel=Default (ALevel,False)
CBlur=Default (CBlur,18) ### Very dependent on source
Weight=Default (Weight,0.75)
TS=Default (TS,True)
TT=Default (TT,30)
TR=Default (TR,10)
p3R=Default(p3R,76)
p3G=Default(p3G,96)
p3B=Default(p3B,110)
v=v.converttoyv12().greyscale()
c=(ALevel==True) ? v.autolevels(12) : v
cpad=(UpSz==True) ? c.sincresize(c.Width*2,c.Height*2) : c
r=cpad.F2Quiver(1,3,p3R,127,0,frad=16)
g=cpad.F2Quiver(1,3,p3G,127,0,frad=16)
b=cpad.F2Quiver(1,3,p3B,127,0,frad=16)
mergergb(r,g,b)
autolevels(12,autogamma=true)
converttoyv12()
coloryuv(autowhite=true)
tweak(sat=10,interp=32)
tweak(sat=10,interp=32)
converttorgb()
invert("G")
mergergb(showgreen,showred,showblue) # ??? is this intended (swap red and green) ???
converttoyv12()
tweak(hue=90)
medianblur(0,CBlur,CBlur)
bilinearresize(width(cpad),height(cpad))
coloryuv(autowhite=true)
(TS==True) ? temporalsoften(last,TR,0,TT) : last
mergechroma(cpad,last,Weight)
}
Only difference is marked in BLUE. 250 (originally) is illegal value in F2Quiver (not rejected by arg checker), max allowed
is 127 ((NYQUIST/2)-1).
I see no real (if any) difference in results. Next version F2Quiver will reject those args of 128 or more.
EDIT: Gold not quite as colourful as previous but still pretty good.
Seems to be better than other scripts, even cmx7Mod.
https://s20.postimg.cc/tk325zw59/SE_BW0_zpsxea0nm2t.png (https://postimg.cc/image/yiqkkizy1/) https://s20.postimg.cc/gtytswo71/Shirley_cm_Mod0_zpsxs9fi0gi.png (https://postimg.cc/image/lsmc7frzt/)
EDIT: Damn, green beer, must be St Patricks day again :)
https://s20.postimg.cc/gihdg57r1/Ice_Cold_BW0_zpseyufhlyb.png (https://postimg.cc/image/ltwa0uttl/) https://s20.postimg.cc/8e99belbx/Green_Beer0_zpsynph1p9v.png (https://postimg.cc/image/gwipfqruh/)
EDIT: Exposed cm script above, args to F2Quiver as p3R, p3G and p3B, 0-> 126.
StainlessS
27th April 2016, 21:02
Script above, added args to cm(), Int p3R, p3G, p3B, 0 -> 126.
Here Test script for cm(), throws random args at it. (blatantly stolen from RaffRiff42 script by PM).
Avisource("IceColdInAlex_VCD.avi").convertToYV12.Trim(176155,176155)
Loop(1000,0,0)
C=Last
global g_logpath = "logfile.txt"
Global g_p3R = Rand(127) # Globals For Random shift, 0->126
Global g_p3G = Rand(127)
Global g_p3B = Rand(127)
RT_WriteFile(g_logpath, "frameno\targs",Append=False)
ScriptClip(C, "cm_Test()").ShowFrameNumber(size=16, x=16, y=C.Height-24)
ConvertToRGB32
##################################
## cm: fuzz test input args
#
function cm_Test(clip C) {
C
## random inputs
Global g_p3R = g_p3G
Global g_p3G = g_p3B
Global g_p3B = Rand(127) # 0 -> 126 : Shift random numbers, produces better 'randomized' numbers from single randon number generator,
# Chaos Theory ([EDIT: multi-dimensional random numbers] dont really matter).
global g_args=RT_String("p3R=%03d, p3G=%03d, p3B=%03d",g_p3R,g_p3G,g_p3B)
RT_DebugF("%d] %s", current_frame, g_args, name="cm: ")
RT_WriteFile(g_logpath,"%d]\t%s",current_frame,g_args,Append=True)
return Eval("cm("+g_args+")").Subtitle(g_args, size=16)
}
Function cm(clip v, float "Weight", int "CBlur",Bool "TS", int "TR", int "TT", Bool "UpSz", Bool "ALevel",
\ Int "p3R",Int "p3G",Int "p3B") {# (c) MWilson, http://forum.doom9.org/showthread.php?t=173364
###Source Must Be Progressive
UpSz= Default (UpSz,False)
ALevel=Default (ALevel,False)
CBlur=Default (CBlur,18) ### Very dependent on source
Weight=Default (Weight,.75)
TS=Default (TS,True)
TT=Default (TT,30)
TR=Default (TR,10)
p3R=Default(p3R,76)
p3G=Default(p3G,96)
p3B=Default(p3B,110)
v=v.converttoyv12().greyscale()
c=(ALevel==True) ? v.autolevels(12) : v
cpad=(UpSz==True) ? c.sincresize(c.Width*2,c.Height*2) : c
r=cpad.F2Quiver(1,3,p3R,127,0,frad=16)
g=cpad.F2Quiver(1,3,p3G,127,0,frad=16)
b=cpad.F2Quiver(1,3,p3B,127,0,frad=16)
mergergb(r,g,b)
autolevels(12,autogamma=true)
converttoyv12()
coloryuv(autowhite=true)
tweak(sat=10,interp=32)
tweak(sat=10,interp=32)
converttorgb()
invert("G")
mergergb(showgreen,showred,showblue) # ??? is this intended (swap red and green) ???
converttoyv12()
tweak(hue=90)
medianblur(0,CBlur,CBlur)
bilinearresize(width(cpad),height(cpad))
coloryuv(autowhite=true)
(TS==True) ? temporalsoften(last,TR,0,TT) : last
mergechroma(cpad,last,Weight)
}
EDIT: MWilson, can you check out the queried Red/Green swap over, Green arg pG3 seems to control redness anomalies.
vcmohan
28th April 2016, 05:55
Even though I am perplexed at the use of freq domain for automatic colorization, I hold my self since it appears that some encouraging results are obtained. I find that homomorphic option of F2Quiver was not tried. May be it may work.
StainlessS
28th April 2016, 16:31
I hold my self since it appears that some encouasing results are obtained.
Yeh, if it 'sort of works' dont knock it (we humans really excel at believing in stuff that cannot be proved at all).
It seems that what it is pretty good at is applying reasonably stable colorization temporally (you dont get completely different
colors at every frame).
I did try doing similar to U and V instead of R, G and B. I'm figuring that it is pretty much impossible to get any kind of blue
out of RGB method due to Luma relation to blue (eg NTSC 30% R + 59% G + 11% B [EDIT: oops got R and G backwards]).
I tried using two freq ranges [EDIT: Band Pass] for each of U and V, subtracting result from Y for one, and Y from result for the other. Then
just used blend (merge or overlay) to mix together, perhaps some other Overlay mode would work. Anyway, did not work too well
but maybe the only way that some blue could be magicked into existence. I shall probably try again with that method, but dont really
have much idea if it could work or what method should be used to mix subtracted results together [EDIT: they tend to cancel each other out].
I'll also have a go with homomorphic option which I dont think did anything for the few times I tried it.
EDIT: I shall perhaps post a U + V script, but not today.
Steve Zodiac
11th May 2016, 02:45
I have been using colorisation scripts for some weeks now and have had the following experiences & observations
1/ The process seems best for non natural light subjects, esp science fiction, as this makes non realistic colouring more acceptable ie this is a clip from Metropolis I did https://www.facebook.com/photo.php?fbid=10154018700977936&set=a.10154018700902936.1073741906.539397935&type=3&theater
https://www.facebook.com/photo.php?fbid=10154018722632936&set=a.10154018700902936.1073741906.539397935&type=3&theater
2/ The process works best with small size files/short length clips, when I did 1/2 hour or longer tv eps & feature films I had a lot of trouble with system crashing which in turn badly affected my computer, I've had to repair my startup 3 times. I also had trouble with long clips being out of sound synch, though I was able to fix this up in my video editor.
3/ The best results are obtained with the best B/W prints. I tried a Space Patrol kinescope which was a bit high contrast and it came out far too yellow on skin tone, but a better kinescope gave a much better result
4/ Reds seem to be coming out best, objects such as costumes, fire extinquishers, signs and props which I know to be red are coming out that way
StainlessS
27th May 2016, 17:44
Steve Zodiac,
I had a lot of trouble with system crashing which in turn badly affected my computer, I've had to repair my startup 3 times.
Which script (in particular which FFT function ie F2Quiver or DeFreq) was used ?
Steve Zodiac
29th May 2016, 10:31
It used this script, which has defreq. A friend uses it without problems
function cmfull(clip v2)
{
#v2=v2.greyscale()
width=v2.width/2
height=v2.height/2
v=v2.sincresize(256,256).addborders(width,height,width,height)
g=v.defreq(fy=0,fx=59,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)
r=v.defreq(fy=0,fx=39,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)
b1=v.defreq(fy=0,fx=59,sharp=100,dx=50,dy=50,cutx=0,cuty=0,fx2=100,fy2=0)
r1=v.defreq(fy=0,fx=47,sharp=100,dx=50,dy=50,cutx=0,cuty=0)
x1=merge(r1,r)
y1=merge(g,g1)
z1=merge(b1,b1)
z2=overlay(v,z1,0,0,mode="multiply")
y2=overlay(v,y1,mode="multiply")
x=mt_makediff(v,x1).converttorgb().crop(width,height,-width,-height)
y=mt_makediff(v,y2).converttorgb().crop(width,height,-width,-height)
z=mt_makediff(v,z2).converttorgb().crop(width,height,-width,-height)
mergergb(x,y,z)
lanczos4resize(width(v2),height(v2))
converttoyv12()
ColorYUV(autowhite=true)
tweak(sat=1)
ax=last.sincresize(width(v2),height(v2))
bx=mergechroma(v2,ax,1)
coloryuv(bx,autowhite=true)
mergechroma(merge(last,last.invert("YUV")),last,1)
mergechroma(v2,last,1)
return last
}
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
}
DirectShowSource("C:\Colorise\Met7.mpg")
cmfullshift(last)
StainlessS
3rd June 2016, 19:04
It used this script, which has defreq. A friend uses it without problems
Thanks for the report. I also have DeFreq() problem crashes.
@VcMohan,
Hi, It is my understanding that the FFT stuff is "Wrap Around", ie top left corner of image will also be affected by the contents at the other three corners.
Applying traditional padding (where padded is mirror image of frame edges) does not work optimally, I have therefore had a go at doing a better FFT pad function to attempt to reduce color flaring exhibited in eg post #131, bottom right image, top left corner - red flare.
Here is my attempt (dll + source ~26KB):- EDIT: LINK REMOVED
[EDIT: YV12 and Y8, v2.58 plugin (Y8 in v2.6 only, of course)]
#include <windows.h>
#include "avisynth.h"
class PadFFT : public GenericVideoFilter {
const int pad;
public:
PadFFT(PClip _child,int _pad, IScriptEnvironment* env);
~PadFFT(){};
PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env);
};
PadFFT::PadFFT(PClip _child, int _pad, IScriptEnvironment* env) : GenericVideoFilter(_child), pad(_pad) {
if (!vi.IsPlanar()) env->ThrowError("PadFFT: Requires Planar");
if((vi.pixel_type!=0xA0000008 && vi.pixel_type!=0xE0000000)) // not YV12 or Y8
env->ThrowError("PadFFT: ColorSpace unsupported in PadFFT, YV12 and Y8 Only\n");
if(pad < 0 || pad > 32 || (pad&0x01)) env->ThrowError("PadFFT: Pad 2 -> 32, even ONLY");
vi.width = vi.width + 2*pad;
vi.height = vi.height + 2*pad;
}
PVideoFrame __stdcall PadFFT::GetFrame(int n, IScriptEnvironment* env) {
n = (n<0) ? 0 : (n>= vi.num_frames) ? vi.num_frames-1 : n;
PVideoFrame src = child->GetFrame(n, env);
const VideoInfo& ivi= child->GetVideoInfo();
PVideoFrame dst = env->NewVideoFrame(vi);
const BYTE *srcp = src->GetReadPtr(PLANAR_Y);
BYTE *dstp = dst->GetWritePtr(PLANAR_Y);
const int spitch = src->GetPitch(PLANAR_Y);
const int dpitch = dst->GetPitch(PLANAR_Y);
const int swid = ivi.width;
const int shit = ivi.height;
const BYTE *srp;
BYTE *drp;
int x,y;
// Copy over original inner frame
srp = srcp;
drp = dstp + (pad * dpitch) + pad;
for(y=shit ; --y>=0 ; ) {
for(x=swid ; --x>=0 ; )
drp[x] = srp[x];
srp += spitch;
drp += dpitch;
}
const int pmax = (2*pad) + 1;
// TOP and BOT MID section
BYTE *sT,*dT;
BYTE *sB,*dB;
sT = dstp + (pad * dpitch) + pad;
sB = dstp + (vi.height-1-pad)*dpitch + pad;
dT = sT - dpitch;
dB = sB + dpitch;
for(y=0; y<pad ; ++y) {
const int mt = 2*pad - y;
const int mb = pmax - mt;
for(x=swid; --x>=0 ; ) {
const int T1 = sT[x];
const int B1 = sB[x];
dT[x] = ((T1*mt + B1*mb) *2 + pmax) / (2*pmax);
dB[x] = ((B1*mt + T1*mb) *2 + pmax) / (2*pmax);
}
dT -= dpitch;
dB += dpitch;
}
// LFT and RGT MID section
BYTE *sL,*dL;
BYTE *sR,*dR;
sL = dstp + (pad * dpitch) + pad;
sR = dstp + (pad * dpitch) + vi.width-1-pad;
for(y=shit; --y>=0 ; ) {
dL = sL - 1;
dR = sR + 1;
for(x=0; x<pad ; ++x) {
const int ml = 2*pad - x;
const int mr = pmax - ml;
const int L1 = sL[0];
const int R1 = sR[0];
dL[-x] = ((L1*ml + R1*mr) *2 + pmax) / (2*pmax);
dR[x] = ((R1*ml + L1*mr) *2 + pmax) / (2*pmax);
}
sL += dpitch;
sR += dpitch;
}
// CORNERS
BYTE * TL = dstp + (pad * dpitch) + pad;
BYTE * TR = dstp + (pad * dpitch) + vi.width-1-pad;
BYTE * BL = dstp + (vi.height-1-pad)*dpitch + pad;
BYTE * BR = dstp + (vi.height-1-pad)*dpitch + vi.width-1-pad;
for(y=0 ; y < pad ; ++y) {
const int my1 = (2*pad-y);
const int my2 = pmax-my1;
for(x=0 ; x <pad ; ++x) {
const BYTE BRy = BR[(y+1)*dpitch];
const BYTE BRx = BR[x+1];
const BYTE BLy = BL[(y+1)*dpitch];
const BYTE BLx = BL[-(x+1)];
const BYTE TRy = TR[-((y+1)*dpitch)];
const BYTE TRx = TR[x+1];
const BYTE TLy = TL[-((y+1)*dpitch)];
const BYTE TLx = TL[-(x+1)];
const int mx1 = (2*pad-x);
const int mx2 = pmax-mx1;
BR[ (y+1)*dpitch +(x+1)] = ((BRy*mx1 + BLy*mx2 + BRx*my1 + TRx*my2) *2 + (2*pmax)) / (4*pmax);
BL[ (y+1)*dpitch -(x+1)] = ((BLy*mx1 + BRy*mx2 + BLx*my1 + TLx*my2) *2 + (2*pmax)) / (4*pmax);
TR[-(y+1)*dpitch +(x+1)] = ((TRy*mx1 + TLy*mx2 + TRx*my1 + BRx*my2) *2 + (2*pmax)) / (4*pmax);
TL[-(y+1)*dpitch -(x+1)] = ((TLy*mx1 + TRy*mx2 + TLx*my1 + BLx*my2) *2 + (2*pmax)) / (4*pmax);
}
}
const int RowSize = dst->GetRowSize(PLANAR_U);
if(RowSize > 0) { // NOT Y8 : Chroma GreyScale
const int upitch = dst->GetPitch(PLANAR_U);
const int uhit = dst->GetHeight(PLANAR_U);
BYTE *urp = dst->GetWritePtr(PLANAR_U);
BYTE *vrp = dst->GetWritePtr(PLANAR_V);
for(y=uhit ; --y>=0 ; ) {
for(x=RowSize ; --x>=0 ; ) {
urp[x] = 128;
vrp[x] = 128;
}
urp += upitch;
vrp += upitch;
}
}
return dst;
}
AVSValue __cdecl Create_PadFFT(AVSValue args, void* user_data, IScriptEnvironment* env) {
PClip child = args[0].AsClip();
int pad = args[1].AsInt(4);
return (pad != 0)
? new PadFFT(child,pad,env)
: child; // pad == 0, return original clip.
}
extern "C" __declspec(dllexport) const char* __stdcall AvisynthPluginInit2(IScriptEnvironment* env) {
env->AddFunction("PadFFT","c[Pad]i", Create_PadFFT, 0);
return "`PadFFT' PadFFT plugin";
// A freeform name of the plugin.
}
This is result of PadFFT(32) # pad 32 pixels at each edge
https://s20.postimg.cc/58onl72pp/Alex-_No_Shift_zpsrrzlyia4.jpg (https://postimg.cc/image/i02trpchl/)
And shift into middle
https://s20.postimg.cc/v5ibxt6d9/Alex-_Shift_zpskcueofkw.jpg (https://postimg.cc/image/bnnohv9fd/)
Should the arg to pad be same as F2Quiver frad arg ?
Also, is it necessary to do some kind of moving window average on the padded sections ? (would it affect F2Quiver)
Thank you in advance, and if you have any recommendations I'de be glad to hear them.
Script to shift the padding into middle
Avisource("IceColdInAlex_VCD.avi").convertToYV12.Trim(176155,176155)
Crop(0,0,Width/4*4,Height/4*4).convertToYV12.GrayScale
PadFFT(32)
StackVertical(Crop(0,Height/2,0,0),Crop(0,0,0,Height/2))
StackHorizontal(Crop(Width/2,0,0,0),Crop(0,0,Width/2,0))
return Last
EDIT: In source cpp, this is sort of equiv
dT[x] = ((T1*mt + B1*mb) *2 + pmax) / (2*pmax);
To this
dT[x] = int((T1*mt + B1*mb) / (double)pmax + 0.5);
vcmohan
4th June 2016, 13:30
Hi, It is my understanding that the FFT stuff is "Wrap Around", ie top left corner of image will also be affected by the contents at the other three corners.
Applying traditional padding (where padded is mirror image of frame edges) does not work optimally,
traditional padding is just adding that many number of zeroes.Since we remove this part in our result, whatever aliasing happens, it gets removed.
Should the arg to pad be same as F2Quiver frad arg ?
Since that length of filter gets convolved it also to be ensured does not alias back. So the zero padding length is twice the filter rad at least.
Also, is it necessary to do some kind of moving window average on the padded sections ? (would it affect F2Quiver)
No. Only zeroes are to be in padded section. Padding at end of each horizontal and each vertical line is the correct way. No averaging is to be done.
The frequency spectrum which is displayed normally is obtained by a centering ( -1 **n) so that it can be understood. Actually the spectrum is around all 4 corners and difficult to make sense.
The flaring what you see is probably due to the improper padding.
StainlessS
4th June 2016, 19:45
Thank you VC, looks like I got myself involved in a little folly.
If I understand correctly, then AddBorders(frad*2,frad*2,frad*2,frad*2, $000000) is all that is required.
EDIT: ie the 'wrap around' padding is total frad*4.
and difficult to make sense
Yeh, I get that part :)
Again thanks for your answer, think I'll give it a go now.
EDIT: Damn, I think Addborders(... , color=$000000) would set border to YUV $108080, so we need
a plug to set $008080 for YV12 and Y8. Seems there is no way to use Addborders with PC levels YUV,
color is always RGB and YUV CCIR-601 color (luma=16).
StainlessS
4th June 2016, 22:09
PadFFT v0.02, because of AddBorders() stuff in EDIT above:- http://www.mediafire.com/download/2b4nr321osk2chm/PaddFFT_dll_v0.02_20160604.zip
PadFFT cpp
#include <windows.h>
#include "avisynth.h"
class PadFFT : public GenericVideoFilter {
const int pad;
const int padval;
public:
PadFFT(PClip _child,int _pad,int _padval, IScriptEnvironment* env);
~PadFFT(){};
PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env);
};
PadFFT::PadFFT(PClip _child, int _pad, int _padval, IScriptEnvironment* env) : GenericVideoFilter(_child), pad(_pad), padval(_padval) {
if (!vi.IsPlanar()) env->ThrowError("PadFFT: Requires Planar");
if((vi.pixel_type!=0xA0000008 && vi.pixel_type!=0xE0000000)) // not YV12 or Y8
env->ThrowError("PadFFT: ColorSpace unsupported in PadFFT, YV12 and Y8 Only\n");
if(pad < 0 || pad > 64 || (pad&0x01)) env->ThrowError("PadFFT: Pad 2 -> 64, even ONLY");
if(padval < 0 || padval > 255) env->ThrowError("PadFFT: PadVal 0 -> 255 ONLY");
vi.width = vi.width + 2*pad;
vi.height = vi.height + 2*pad;
}
PVideoFrame __stdcall PadFFT::GetFrame(int n, IScriptEnvironment* env) {
n = (n<0) ? 0 : (n>= vi.num_frames) ? vi.num_frames-1 : n;
PVideoFrame src = child->GetFrame(n, env);
const BYTE *srcp = src->GetReadPtr(PLANAR_Y);
const int spitch = src->GetPitch(PLANAR_Y);
PVideoFrame dst = env->NewVideoFrame(vi);
BYTE *dstp = dst->GetWritePtr(PLANAR_Y);
const int dpitch = dst->GetPitch(PLANAR_Y);
const int dwid = vi.width;
const int dhit = vi.height;
const VideoInfo& ivi= child->GetVideoInfo();
const int swid = ivi.width;
const int shit = ivi.height;
const int val = padval;
int x,y;
for(y=pad ; --y>=0 ; ) {
for(x=dwid ; --x>=0 ; )
dstp[x] = val;
dstp += dpitch;
}
for(y=shit ; --y>=0 ; ) {
BYTE *drp = dstp + pad + swid;
for(x=pad ; --x>=0 ; )
drp[x] = val;
drp -= swid;
for(x=swid ; --x>=0 ; )
drp[x] = srcp[x];
for(x=pad ; --x>=0 ; )
dstp[x] = val;
dstp += dpitch;
srcp += spitch;
}
for(y=pad ; --y>=0 ; ) {
for(x=dwid ; --x>=0 ; )
dstp[x] = val;
dstp += dpitch;
}
const int RowSize = dst->GetRowSize(PLANAR_U);
if(RowSize > 0) { // NOT Y8 : Chroma GreyScale
const int upitch = dst->GetPitch(PLANAR_U);
const int uhit = dst->GetHeight(PLANAR_U);
BYTE *urp = dst->GetWritePtr(PLANAR_U);
BYTE *vrp = dst->GetWritePtr(PLANAR_V);
for(y=uhit ; --y>=0 ; ) {
for(x=RowSize ; --x>=0 ; ) {
urp[x] = 128;
vrp[x] = 128;
}
urp += upitch;
vrp += upitch;
}
}
return dst;
}
AVSValue __cdecl Create_PadFFT(AVSValue args, void* user_data, IScriptEnvironment* env) {
PClip child = args[0].AsClip();
int pad = args[1].AsInt(8);
int padval = args[2].AsInt(0);
return (pad != 0)
? new PadFFT(child,pad,padval,env)
: child; // pad == 0, return original clip.
}
extern "C" __declspec(dllexport) const char* __stdcall AvisynthPluginInit2(IScriptEnvironment* env) {
env->AddFunction("PadFFT","c[Pad]i[PadVal]i", Create_PadFFT, 0);
return "`PadFFT' PadFFT plugin";
// A freeform name of the plugin.
}
Changed pad arg range 2 -> 64 in even steps.
Script to demo (not as any yet posted)
Function cm(clip c, float "Weight", int "CBlur",Bool "TS", int "TR", int "TT", Bool "UpSz", Bool "ALevel",
\ Int "p3R",Int "p3G",Int "p3B",Int "Pad") {# (c) MWilson, http://forum.doom9.org/showthread.php?t=173364
###Source Must Be Progressive
UpSz= Default (UpSz,False)
ALevel=Default (ALevel,False)
CBlur=Default (CBlur,18)
Weight=Default (Weight,0.75)
TS=Default (TS,True)
TT=Default (TT,30)
TR=Default (TR,10)
p3R=Default(p3R,96)
p3G=Default(p3G,76)
p3B=Default(p3B,110)
Pad = Default(Pad,0)
c=c.converttoyv12().greyscale()
c2=(ALevel==True) ? c.autolevels(12) : c
c3=(UpSz==True) ? c2.sincresize(c2.Width*2,c2.Height*2) : c2
cpad=c3.PadFFT(PAD)
r=cpad.F2Quiver(1,3,p3R,127,0,frad=16)
g=cpad.F2Quiver(1,3,p3G,127,0,frad=16)
b=cpad.F2Quiver(1,3,p3B,127,0,frad=16)
mergergb(r,g,b)
autolevels(12,autogamma=true)
converttoyv12()
coloryuv(autowhite=true)
tweak(sat=10,interp=32)
tweak(sat=10,interp=32)
converttorgb()
invert("R")
#mergergb(showgreen,showred,showblue) # ??? is this intended (swap red and green) ???
converttoyv12()
tweak(hue=90)
medianblur(0,CBlur,CBlur)
Crop(PAD,PAD,-PAD,-PAD)
bilinearresize(width(c),height(c))
coloryuv(autowhite=true)
(TS==True) ? temporalsoften(last,TR,0,TT) : last
mergechroma(c,last,Weight)
}
Avisource("IceColdInAlex_VCD.avi").convertToYV12.Trim(176155,176155)
Crop(0,0,Width/4*4,Height/4*4).convertToYV12
A=CM(Pad=0).RT_Subtitle("frad=16:Pad=0",align=5)
B=CM(pad=8).RT_Subtitle("frad=16:Pad=8",align=5)
C=CM(pad=16).RT_Subtitle("frad=16:Pad=16",align=5)
D=CM(pad=32).RT_Subtitle("frad=16:Pad=32",align=5)
StackVertical(StackHorizontal(A,B),StackHorizontal(C,D))
Return Last
Gives this
https://s20.postimg.cc/4lpqvo5tp/Pad_Test0_zpsdhsxpyiz.jpg (https://postimg.cc/image/is5hqwgop/)
Looks to me like best padding is Frad / 2, so that total wrap around padding = Frad.
With Pad=frad*2, we get lots of blue (well people been complaining bout lack of blue, now we got some :) ).
EDIT: I think I'll mod to PadFFT(Int "Pad"=8,Int "PadVal"=0), where PadVal added so can set whatever value you like,
might be useful for other things where AddBorders is un-obliging.
EDIT: Change zip link above to v0.02, the PadVal arg added..
vcmohan
5th June 2016, 12:54
EDIT: ie the 'wrap around' padding is total frad*4.
.
In addition to the requirement of padding by 2 * frad, it is to be ensured that the resulting frame width and heights are multiples of 2, 3 , 5, 7, 9, 11 for FFTW3.dll speed considerations. All this work is done internally by F2Quiver. Only thing the user is to ensure is frame width and heights are even numbers.( YUY or YV standards also requires this criterion to be met.)
StainlessS
5th June 2016, 13:57
Thanks VC.
Presumably, 3,5,7,9,11, are something to do with harmonics.
Are there any caveats regarding PC/TV levels, (does F2Quiver differentiate).
I tried setting PadVal=16 (and 64, 128 255 etc), and it does make some difference (even though it would seem that frequencies in
the padded regions should be 0, ie no differences [except for initial transition at edge->pad]).
EDIT: Where Pad=Frad*2 and PadVal=255, the blue edge turns a greenish. Where PadVal=128, even more greenish.
Even though padding should logically be frad*2, (wraparound frad*4), for this peculiar application seems frame/2 is better choice,
although that may perhaps result in grayscale edges (have not as yet played with other clips/images).
StainlessS
5th June 2016, 14:47
Having relocated the removal of padding to just after F2Quiver (and MergeRGB), the amount of padding makes pretty much no visible difference.
It would seem that autolevels and autowhite were responsible for the differences, including the weird blue border (Doh).
Function cm(clip c, float "Weight", int "CBlur",Bool "TS", int "TR", int "TT", Bool "UpSz", Bool "ALevel",
\ Int "p3R",Int "p3G",Int "p3B",Int "Pad",Int "PadVal") {# (c) MWilson, http://forum.doom9.org/showthread.php?t=173364
UpSz= Default (UpSz,False)
ALevel=Default (ALevel,False)
CBlur=Default (CBlur,18)
Weight=Default (Weight,0.75)
TS=Default (TS,True)
TT=Default (TT,30)
TR=Default (TR,10)
p3R=Default(p3R,96)
p3G=Default(p3G,76)
p3B=Default(p3B,110)
Pad = Default(Pad,0)
PadVal = Default(PadVal,0)
c=c.converttoyv12().greyscale()
c2=(ALevel==True) ? c.autolevels(12) : c
c3=(UpSz==True) ? c2.sincresize(c2.Width*2,c2.Height*2) : c2
cpad=c3.PadFFT(PAD,PadVal)
FRAD = 16
r=cpad.F2Quiver(1,3,p3R,127,0,frad=FRAD)
g=cpad.F2Quiver(1,3,p3G,127,0,frad=FRAD)
b=cpad.F2Quiver(1,3,p3B,127,0,frad=FRAD)
mergergb(r,g,b)
Crop(PAD,PAD,-PAD,-PAD)
autolevels(12,autogamma=true)
converttoyv12()
coloryuv(autowhite=true)
tweak(sat=10,interp=32)
tweak(sat=10,interp=32)
converttorgb()
invert("R")
converttoyv12()
tweak(hue=90)
medianblur(0,CBlur,CBlur)
bilinearresize(width(c),height(c))
coloryuv(autowhite=true)
(TS==True) ? temporalsoften(last,TR,0,TT) : last
mergechroma(c,last,Weight)
}
#Imagesource("ShirleyEaton.jpg",end=0) crop(0,0,Width/2*2,Height/2*2).convertToYV12.BilinearResize(400,272)
#Imagesource("DQ-Tools_Color.BMP",end=0).convertToYV12
#Imagesource("JP_Test_Color.BMP",end=0).convertToYV12
#Imagesource("harold-lloyd.jpg",end=0) crop(0,0,Width/2*2,Height/2*2).convertToYV12
#Imagesource("Original Football.jpg",end=0).convertToYV12
#Avisource("Doctor.avi").convertToYV12
#Avisource("Test1.avi").convertToYV12
Avisource("IceColdInAlex_VCD.avi").convertToYV12.Trim(176155,176155)
#AviSource("BabelColour.avi")
#AviSource("JurassicPark.avi").RoboCrop(Wmod=4,HMod=4,Laced=False).Trim(19109,22086).Trim(600,0)
Crop(0,0,Width/4*4,Height/4*4).convertToYV12
PadVal=0
A=CM(Pad=0, PadVal=PadVal).RT_Subtitle("frad=16:Pad=0:PadVal=%d",PadVal,align=5)
B=CM(pad=8, PadVal=PadVal).RT_Subtitle("frad=16:Pad=8;PadVal=%d",PadVal,align=5)
C=CM(pad=16,PadVal=PadVal).RT_Subtitle("frad=16:Pad=16:PadVal=%d",PadVal,align=5)
D=CM(pad=32,PadVal=PadVal).RT_Subtitle("frad=16:Pad=32:PadVal=%d",PadVal,align=5)
StackVertical(StackHorizontal(A,B),StackHorizontal(C,D))
return Last
We are still stuck with the red 'flare', but it is not the wrap around that is responsible.
vcmohan
9th June 2016, 13:18
Thanks VC.
Presumably, 3,5,7,9,11, are something to do with harmonics.
No. These are the least multiplication factors. The size of width or height must have factors of 2 and or 3 and or 5 and or 7 so on. This facilitates FFTW to set up its internal calculation efficiently. Any large prime can also be used but that will slow down enormously (I never tried).
Are there any caveats regarding PC/TV levels, (does F2Quiver differentiate).
. No. Only thing is internally when converting back result to integers I am using 0 to 256 range.
StainlessS
9th June 2016, 15:33
Thanks VC,
internally when converting back result to integers I am using 0 to 256 range.
surely 0-255 (typo I assume).
Anyways, just been playing with the defreq version of Cmx7Mod (which some may prefer resultant colors), and for some reason suspected that Measure arg (unused in any version so far) might affect the crashing. So, after mod and 3 or 4 dozen attempts to crash script, was un-successful, so we seem to have found a fix for the crashing.
@ Steve Zodiac, can you try with supplied below (or mod to your favorite version [just add the MEASURE=False, and ',measure=MEASURE' text to Defreq calls])
Do tell if it fixes the probs that you were having.
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
MEASURE=False # Fix crashes
r = Padc.defreq(fy=0,fx=39,sharp=100,dx=50,dy=50,cutx=0,cuty=0,Measure=MEASURE).Crop(Pad,Pad,-Pad,-Pad)
r1 = Padc.defreq(fy=0,fx=47,sharp=100,dx=50,dy=50,cutx=0,cuty=0,Measure=MEASURE).Crop(Pad,Pad,-Pad,-Pad)
g = Padc.defreq(fy=0,fx=37,sharp=100,dx=50,dy=50,cutx=0,cuty=0,Measure=MEASURE).Crop(Pad,Pad,-Pad,-Pad)
g1 = Padc.defreq(fy=0,fx=85,sharp=100,dx=50,dy=50,cutx=0,cuty=0,Measure=MEASURE).Crop(Pad,Pad,-Pad,-Pad)
b = Padc.defreq(fy=0,fx=65,sharp=100,dx=50,dy=50,cutx=0,cuty=0,Measure=MEASURE).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,Measure=MEASURE).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
}
EDIT: From DeFreq() docs
measure - select fastest FFT method by speed measure (longer init stage) instead of simple estimation (default=true)
EDIT: Stacking two versions side by side, and I'm now getting crashes, but with single version seems more stable.
vcmohan
10th June 2016, 12:39
from the write up Defreq is equivalent to F2Quiver with point symmetry option and large degree (24). The difference still would be defreq selects the point coordinates as the maximum in window, while F2Quiver does not. One more point, if the search window encompasses either x = 0 or y = 0, then the point to be filtered will always be on the axis. The axial values are larger as they represent the DC value.
StainlessS
10th June 2016, 13:36
So would below be about same ?
MEASURE=false # Fix crashes
p3R=39 #
r=defreq(fy=0,fx=p3R,sharp=100,dx=50,dy=50,cutx=0,cuty=0,Measure=MEASURE)
p3R=39 # EDIT: p3R=Int(39*127/100.0+0.5)
MORPH = False # Default False(as yet untried)
RESCALE= False # Default False
FRAD = 16 # Default 32, Min Frame x:y dimension=16*8=128(incl padding)
# Symetry=5(Point) : Type=5(Not Used) : xFreq=p3x(arg) : yFreq=0 : DegreeOfSharpness=24 : FRad=FRAD
r=F2Quiver(5,5,p3R,0,24, morph=MORPH,rescale=RESCALE,frad=FRAD)
Although for p3R, I think defreq goes to 100.0 and F2Quiver 127 (int) [needs conversion]
vcmohan
11th June 2016, 12:43
So would below be about same ?
MEASURE=false # Fix crashes
p3R=39 #
r=defreq(fy=0,fx=p3R,sharp=100,dx=50,dy=50,cutx=0,cuty=0,Measure=MEASURE)
p3R=39 # EDIT: p3R=Int(39*127/100.0+0.5)
MORPH = False # Default False(as yet untried)
RESCALE= False # Default False
FRAD = 16 # Default 32, Min Frame x:y dimension=16*8=128(incl padding)
# Symetry=5(Point) : Type=5(Not Used) : xFreq=p3x(arg) : yFreq=0 : DegreeOfSharpness=24 : FRad=FRAD
r=F2Quiver(5,5,p3R,0,24, morph=MORPH,rescale=RESCALE,frad=FRAD)
Although for p3R, I think defreq goes to 100.0 and F2Quiver 127 (int) [needs conversion]
As defreq selects highest valued freq to attennuate, I can not for sure say that the two are same. Best way to check is to run a F2QTest after each of these and see visually whether the filter appears at the same point.
MWilson
17th July 2016, 17:14
I found something from a while back. It doesn't internally greyscale and I'm using cmb(0,1,0,false) before.
function colorbyfreqx (clip c, float weight)
{
c=c.converttoyv12()
v=c.gaussresize(256,256).levels(0,1.150,255,0,255).tweak(bright=0)
v
g=v.defreq(fy=0,fx=84,sharp=100,dx=50,dy=50,cutx=0,cuty=0,info=false)
b=v.defreq(fy=0,fx=99,sharp=100,dx=50,dy=50,cutx=0,cuty=0,fx2=100,fy2=0)
r=v.defreq(fy=0,fx=39,sharp=100,dx=50,dy=50,cutx=0,cuty=0)
g1=v.defreq(fy=0,fx=49,sharp=100,dx=50,dy=50,cutx=0,cuty=0)
b1=v.defreq(fy=0,fx=76,sharp=100,dx=50,dy=50,cutx=0,cuty=0,fx2=100,fy2=0)
r1=v.defreq(fy=0,fx=47,sharp=100,dx=50,dy=50,cutx=0,cuty=0)
x1=merge(r1,r)
y1=merge(g,g1)
z1=merge(b1,b)
x=mt_makediff(v,x1,y=3).levels(0,0.3,255,0,255).converttorgb()
y=mt_adddiff(v,y1,y=3).levels(0,1.5,226,0,255).converttorgb()
z=mt_adddiff(v,z1,y=3).levels(0,.4,226,0,235).converttorgb()
mergergb(x,y,z)
converttoyv12()
gaussresize(width(c),height(c))
ColorYUV(autogain=true,autowhite=true,showyuv=false)
tweak(sat=2)
mergechroma(c,last,weight)
return last
}
My current go-to script (Newly Modified CMB):
Function CmBmod(clip v, Int "Speed", float "Weight", float "Merge" , int "CBlur", Bool "ALevel") { # (c) MWilson, http://forum.doom9.org/showthread.php?t=173364
###Source Must Be Progressive
Speed= Default (Speed,1) # 0 = fast, 1 normal, 2 slow.
Assert(Speed>=0 && Speed <=2, "Speed, 1 <= Speed <= 2")
Weight=Float(Default (Weight,1))
Merge=Float(Default (Merge,.25))
CBlur = Default (CBlur,20) ### Very dependent on source
ALevel= Default (ALevel,False)
LRad = Speed < 2 ? 4 : 12
#
v = v.Crop(0,0,v.Width/2*2,v.Height/2*2).ConvertToYV12.GreyScale.colorbyfreqx(1) # Mod 2, must be same as cmx7mod returns
c=(ALevel==True) ? v.autolevels(12) : v
cpad = Speed < 2 ? c.bilinearresize(400,400) : c
g=cpad.F2Quiver(1,3,96, 127,0,frad=24)
b=cpad.F2Quiver(1,3,110,127,0,frad=24)
r=cpad.F2Quiver(1,3,76, 127,0,frad=24)
mergergb(r,g,b)
autolevels(LRad,autogamma=true)
converttoyv12()
coloryuv(autowhite=true)
tweak(sat=10,interp=32).tweak(sat=10,interp=32)
converttorgb()
invert("G")
mergergb(showgreen,showred,showblue)
converttoyv12()
tweak(hue=90)
converttoyv12()
medianblur(0,CBlur,CBlur)
bilinearresize(width(c),height(c))
coloryuv(autowhite=true)
# cc=Speed > 0 ? c.cmx7mod() : c
# mergechroma(cc,Last,Weight)
Speed > 0 ? Last.Merge(c.colorbyfreqx(1).gblur(2),Merge) : Last
mergechroma(c.greyscale(),Last,Weight)
}
Will add some example pics, once again by no means perfect, but it seems to colorize well.
Edit: Examples, at default with the above script.
http://i1053.photobucket.com/albums/s461/Morgan_Dale_Wilson/1941%20ReColor%203_zpsrnkryiho.jpg (http://s1053.photobucket.com/user/Morgan_Dale_Wilson/media/1941%20ReColor%203_zpsrnkryiho.jpg.html)
http://i1053.photobucket.com/albums/s461/Morgan_Dale_Wilson/Doc%20Who%20Color_zpsmckc2tf7.jpg (http://s1053.photobucket.com/user/Morgan_Dale_Wilson/media/Doc%20Who%20Color_zpsmckc2tf7.jpg.html)
http://i1053.photobucket.com/albums/s461/Morgan_Dale_Wilson/1941%20ReColor_zps6ffjv6ki.jpg (http://s1053.photobucket.com/user/Morgan_Dale_Wilson/media/1941%20ReColor_zps6ffjv6ki.jpg.html)
Edit: Newly updated CMB.
cork_OS
20th July 2016, 09:00
http://demos.algorithmia.com/colorize-photos/
http://i1376.photobucket.com/albums/ah1/Ivan_Nemow/52b568d28c0e6d224356fed37ee87e46_IceCold_BW0_zpssjbib6gx.png (http://s1376.photobucket.com/user/Ivan_Nemow/media/52b568d28c0e6d224356fed37ee87e46_IceCold_BW0_zpssjbib6gx.png.html) http://i1376.photobucket.com/albums/ah1/Ivan_Nemow/6c740146e6a1123790b63168bc031b39_SE_BW0_zpsgwabpgpv.png (http://s1376.photobucket.com/user/Ivan_Nemow/media/6c740146e6a1123790b63168bc031b39_SE_BW0_zpsgwabpgpv.png.html)
MWilson
21st July 2016, 03:43
Edit: Above script at post 151 is much better.
Full rewrite. ChromaJig v1 (or is it a million? )
:rolleyes:
Requirements:
defreq
Masktools
MedianBlur
GamMac
Optional:
F2Quiver
function cm1 (clip c, float weight)
{
c=c.converttoyv12()
v=c.gaussresize(256,256)##.unfilter(0,100).unfilter(100,100)
v
g=v.defreq(fy=-100,fx=100,sharp=0,dx=50,dy=50,cutx=0,cuty=0,info=false)
b=v.defreq(fy=-100,fx=0,sharp=0,dx=50,dy=50,cutx=0,cuty=0,fx2=0,fy2=0)
r=v.defreq(fy=0,fx=36,sharp=0,dx=50,dy=50,cutx=0,cuty=0)
g1=v.defreq(fy=-50,fx=49,sharp=0,dx=50,dy=50,cutx=0,cuty=0)
b1=v.defreq(fy=0,fx=49,sharp=0,dx=50,dy=50,cutx=0,cuty=0,fx2=0,fy2=0)
r1=v.defreq(fy=-50,fx=34,sharp=0,dx=50.0,dy=50.0,cutx=0,cuty=0)
x1=merge(r1,r)
y1=merge(g,g1)
z1=merge(b,b1)
x=mt_makediff(v,x1,y=3).converttorgb()
y=mt_makediff(v,y1,y=3).converttorgb()
z=mt_makediff(v,z1,y=3).converttorgb()
mergergb(x,y,z)
converttoyv12()
coloryuv(autowhite=true)
gaussresize(width(c),height(c))
ColorYUV(autogain=true,autowhite=false)
tweak(sat=3.5,interp=32)
invert("UV")
swapuv()
medianblur(0,5,5)
mergechroma(c,last,weight)
return last
}
function chromajig(clip g, float weight)
{
g=g.greyscale().converttoyv12()
converttorgb(g)
rgbadjust(g=0)
invert()
cm1(1)
invert("Y")
converttorgb()
rgbadjust(r=0,b=0)
merge(g.cm1(1),last.converttoyv12())
converttorgb()
gammac(-3)
converttoyv12()
coloryuv(cont_u=220,cont_v=220)
mergechroma(g,last,weight)
return last
}
I hope this can be useful.
:thanks:
Edit: Removed last line. - Added CMJ.
Edit: CMJ Removed.
MWilson
24th July 2016, 09:29
I'm finding some uses of cmfullshift out in the wild.
Large portions of Metropolis.
https://www.youtube.com/watch?v=AbH1cQUnh7U (https://www.youtube.com/watch?v=AbH1cQUnh7U)
The transformation scene.
https://www.youtube.com/watch?v=E99Gb7N2oIk
Deadly Earnest.
https://www.youtube.com/watch?v=6XxooEg9qxo (https://www.youtube.com/watch?v=6XxooEg9qxo)
Because I modified the first post, omitting the script, here it is warts and all.
function cmfull(clip v2)
{
v2=v2.greyscale()
width=v2.width/2
height=v2.height/2
v=v2.sincresize(256,256).greyscale().addborders(width,height,width,height)
g=v.defreq(fy=0,fx=59,sharp=100,dx=50,dy=50,cutx=0,cuty=0,info=false)
b=v.defreq(fy=0,fx=65,sharp=100,dx=50,dy=50,cutx=0,cuty=0,info=false)
r=v.defreq(fy=0,fx=39,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)
b1=v.defreq(fy=0,fx=59,sharp=100,dx=50,dy=50,cutx=0,cuty=0,fx2=100,fy2=0)
r1=v.defreq(fy=0,fx=47,sharp=100,dx=50,dy=50,cutx=0,cuty=0)
x1=merge(r1,r)
y1=merge(g,g1)
z1=merge(b1,b1)
z2=overlay(v,z1,0,0,mode="multiply")
y2=overlay(v,y1,mode="multiply")
x2=overlay(v,x1,mode="multiply")
x=mt_makediff(v,x1).converttorgb().crop(width,height,-width,-height)
y=mt_makediff(v,y2).converttorgb().crop(width,height,-width,-height)
z=mt_makediff(v,z2).converttorgb().crop(width,height,-width,-height)
mergergb(x,y,z)
lanczos4resize(width(v2),height(v2))
converttoyv12()
ColorYUV(autogain=false,autowhite=true)
tweak(sat=1)
ax=last.sincresize(width(v2),height(v2))
bx=mergechroma(v2.greyscale(),ax,1)
coloryuv(bx,autowhite=true)
mergechroma(merge(last,last.invert("Y").invert("UV")),last,1)
mergechroma(v2.greyscale(),last,1)
return last
}
function cmfullshift (clip v)
{
v=v.converttoyv12().greyscale()##only addition
cmfull(v)
u=last.utoy()
v2=last.vtoy()
stackhorizontal(u,v2)
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
}
RocketJet
24th July 2016, 12:13
I cannot find the gammac plugin needed for the ChromaJig script above. Google didn't help.
Can anyone point me to it?
MWilson
24th July 2016, 12:18
GamMac:
http://forum.doom9.org/showthread.php?t=173695
RocketJet
24th July 2016, 14:58
Thanks.
Reel.Deel
24th July 2016, 16:48
Interesting VideoHelp thread: Coloring Grey-Scale Image: Another triumph of deep learning AI (http://forum.videohelp.com/threads/378962-Coloring-Grey-Scale-Image-Another-triumph-of-deep-learning-AI)
MWilson
24th July 2016, 17:31
Thanks for the link Reel.Deel :)
function cmfullshift2 (clip v)
{
v=v.converttoyv12()
cmfull(v)
u=last.utoy()
v2=last.vtoy()
##stackhorizontal(u,v2)
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(u,v2,v)
tweak(sat=7.5,interp=32)
mergechroma(v,last,.33)
coloryuv(autowhite=true)
##vtoy()
u4=mt_merge(u.spline36resize(width(v),height(v)),u.invert().spline36resize(width(v),height(v)),v).lanczosresize(width(v)/2,height(v)/2)
v4=mt_merge(v2.spline36resize(width(v),height(v)),v2.invert().spline36resize(width(v),height(v)),v).lanczosresize(width(v)/2,height(v)/2)
ytouv(u4,v4,v)
tweak(sat=7.5)
mergechroma(v,last,.75)
return last
}
function cmshifter (clip y, float weight)
{
y=y.converttoyv12().greyscale()
gaussresize(y,192,108)
cmfullshift2()
coloryuv(cont_u=-96,cont_v=-96)
hqdn3d(8,16,0,4.5)
tweak(sat=7.5,interp=32)
gaussresize(width(y),height(y))
mergechroma(y.chromajig(1),last,.33)
mergechroma(y,last,weight)
return last
}
CMShifter comes (I think) as close as I have gotten.
Hope you guys like it!
Edit: Comparison Pic - cmfullshift (left) / cmshifter (right)
http://i1053.photobucket.com/albums/s461/Morgan_Dale_Wilson/cmfullshift%20vs%20cmshifter_zpsajnmvcf7.jpg (http://s1053.photobucket.com/user/Morgan_Dale_Wilson/media/cmfullshift%20vs%20cmshifter_zpsajnmvcf7.jpg.html)]
MWilson
29th July 2016, 05:37
ChromaJig v1.6a - 8/15/2016
Requirements:
Defreq
Masktools2
HQDN3d
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.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
}
Edit: New - Version 1.6a
Edit: Minor Changes
Edit: New - Version 1.5b - Removed Link to video
Edit: New - Version 1.5a - Removed Extra Calls - Output is the same
Edit: Remove Old Pics
Edit: Link to script and all requirements :ChromaJig (https://drive.google.com/folderview?id=0B72PmD8lKDzSQmxaTTdhV0VnRDQ&usp=sharing)
MWilson
15th August 2016, 21:35
I apologize for the last script. It wasn't even working for me :(
I've posted a new version (3 scripts in 1), but I'm having trouble getting much further than this. Any ideas would be appreciated.
I hope this can be helpful. I'm taking a break :rolleyes:
RocketJet
20th August 2016, 10:52
I tried running ChromaJig under AviSynth MT and it is MUCH faster.
Also, to get better skin tones, I use VirtualDub gradation curves filter to limit saturation.
MWilson
20th August 2016, 10:57
I tried running ChromaJig under AviSynth MT and it is MUCH faster - about 8x.
Also, to get better skin tones, I use VirtualDub gradation curves filter to limit saturation.
Thanks for the tip! I'll check out a MT build.And I've been using colormill for similar reasons.
RocketJet
20th August 2016, 11:12
I used the AviSynth MT version and instructions from the following page:
http://forum.doom9.org/showthread.php?t=148782
RocketJet
20th August 2016, 15:17
I didn't notice at first that part of the speed up in processing was from the latest version of ChromaJig. But still, using AviSynth MT certainly helped too.
real.finder
20th September 2016, 17:06
ChromaJig v1.6a - 8/15/2016
Requirements:
Defreq
Masktools2
HQDN3d
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.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
}
Edit: New - Version 1.6a
Edit: Minor Changes
Edit: New - Version 1.5b - Removed Link to video
Edit: New - Version 1.5a - Removed Extra Calls - Output is the same
Edit: Remove Old Pics
Edit: Link to script and all requirements :ChromaJig (https://drive.google.com/folderview?id=0B72PmD8lKDzSQmxaTTdhV0VnRDQ&usp=sharing)
wow, this is very good, I test it in damaged VCR home made video that lost the colour and it work but there is some Artifacts (like blue big halo)
StainlessS
20th September 2016, 23:18
Yes, M Wilson made some real strange but good investigations into that area.
Mostly inexplicable (un - explainable, but still seem to work, against all odds).
Floatingshed
23rd September 2016, 23:06
I'm trying to have a play with chromajig_15 but cannot get past: There is no function called F2Quiver
It is there, in the plugins folder... and libfftw3f-3.dll is in system32 and syswow64.
Any ideas please?
Also what is "cmfull" and "cmfullshift"? There seem to be various bits of code scattered throughout this thread. How should this be used?
Thanks.
MWilson
24th September 2016, 04:48
I'm stumped on the first question :mad:
As for the second, I was (am) very disorganized! I'm pretty happy with the script real.finder quoted a couple of posts up, FWIW.
:thanks:
Floatingshed
24th September 2016, 20:18
I have tried the script posted by real.finder and I'm now having trouble with a different filter: "unable to load awarpsharp.dll Module not found, install missing library.
Can anyone suggest what might be happening here. I have tried the dll in my avisynth plugins folder (which gives: no function called awarpsharp2) and elsewhere specifically loaded (which gives the above error). I have 32bit avisynth 2.6mt under win7 64bit. Using x86 version of awarpsharp2 dll
Its really frustrating when this sort of stuff stops you playing with an interesting script grrr!
raffriff42
24th September 2016, 20:33
>cannot get past: There is no function called F2Quiver...
Make sure you have a valid source clip.
If you call any filter without giving it a source clip, you get an error message; usually either
Invalid arguments to function "<filter>"
or
I don't know what "<filter>" means
>unable to load awarpsharp.dll Module not found, install missing library.
From the wiki page (http://avisynth.nl/index.php/AWarpSharp2#Requirements), you need
Microsoft Visual C++ 2015 Redistributable Package (vcredist_x86.exe) (http://www.microsoft.com/en-us/download/details.aspx?id=52982)
Floatingshed
24th September 2016, 21:12
Thanks, clearly I had an older version. Sorted now, although I still can't get F2Quiver to work (same errors as above). I guess a different runtime is needed but there's no mention of which one on the wiki.
Now the script is working without errors it isn't producing anything like the results posted in this thread, everything I try is just cepia with a blue halo!
Taurus
24th September 2016, 21:24
Amazing, truly amazing!
Tried CromaJig for the first time.
Everything went smooth.
I must have been lucky, all dependancies are working right out of the box.
Took some greyscales and sepia toned clips,
....and wow!
What a surprise.
Colors, real colors in the results.
Thank you MWilson and of course StainlessS and all others who made this magic happened:thanks::thanks:
Floatingshed
24th September 2016, 21:38
Amazing, truly amazing!
Tried CromaJig for the first time.
Everything went smooth.
I must have been lucky, all dependancies are working right out of the box.
Took some greyscales and sepia toned clips,
....and wow!
What a surprise.
Colors, real colors in the results.
Thank you MWilson and of course StainlessS and all others who made this magic happened:thanks::thanks:
Would you please post exactly what you did to get good results?
Just please copy your script.
Thanks.
MWilson
24th September 2016, 23:56
Amazing, truly amazing!
Tried CromaJig for the first time.
Everything went smooth.
I must have been lucky, all dependancies are working right out of the box.
Took some greyscales and sepia toned clips,
....and wow!
What a surprise.
Colors, real colors in the results.
Thank you MWilson and of course StainlessS and all others who made this magic happened:thanks::thanks:
Taurus, I'm glad you like it! You just made my day :D
Floatingshed
25th September 2016, 00:37
Please explain how to make this work.
The script posted by real.finder gives this: http://www.floatingshed.com/temp/1.jpg
The downloaded chromajig-15.avsi gives this: http://www.floatingshed.com/temp/2.jpg
MWilson
25th September 2016, 01:20
The only thing I can think of at the moment is to downscale before the script.
Try the following:
Y=Clip
Y.GaussResize(192,76).ChromaJig().GBlur(2).GaussResize(width(Y),height(Y))
MergeChroma(Y,Last)
Edit: I didn't even like the results of 1.5 and it will be replaced with the latest ASAP.
Floatingshed
25th September 2016, 01:48
Still not right...
http://www.floatingshed.com/temp/3.jpg
MWilson
25th September 2016, 02:15
Still not right...
Floatingshed, it's not perfect. If you just want rid of the halos, somebody else may be able to help :)
Floatingshed
25th September 2016, 02:23
Oh, I don't expect miracles! Is this now working as it should? I have had so many stumbles with this I am not sure...
Other folks earlier in this thread seemed to be getting far better results.
MWilson
25th September 2016, 02:30
From what I see it is. If you could point me to the images you like, I can most likely post the script used :)
raffriff42
25th September 2016, 05:12
Still not right...
http://www.floatingshed.com/temp/3.jpg
Simply limiting the maximum chroma/saturation helps a lot.
https://www.dropbox.com/s/vn7s6y0j5vbfgit/autochroma-sample103-limited.jpg?raw=1
Limiter (http://avisynth.nl/index.php/Limiter)(0, 255, 128-12, 128+12)
MWilson
25th September 2016, 05:30
Simply limiting the maximum chroma/saturation helps a lot.
:goodpost:
Limiter had slipped my mind, that's going to come in handy!
TheFluff
25th September 2016, 19:01
I really wouldn't put too much effort into a filter that by definition gives essentially random results. Just sayin'
MWilson
25th September 2016, 19:36
I really wouldn't put too much effort into a filter that by definition gives essentially random results. Just sayin'
There are plenty of problems, but those problems seem to be fairly consistent. So I will have to disagree :)
AzraelNewtype
25th September 2016, 20:55
Oh, I don't expect miracles! Is this now working as it should? I have had so many stumbles with this I am not sure...
Other folks earlier in this thread seemed to be getting far better results.
The best results shown in this thread were from when the script was being used on clips that had chroma, and the script was buggy and reusing that information instead of purely the random noise that you're getting.
MWilson
25th September 2016, 21:29
The best results shown in this thread were from when the script was being used on clips that had chroma, and the script was buggy and reusing that information instead of purely the random noise that you're getting.
A) The images you're talking about are gone, and have been for months.
B) Random noise is going too far, if you don't like the results you have every right to say so. But it plain and simply isn't what you're describing.
real.finder
25th September 2016, 21:53
The only thing I can think of at the moment is to downscale before the script.
Try the following:
Y=Clip
Y.GaussResize(192,76).ChromaJig().GBlur(2).GaussResize(width(Y),height(Y))
MergeChroma(Y,Last)
Edit: I didn't even like the results of 1.5 and it will be replaced with the latest ASAP.
gblur need 3 and up (odd number) (http://www.avisynth.nl/users/vcmohan/GBlur/GBlur.html)
do you use another GBlur?
TheFluff
25th September 2016, 21:57
No, seriously though, this particular bit of dumb has gone on for far too long. Your script is based on not just one, but a entire series of fundamental misunderstandings of the underlying technology (the most egregious ones being how measuring chromatic information actually works and what the frequency domain actually is). This has been pointed out to you several times already but still you persist in using the same method. This entire thread is one big tribute to the remarkable ability of the human perception to see what it wants to see. You're literally adding random colors (there is no correlation whatsoever between the information you're basing the colors on and the actual color of the object, so you're picking the colors at random - it's not even an educated guess) and when the almost correct shade happens to fall out of the slot machine for some important foreground object you claim that this is a success, never mind that literally everything else in the background is utter garbage and you get a whole truckload of bizarre artifacts to go along with it (hint: stop these dumb frequency domain operations already). The entire thing is nonsense that usually results in coloring the entire scene either vaguely orange or vaguely green. Just drop it.
MWilson
25th September 2016, 22:01
gblur need 3 and up (odd number) (http://www.avisynth.nl/users/vcmohan/GBlur/GBlur.html)
do you use another GBlur?
I most likely am. I'm away from my main computer so I can't give you the exact plugin (or version of ?). The idea is the same, I'd just go with whatever gives you the best results.
MWilson
25th September 2016, 22:08
Just drop it.
Exactly.
Navarre66
25th September 2016, 23:15
Really to do this correctly you would need to use a neural network. There just isn't enough information there. In reality most stars were wearing green makeup in the black and white TV shows so you are never going to want to show the real colors anyway.
Here are a couple articles that seems to be much better results, but still has work to go.
http://tinyclouds.org/colorize/
https://techcrunch.com/2016/03/31/this-neural-network-hallucinates-the-right-colors-into-black-and-white-pictures/
However I still wish you luck with this technique.
Navarre66
MWilson
25th September 2016, 23:26
Really to do this correctly you would need to use a neural network. There just isn't enough information there. In reality most stars were wearing green makeup in the black and white TV shows so you are never going to want to show the real colors anyway.
Here are a couple articles that seems to be much better results, but still has work to go.
http://tinyclouds.org/colorize/
https://techcrunch.com/2016/03/31/this-neural-network-hallucinates-the-right-colors-into-black-and-white-pictures/
However I still wish you luck with this technique.
Navarre66
Thank you, and I agree about the neural network approach :)
real.finder
27th September 2016, 06:32
I most likely am. I'm away from my main computer so I can't give you the exact plugin (or version of ?).
I am waiting :)
RocketJet
27th September 2016, 10:03
No, seriously though, this particular bit of dumb has gone on for far too long. .
On the contrary, I find it works quite well for me. I have colorized a bunch of stuff, including Fireball XL5 and the B/W seasons of Superman. Bottom line, if you don't like, then don't use it. I like it.
color
27th September 2016, 18:46
I think this works great on old movies. I do have to change the levels, contrast and brightness a bit on some scenes to make it work better. But the best result is when its outdoor, its the sky is blue and colors are great. Often the things that should be red becomes green, but I can live with that.
And about the off topic on colorization with learning, I would love to see this work somehow with avisynth, but I think its hard job and hard to do. But it looks awesome. Still I do like the ChromaJig and I do like it and its faster than other projects like:
http://people.cs.uchicago.edu/~larsson/colorization/
http://colorize.ttic.edu/
http://demos.algorithmia.com/colorize-photos/ (free to do one picture online but otherwise it cost)
https://github.com/satoshiiizuka/siggraph2016_colorization
http://colorize.dev.kaisou.misosi.ru/
https://github.com/Eiji-Kb/macacon
color
3rd October 2016, 18:31
Floatingshed
I do try to change the levels to get the best "colors" when its not good colored., but mostly they are okey.
I did change the levels but I think it could be mutch better if you do it. I just did this in a few secounds:
ImageSource("C:\where_ever\the_image.jpg").ConvertToYUY2(matrix="Rec601", interlaced=false)
Levels(0, 1.390, 191, 0, 170)
chromajig(1)
when merging the color/chroma(?) with the black and white image or movie then its so mutch better.
B=(ImageSource("C:\where_ever\the_image.jpg"))
C=(ImageSource("C:\where_ever\the_image.jpg").Levels(0, 1.390, 191, 0, 170).chromajig(1))
Overlay(B, C.BicubicResize(B.Width, B.Height), mode="chroma")
The only problem I have is the green color that sometimes want to color the face.
MWilson
26th October 2016, 04:02
function cjb(clip v)
{
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(128,128)
chromajig()
blur(1,1)
invert()
swapuv()
spline36resize(width(y),height(y))
c=last
subtract(a,b)
subtract(last,c)
invert()
temporalsoften(10,0,25)
mergechroma(y.converttoyv12().greyscale(),last,.75)
coloryuv(autowhite=true)
hqdn3d(0,6,0,4.5)
spline36resize(width(v),height(v))
blur(1,1)
mergechroma(v,last)
return last
}
function cjc(clip y)
{
y=y.greyscale().converttoyv12()
a=y.cjb().invert().tweak(hue=-90).invert().invert("U").swapuv()
b=y.cjb()
merge(a,b)
return last
}
Edit: Removed some extra lines
This is giving me some promising results, as always adjust as necessary.
:thanks:
MWilson
6th November 2016, 11:22
function ChromaJig3 (clip y, float weight)
{
y=y
weight=Default (weight,1)
y.gaussresize(240,240)
blur(1,1)
blur(1,1)
blur(1,1)
gaussresize(120,120)
blur(1,1)
blur(1,1)
gaussresize(42,42)
blur(1,1)
blur(1,1)
blur(1,1)
blur(1,1)
blur(1,1)
chromajig()
swapuv()
invert()
gaussresize(width(y),height(y))
subtract(last,y.chromajig())
a=last
a.gaussresize(36,36).chromajig().gaussresize(width(y),height(y))
b=last
c=subtract(a,b).swapuv()
d=subtract(b,a)
subtract(c,d)
merge(a,last)
merge(c,last)
invert("V")
mergechroma(y,last)
mergechroma(last,d,.75)
mergechroma(y,last,weight)
}
function fcjig(clip y)
{
y=y.converttoyv12()
y
gaussresize(80,60)
converttoyv12()
y1=last
y1
chromajig3(1)
converttorgb()
invert("G")
converttoyv12()
invert("UV")
swapuv()
blur(1,1)
blur(1,1)
blur(1,1)
merge(y1.chromajig(),last)
bilinearresize(width(y),height(y))
subtract(last,y.greyscale())
tweak(hue=-90)
merge(y.chromajig(),last)
gaussresize(80,80)
blur(1,1)
blur(1,1)
bilinearresize(width(y),height(y))
mergechroma(y,last)
return last
}
function chroma(clip v,float "Weight")
{
Weight= Default (Weight,.75)
v=v.greyscale().converttoyv12()
y=v.linearresize(240,240).greyscale()
y.fcjig()
mt_makediff(vtoY(),last.reduceby2(),u=3,v=3)
#chromajig3b()
invert()
coloryuv(autowhite=true)
linearresize(width(v),height(v))
mergechroma(v,last,Weight)
}
I know this could be shortened. If you don't have LinearResize, change it to whatever you tend to use :)
I hope you folks will enjoy it as much as I am.
You might want to use rgbadjust (Broken Record, I know). But it's fairly close from the get-go with everything I've tried.
Here's two short clips that haven't been corrected or graded, one is from a color source converted to greyscale, and one that was originally colorized and then converted to greyscale.
https://vimeo.com/190428169
Usage:
Chroma()
Thanks folks!
MWilson
7th November 2016, 14:00
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)
}
Usage:
ColorJig()
Edit: Quick Test using ColorJig().Autolevels()
https://vimeo.com/190554882
Edit: Commented out HQDN3D and temporalsoften calls, it was painfully slow. Using a denoiser after the fact is really just about as good.
MWilson
8th November 2016, 11:33
This one is very close as far as I can see. I apologize for the posts, I just had to get some stuff out there.
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
}
http://i1053.photobucket.com/albums/s461/Morgan_Dale_Wilson/Porkysavs008533_zpst3eic1na.png
http://i1053.photobucket.com/albums/s461/Morgan_Dale_Wilson/Porkysavs000946_zpsrub89jmc.png
http://i1053.photobucket.com/albums/s461/Morgan_Dale_Wilson/Star_Trek_The_Cage_hybrid_vs_full_version_part_2_3_hd1080017063_zpshzw6ylp9.png
http://i1053.photobucket.com/albums/s461/Morgan_Dale_Wilson/Porkysavs004610_zps1un54eqv.png
Bloax
8th November 2016, 17:30
Plain transformations are never going to be anything close to correct, though having a bunch of vaguely related colors help tell your brain that there were probably colors there sometime.
MWilson
8th November 2016, 18:12
Bloax, they are *very* close to correct.
https://vimeo.com/190745275
On a side note, I am running avisynth through wine. When I checked on my windows computer it looked awful. I'm going to guess that defreq is running better under wine.
TheFluff
8th November 2016, 19:40
Bloax, they are *very* close to correct.
No they're not, you're either delusional or intentionally talking nonsense. The chroma isn't even particularly well attached to the luma shapes. The entire background is full of random hues and in many scenes the coloring is highly unstable and there are deeply disconcerting color fluctuations over the entire frame. Most scenes have a generally brown-ish tone (with odd fluctuations towards green and blue in places) that I guess you think looks "correct" because sometimes it happens to coincide with a vague impression of human skin coloring or something.
Again, please stop this nonsense and stop trying to convince people that your snake oil is actually worth something.
On a side note, I am running avisynth through wine. When I checked on my windows computer it looked awful. I'm going to guess that defreq is running better under wine.
nope
MWilson
8th November 2016, 19:44
No they're not, you're either delusional or intentionally talking nonsense. The chroma isn't even particularly well attached to the luma shapes. The entire background is full of random hues and in many scenes the coloring is highly unstable and there are deeply disconcerting color fluctuations over the entire frame. Most scenes have a generally brown-ish tone (with odd fluctuations towards green and blue in places) that I guess you think looks "correct" because sometimes it happens to coincide with a vague impression of human skin coloring or something.
Again, please stop this nonsense and stop trying to convince people that your snake oil is actually worth something.
nope
Fluffy, it's odd I don't have any views on the video at the moment!
Also insults are getting a little old. And yes it is working better via wine for me.
TheFluff
8th November 2016, 19:46
Fluffy, it's odd I don't have any views on the video at the moment!
I'm almost literally planting my face into my desk here
edit: ok real response: the conspiracy here is that no view counter on any big site ever updates in realtime, because that doesn't scale
TheFluff
8th November 2016, 19:49
and no defreq doesn't "work better" under wine, you're either making things up or more likely you're doing something wrong (using different versions of the plugins or a different script or w/e)
I haven't tried it at all, in fact I haven't even used Wine in many years but I can tell you this with a great deal of confidence anyway because unlike you I have at least a basic understanding of how these things work
MWilson
8th November 2016, 19:51
I'm almost literally planting my face into my desk here
I am being sincere. I checked my activity, maybe it didn't update.
Fluffy, please stop.
TheFluff
8th November 2016, 19:52
see edits
MWilson
8th November 2016, 19:54
and no defreq doesn't "work better" under wine, you're either making things up or more likely you're doing something wrong (using different versions of the plugins or a different script or w/e)
I haven't tried it at all and haven't used Wine in many years but I can tell you this with a great deal of confidence anyway because unlike you I have at least a basic understanding of how these things work
Yeah, I was making up that it looked horrible on my PC.
Fluffy, I'm fed up with this trolling.
TheFluff
8th November 2016, 19:55
seriously, post a video comparing only the chroma without the luma channel at all. I bet my ass there's zero correlation between the two
MWilson
8th November 2016, 19:56
Sure thing!
TheFluff
8th November 2016, 19:57
Yeah, I was making up that it looked horrible on my PC.
Fluffy, I'm fed up with this trolling.
Everything you posted looks like garbage already though so I don't see why there would be a difference? Do you perhaps have a broken monitor on your Linux box?
objective facts: now considered trolling
MWilson
8th November 2016, 20:00
Everything you posted looks like garbage already though so I don't see why there would be a difference? Do you perhaps have a broken monitor on your Linux box?
objective facts: now considered trolling
Okay Fluffy, I've reported your post. Stop.
johnmeyer
8th November 2016, 21:28
Okay Fluffy, I've reported your post. Stop.I did too. I have no problem with him calling the script useless, but once or twice is enough. By repeating the same thing over and over, it becomes harassment, which is against forum rules.
MWilson
8th November 2016, 21:35
I have no problem with him calling the script useless, but once or twice is enough. By repeating the same thing over and over, it becomes harassment, which is against forum rules.
I don't have a problem with folks hating the script, I just don't appreciate folks insulting my intelligence.
FWIW, I'm pleased with this one and it does it's job to my liking.
I'm going to refrain from posting every idea I have as well.
:thanks:
Kuukunen
8th November 2016, 22:45
I was *very* bored, so I played around with it a bit.
https://vimeo.com/190782322
http://pastebin.com/gq18n0fe
The middle left is the original chroma from the video, the middle right is the chroma from the right side of the video. (From the colorized version.)
The bottom left is redoing the colorization to check if the script is working correctly. (It seems to be, as it matches the chroma from the video.)
The bottom right is the difference between the chromas of the original and the colorized one.
Overall impressions: The chroma areas match somewhat in size and shape, which is not surprising, since it's basically taking the luma, blurring it and then trying to map it to chroma with some twists and turns. The colors however are completely off. Some red areas come out as red, but some red areas come out as blue or whatever, there doesn't seem to be any correlation between what the color should be and what the automatic colorization creates.
The difference clip is there mostly for fun, and if you look at it, you can note that the clip is about as vibrant as the original chroma, which would indicate that the colorized clip is about as far from the original as a blank gray video would be.
So in summary: The script seems to mostly assign random colors to areas in the video based on the luma and should not be used for anything serious, and even for non-serious applications is mostly useful as random color generator.
Gavino
8th November 2016, 23:15
So in summary: The script seems to mostly assign random colors to areas in the video based on the luma and should not be used for anything serious, and even for non-serious applications is mostly useful as random color generator.
Thank you.
At last, an objective analysis which confirms what many of us suspected.
MWilson
9th November 2016, 01:50
The script seems to mostly assign random colors to areas in the video based on the luma and should not be used for anything serious, and even for non-serious applications is mostly useful as random color generator.
Okay, all you have proven is that this is not *color restoration*. And it's not. I've said that it isn't. It's colorization, and pretty good colorization. It will not and can not be perfect.
TheFluff
9th November 2016, 07:06
Okay, all you have proven is that this is not *color restoration*. And it's not. I've said that it isn't. It's colorization, and pretty good colorization. It will not and can not be perfect.
You said:
[The colors] are *very* close to correct.
The only person here who is even bothering to make a distinction between colorization and color restoration is you. One wonders why the distinction is even meaningful in this case - obviously the goal in both cases is to attempt to get colors that are close to reality or at least plausibly so, and failing to do so means the method is bad. Your claim that the script produces results that are "close to correct" has been proven to be obviously untrue (who coulda thunk it, the method is obviously completely bogus and akin to trying to solve mathematical problems by divination from goose entrails). Should I take your backpedalling as a claim that you weren't even trying to get it right in the first place, or what?
Report for harassment all you want but I really don't think neither the forum nor public discourse in a wider sense is well served by people getting to make outrageous and false claims without any opposition. To quote philosopher Thomas Thorild, "to think freely is great, but to think rightly is greater".
MWilson
9th November 2016, 18:17
Fluffy, I'm responding to you for the last time. If you try it, and it looks "close to correct" (which it generally does), it's good. Stop this, it IS harassment and borderline slander. You are doing nothing but being mean, rude, and downright nasty. I reported you again, this is completely wrong.
StainlessS
9th November 2016, 18:31
It is what it is, whether tis scientifically accurate or not does not really matter (realistically, few were questioning whether it may be).
If it gives pleasing result, then that is it's intrinsic worth. Fluffy would have us all hand coloring black and white sequences, this is
one helluva lot simpler and easier and yes does fool the brain into accepting it as better than the source sequence, and if that is so,
then who cares if it accurately approximates the original pre capture scene.
Tis an interesting little folly and now that we all accept that, Fluffy can go off and antagonize his next victim.
Gavino
9th November 2016, 18:52
Tis an interesting little folly
The thing is, it would be better if MWilson had presented it in those terms.
If he had said from the start, "Here's a fun effect I discovered by playing about. It has no scientific basis, but seems to create the right colours for certain types of scenes, if you don't look too closely", we would all have accepted it in those terms.
Instead, by accident or design, he gave the impression that he had invented some wonderful way of extracting accurate colour information from greyscale images. Perhaps he even believes that he has, I still don't know.
MWilson
9th November 2016, 19:00
The thing is, it would be better if MWilson had presented it in those terms.
If he had said from the start, "Here's a fun effect I discovered by playing about. It has no scientific basis, but seems to create the right colours for certain types of scenes, if you don't look too closely", we would all have accepted it in those terms.
Instead, by accident or design, he gave the impression that he had invented some wonderful way of extracting accurate colour information from greyscale images. Perhaps he even believes that he has, I still don't know.
If I gave that impression, I sincerely apologize. It was an accident. No, I do not believe that. I just wanted to share something I thought could be useful. I admit I may be overly enthusiastic, but my intentions are good.
captaiŋadamo
9th November 2016, 19:04
Stop this, it IS harassment and borderline slander.
Just to be pedantic, it would be libel not slander. Slander is a spoken statement. :p
MWilson
9th November 2016, 19:08
Just to be pedantic, it would be libel not slander. Slander is a spoken statement. :p
Ha, you're right! Darn it!
StainlessS
9th November 2016, 20:33
I guess that some of us could having gotten a little over awed by some examples (the Golden girl GobSmacked me),
now, just gonna nip off and sharpen my razor blades in a great little cardboard pyramid that I bought at a very reasonable price,
they'll be nice and sharp by the morn.
StainlessS
15th July 2017, 15:27
Have restored my images since Photobucket broke them all,
@MWilson, if you wish to do same for yours, right click on your image on PhotoBucket, and select "Save Link As",
Then upload to eg postimg.org (is easy, can do without register if prefer), and restore the new links via forum edit.
MWilson
15th July 2017, 17:16
@MWilson, if you wish to do same for yours, right click on your image on PhotoBucket, and select "Save Link As",
Then upload to eg postimg.org (is easy, can do without register if prefer), and restore the new links via forum edit.
Thanks for the tip :) Will update this post when it gets fixed.
StainlessS
15th July 2017, 17:37
MW,
It probably aint gonna get fixed. (If you are talking about Photobucket restoring images), they want you to pay money now [EDIT: $400 annual] for
direct inserting images into forum (they changed the rules apparently, and very quietly).
Just go to the site and selelct 1st image, and save it, move on to next image via the big arrow (I think, have deleted my PB account).
You probably need do similar with Vimeo and for any other images that are broken.
EDIT: https://forum.doom9.org/showthread.php?p=1811309#post1811309
EDIT: I think about 2 or 3 images could not be downloaded from my account, (looked same as on forum), but I got back 260+
images OK.
EDIT: On second thoughts, I think I may have saved those that looked same as on forum, and they saved correctly, not sure though.
StainlessS
16th July 2017, 04:35
For anyone wanting to find all instances of PhotoBucket images embedded in their posts,
Advanced Search on keyword "PhotoBucket", and tick 'Posts' (rather than 'Threads'), and UserName to your own username.
I have now reinstated almost all of my PhotoBucket Images, downloaded from that site and re-upped to PostImage.org (about 250 images),
and in doing so have found that many others have had their images broken too. (tis very tedious and time consuming if you gots lots of them,
but worth doing I think).
You could do as above if you just wanna check out your posts.
johnmeyer
20th July 2017, 02:19
For anyone wanting to find all instances of PhotoBucket images embedded in their posts,
Advanced Search on keyword "PhotoBucket", and tick 'Posts' (rather than 'Threads'), and UserName to your own username.
I have now reinstated almost all of my PhotoBucket Images, downloaded from that site and re-upped to PostImage.org (about 250 images),
and in doing so have found that many others have had their images broken too. (tis very tedious and time consuming if you gots lots of them,
but worth doing I think).
You could do as above if you just wanna check out your posts.StainlessS,
They haven't hit me yet (don't know why), but I expect they will. What you describe sounds like HOURS of work. Were you able to automate it somehow? I can't imagine going through hundreds (or more) posts and cutting/pasting links. Not only would that be tedious, but I don't know how I could possibly keep track of everything:
1. Find next forum post with a link.
2. Open to edit.
3. Try to find the new link from the new hosting site that matches the broken Photobucket link (that would be torture, I would think).
4. Copy/paste the new link.
5. Rinse, lather, repeat.
Just this one forum would take a day. You must have figured out something simpler.
StainlessS
20th July 2017, 02:40
You must have figured out something simpler.
Wish that were the case. I think I started about mid morning, and finished about 05:00AM next morning :(
I downloaded all images (although I think I missed about 3),
Created a few directories where lots of images in single thread, eg GAMMAC dir, copied all images that I thought were from thread to the directories.
(Some I did not have a clue where they lived).
Find next post. Upload images for that post to postimage.org, copied links into thread, and moved images into DONE folder.
Repeat ~260 times.
(very tedious, every now and then the list of links expire and you have to redo the search).
I'm guessin that the problem originated in some recent-ish thread like GamMac, where there are lots of images, and also a significant number
of views on thread [EDIT: or this one, 30,000 views]. Maybe they added some kind of monitor recently so older threads not so much affected.
MWilson
18th August 2017, 17:24
function ct(clip v)
{##(c) MWilson 2017
v=v.converttoyv12().greyscale()
gs=v.greyscale().separatefields().gaussresize(360,360).converttoyv12().padding(16,16,16,16)
gs
r=gs.F2Quiver(1,3,47,127,0)
g=gs.F2Quiver(1,3,120,127,0)
b=gs.F2Quiver(1,3,126,127,6)
mergergb(b,g,r)
invert()
autogamma()
gaussresize(80,80,p=1)
converttoyv12()
coloryuv(autowhite=true)
gaussresize(width(gs),height(gs))
hqdn3d(0,7,0,14)
mergechroma(gs,last)
padresize(360,360)
weave()
converttorgb()
gaussresize(width(v),height(v))
gammac(-3,show=false)
converttoyv12()
return last
}
This isn't complete, but the output surprised me :)
P.S.
Sorry for being away so long, my father passed away and it's been rough.
P.P.S.
A Quick Video:https://vimeo.com/230180563
FranceBB
22nd August 2017, 01:17
Uh... It didn't recognise the face of the girl, but it did recognise that the tiles on the back were yellowish (white with a yellow light) and that the captions on the left sign were red, while the ones on the right sign were black, which is something. Probably because the light was stronger in that point, so it thought it may have been of a similar colour. Anyway, I don't have a clue about the haloing around the girl, which is pretty bad. It looks like a bronze-statue.
http://i.imgur.com/Bzc9xnq.png
TheFluff
22nd August 2017, 19:03
It doesn't recognize anything. The colors are randomized based on luma info only. Any resemblance to the original colors is pure coincidence.
TheFluff
23rd August 2017, 11:54
I mean, seriously. Look at the script. Literally all it does is take the grayscale image, convert it to RGB using the luma as R, G and B, blur it in at least three different ways and run auto white balancing on it. The reason it has so much haloing is that the chroma is constructed from the luma downscaled to first 360x360 and then further to 80x80 pixels, plus different kinds of blurring on top of that.
feisty2
23rd August 2017, 12:08
It doesn't recognize anything. The colors are randomized based on luma info only. Any resemblance to the original colors is pure coincidence.
cmon his dad just died, u can always save the bad news for a more appropriate time
edit: typo
FranceBB
24th August 2017, 02:38
I mean, seriously. Look at the script. Literally all it does is take the grayscale image, convert it to RGB using the luma as R, G and B, blur it in at least three different ways and run auto white balancing on it. The reason it has so much haloing is that the chroma is constructed from the luma downscaled to first 360x360 and then further to 80x80 pixels, plus different kinds of blurring on top of that.
Got it. So it's pure luck. What's the point of doing it, then? Thanks for the clarification, anyway.
cmon his dad just died, u can always save the bad news for a more appropriate time
edit: typo
Yep, I'm sorry about his father.
color
18th December 2017, 00:06
function ct(clip v)
{##(c) MWilson 2017
v=v.converttoyv12().greyscale()
gs=v.greyscale().separatefields().gaussresize(360,360).converttoyv12().padding(16,16,16,16)
gs
r=gs.F2Quiver(1,3,47,127,0)
g=gs.F2Quiver(1,3,120,127,0)
b=gs.F2Quiver(1,3,126,127,6)
mergergb(b,g,r)
invert()
autogamma()
gaussresize(80,80,p=1)
converttoyv12()
coloryuv(autowhite=true)
gaussresize(width(gs),height(gs))
hqdn3d(0,7,0,14)
mergechroma(gs,last)
padresize(360,360)
weave()
converttorgb()
gaussresize(width(v),height(v))
gammac(-3,show=false)
converttoyv12()
return last
}
This isn't complete, but the output surprised me :)
P.S.
Sorry for being away so long, my father passed away and it's been rough.
P.P.S.
A Quick Video:
I'm trying this but I can not find padresize anywhere?
It is when deactivate that making great colors for some clips I'm using but it looks wierd in the edges.
EDIT: I just found it, took me some time but i found a link from another forum (videohelp)
https://forum.videohelp.com/threads/369143-ResizersPack-MasksPack-PlaygroundPack-SmoothContrast-Logo-mod-functions
http://www.mediafire.com/file/w8sayuutsbgbmvd/ResizersPack4.5.zip
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.