Log in

View Full Version : colorYUV - color correction, remove color cast. autowhite behavior?


xekon
25th January 2013, 06:28
I got an idea after reading this guide: http://www.kanzenshuu.com/forum/viewtopic.php?f=7&t=19448

In that guide it makes a very good point:

The reason we do not want to do a straight white balance is because we do not want to change the overall tonality of the colors; we just want to remove remove the excess color added by the aging but keep the brightness/contrast as close as possible as to what's on the Dragon Box already. We can do any kind of contrast/brightness adjustment later in a more controlled fashion.

The Idea I got was to take the results of ColorYUV(autowhite=true) for a section of a particular frame, and apply that to the entire clip (the same idea from Ashura's guide on kanzenshuu)
Using only ColorYUV would allow me to skip converting to rgb and then back to yv12.

What I do first is find a frame that shows a nice close up of their eye, something that should be white/grey without color. Then get the coordinates within that frame that are just the eye.

http://i1208.photobucket.com/albums/cc361/xekon/idea-1_zps733434c4.png

My question first is about the autowhite feature of colorYUV, does it adjust brightness or contrast? or does it only adjust the color to restore white/greys (hoping just color)

I did a little test (these are the section of eye seen above, cropped and enlarged.):
http://i1208.photobucket.com/albums/cc361/xekon/one_zps9621a058.png

http://i1208.photobucket.com/albums/cc361/xekon/two_zps9f002bf4.png

I can see that the values for Y did not change, so my gut is telling me that the brightness/contrast is not changed, only the colors. because the U & V are for the colors and the Y is for the brightness/intensity as I understand it.
(I am still new to all of this, so please correct me if im wrong)

so If I could expose the results or values that colorYUV applies when running autowhite on one specific frame cropped to a section that is just white like a section of their eyes, then I could take those results and apply them to the entire clip.

I was thinking maybe the same way it shows results with analyze=true it could show the parameters used from the autowhite result.

lansing
25th January 2013, 09:18
regarding the color cast removing process, i would suggest you go with the Adobe Premiere routine using the RGB parade scope. When you're doing it in avisynth, first crop out the part where you think should be white, size doesn't matter, and then apply the HistogramRGBParade here (http://forum.doom9.org/showthread.php?p=1570968#post1570968) to see the rgb parade scope. From there all you need to do is line up rgb values horizontally like this:

(point to image 1)

you can achieve this by using fast color corrector or an RGB curve in premiere. If I'm not mistaken, the fast color corrector acts similar to coloryuv where they both only affect hue without touching luminance, which is not a good choice for removing color cast for anime. You wanted your color corrector to affect luminance, or it will end up something like this (http://www.animemusicvideos.org/guides/avtech31/post-qual.html#color). As seen in that uses of coloryuv, the author kind of got the white balance from blind guess, but then when you look at the shadow area, it all turned to green. RGB curve is a much better choice here:

(point to image 2)

But sadly, i don't know if there's any script that simulate the rgb curve in avisynth.




I've read Ashura's post too a week ago, the color correction that he does was also a blind guess. For removing color cast, you need to first keep notice what version of dragon box you have, see the comparison here:
http://www.youtube.com/watch?v=rVQYcCtoGGA

the US version are brighter than the JP version, so if you got the US version, you need to return it to the jp level range first before removing color cast.

And as for color correction after that, do you have a reference? How do you know if the color is right or wrong? Blind guess is not going to get you anywhere.

Gavino
25th January 2013, 11:55
I can see that the values for Y did not change, so my gut is telling me that the brightness/contrast is not changed, only the colors.
That's correct.

so If I could expose the results or values that colorYUV applies when running autowhite on one specific frame cropped to a section that is just white like a section of their eyes, then I could take those results and apply them to the entire clip.
All autowhite=true does is to set off_u and off_v dynamically for each frame to make the average U and V values equal 127 for that frame. So you could get the average values for a white/grey section from analyse=true and apply the offsets manually.

Taking your example, the average U and V of the 'eye' section are 121.78 and 131.55, so you would use off_u=5.22, off_v=-4.55.

However, as lansing suggests, you may get better results doing the correction in RGB.

lansing
25th January 2013, 19:51
in addition, don't use the auto white balance function, because it will fail most of the time.

For accurate color cast removal, you need to have some kind of graph like the RGB parade and wave form histogram to monitor the color and brightness. Blind guessing out of the sky is not a good practice.

here's a before and after with RGB curve in premiere, white reference from the same screen shot of bulma's eye:

http://www.twistygadget.com/stuff/db/ccguide/photoshop_sml03.png


in comparison to the one Ashura did, the brightness is more reasonable, and you don't need to do all those messes with photoshop to virtualdub import.

xekon
25th January 2013, 21:23
Wow! awesome guys, thanks for all the examples and help, and now I know what autowhite was doing too.

But sadly, i don't know if there's any script that simulate the rgb curve in avisynth.

GiCoCu is supposed to be able to use the curve files created in adobe: http://avisynth.org.ru/docs/english/externalfilters/gicocu.htm

rgb curves from gimp:
GiCoCu("D:\Captures\gimp.cur")

rgb curves from adobe:
GiCoCu("D:\Captures\adobe.amp")

I did read one post saying that GiCoCu may not be accurately reproducing the effect. I will have to see where it was I saw that post.

I tried out HistogramRGBParade(), it shows the issue good, but it sounds like lansing you are doing the correction work right in premier instead of Avisynth.
So is HistogramRGBParade mostly to check your work after making the corrections? and you just check it on multiple frames on white/gray only areas i take it?
http://i1208.photobucket.com/albums/cc361/xekon/parade_zpse077a236.png

lansing
25th January 2013, 23:01
I tried out HistogramRGBParade(), it shows the issue good, but it sounds like lansing you are doing the correction work right in premier instead of Avisynth.
So is HistogramRGBParade mostly to check your work after making the corrections? and you just check it on multiple frames on white/gray only areas i take it?


yes the HistogramRGBParade is used only to monitor the color during the process, you'll eventually remove it after you're done.

and yes i work entirely with premiere when dealing with color correction, because I can do it a lot faster with a gui, and avisynth doesn't have the necessary functions in order for me to do it in yet, like the RGB curve.

LemMotlow
29th January 2013, 04:38
r s

lansing
29th January 2013, 07:48
Mmm, well...not quite a complete fix. Look in the attached "before" image where the leaves in dark shadow are dark green, and the dark side of the palm tree is dark brown. In the attached "after" pick, all the shadow areas are blue. Not good.


that was just a quick example of doing the color cast removal with RGB curve, and I don't know how it originally looks like. You are free to adjust it to your liking, it's pretty easy.:)

lansing
29th January 2013, 10:19
i'll add my color correction attempt (well i think color match seems more appropriate) here for future reference. The colors were not adjusted from blind guesses, i'm referencing from the FUNimation dragon ball z level set bluray, which has the correct color. The source i'm working on is the R2 dragon box.

The color correction process was done by eyes, so some color may still be off. Filters used were a RGB curve, a three-way color corrector, and a HSL color corrector with eight hue to play with. I couldn't figure out an ideal order of workflow though. So if i changed one parameter in the chain, every other parameter after it have to be changed, which is not a good approach. Well i'll figure it out eventually.

The left is the R2 dragon box, the middle is the level set, and the right is my color correction.

(see images)

I think it should be possible to match all the color if given more time. One problem is that the HSL controller plugin i used cause artifacts some time.

LemMotlow
29th January 2013, 13:04
/xxx5

Kisa_AG
20th May 2013, 14:20
Hello!

Here is my function for grey balance correction, which is based on Black/White/Gray Balance picker like in Photoshop or other image editing applications.

Usig of Gray_Balance script has two stages.
########### Stage 1 ############
Finding RGB values for Black/White/Gray Balance.

write a script like this:
YourSource("yourfile")
Gray_Balance(TestMode=True)
Save this script with an ".avs" extension.

You can even use Gray_Balance(131,127,113,TestMode=True) or any other string, because everything is ignored while TestMode=True.
Then open this .AVS script in VirtualDub, find a frame with an object which should be gray. Copy this frame to clipboard (Ctrl+1).
Go to any image edidting application (Photoshop, GIMP, whatever), paste the frame, choose the picker tool and grab the RGB values for the object, which should be gray. (It's better to use the object in semitones, i.e. it's RGB values should be, let's say, somewhere in between 80-180).
Another approach is to use any screen picker like ColorCop to grab RGB values directly from VirtualDub.
It seems that the resualt should be absolutely the same.

########### Stage 2 ############
Applying color correction.
Open script in Notepad again, remove TestMode=True and enter RGB values grabbed in the first stage as RG, GG and BG. E.g.: Gray_Balance(131,127,113).
You can do the same to set Black and White points of the clip, if you want.
Like here:
-----------------------
# RGB for Gray Object
RG=110
GG=113
BG=102

# RGB for Black Point
R0=0
G0=0
B0=0

# RGB for White Point
RW=197
GW=200
BW=180

Gray_Balance(RG,GG,BG,R0,G0,B0,RW,GW,BW, Interlaced=False, Matrix_In="PC.709", Matrix_Out="PC.709", TestMode=False).
------------------------

Now you can open your .AVS script in VirtualDub to check what happend. If everything was done correctly,
then you should see your gray object really perfectly gray. The overall gray balance should also become more correct.
Curves approximation is based on Quadratic Polynomials.
Here are the before/after sample pictures.

xekon
5th December 2014, 03:03
Thanks for sharing this, I am going to try it out :)

supersaiyangoku
2nd February 2015, 05:52
i can't seem to do the color correction of the dragon box can you help?

Stormborec
2nd February 2015, 16:25
I've made (in fact not me) something similar, that works ... similar ... but I don't know, what you want

supersaiyangoku
5th February 2015, 04:18
i don't know what software i need to remove the color cast and make the set i have color accurate. can you please help the kanzenshuu forum page on this didn't seem to help the software didn't work can you help me?

Overdrive80
6th February 2015, 08:58
IMHO, I dont think that this task is too easy, and you never get original colorimetry. Why?

Because, Toei shooting the films applying some type of photografic filter (look left border, you can see original colorimetry):

http://s6.postimg.org/m5aj35hj5/12_0.png (http://s6.postimg.org/m5aj35hj5/12_0.png)

http://s6.postimg.org/nj25yggsh/13_0.png (http://s6.postimg.org/nj25yggsh/13_0.png)

You can use on Premiere, "Lumetri Looks-->Temp" to reduce colours too yellowed

- Without filter cold

http://s27.postimg.org/7c8u1veo3/Captura_de_pantalla_2015_02_06_08_52_33.png (http://postimg.org/image/6zhfvowe7/full/)

- With filter cold, you can play with mask for setting nivel of opacity

http://s27.postimg.org/cl8gdhmgz/Captura_de_pantalla_2015_02_06_08_52_38.png (http://postimg.org/image/atfhil33z/full/)

Too you can use more filters like "Corrección rápida", in english I dont know like premiere name it:

http://s23.postimg.org/wsr7ibb2j/Captura_de_pantalla_2015_02_06_09_05_32.png (http://postimg.org/image/sjmhg57t3/full/)

Frame without cropping:

http://s2.postimg.org/rfkxtx6cp/Intouch_without_crop.png (http://postimage.org/)

supersaiyangoku
8th February 2015, 02:50
you didn't really answer my question what tools do i need to do this color correction? also what are talking about you can never get the right color is there anyway or at the least get them close enough to them? please answer both questions.

Overdrive80
8th February 2015, 07:42
Yes, I answered to your question:

1. Lansing and I, have recommended to use Adobe Premiere when I said: "You can use on Premiere, "Lumetri Looks-->Temp" to reduce colours too yellowed". However, you are who should choose one program for working (Adobe After effects, Sony Vegas, Blackmagic Davinci, avisynth, larger etc...)

2. For getting them close enough to them, you need original broadcasting material for doing a comparison. Have you this material??

supersaiyangoku
8th February 2015, 19:19
answer to number 2 no but do you know where i can find any info on this? also what's with color being different on the sides? answer both questions.

LemMotlow
9th February 2015, 20:32
answer to number 2 no but do you know where i can find any info on this? also what's with color being different on the sides? answer both questions.The color on the left side border of the images was explained in post #16 (http://forum.doom9.org/showpost.php?p=1708496&postcount=16) at the top of the post. I don't think that comparing the original disc recording will help if you don't know what a color filter is.

In Avisynth use "ColorYUV(autowhite=true)" or AutoAdjust (http://forum.doom9.org/showthread.php?t=167573&highlight=autoadjust).

In VirtualDub use ColorMill (http://fdump.narod.ru/rgb.htm).

No one can answer your question with any detail because no one knows what your video looks like. Just saying that you want to correct a "blue color balance" doesn't tell us anything. The simple answer is to reduce the amount of blue in the video. But we don't have a sample of your video and you won't tell us what software you use, so you can get only very general answers.

Richard1485
12th January 2016, 18:56
I apologize to the moderator for bumping an old-ish thread, but I cannot find a thread for Gray_Balance() anywhere else and didn't want to start one on behalf of its author. Moreover, the thread's been bumped relatively recently anyway.

Gray_Balance() is fantastic, but I have run across a problem. It seems to blow out the whites. :confused: I do ensure that I input the matrices properly. Here is a histogram of the video before (left) and after (right).

http://i.imgur.com/ytI76M0.png

(Ignore the strange-looking square pattern on the top right. I forgot to uncomment Info() when making the screenshot. :o)

Perhaps the SmoothCustom() part of the function is causing this. I can see from looking at the code that all the color-space conversions are, of course, correct. I am using version 1.0 from 2013. Is there a later version?

Does the filter work in RGB internally? If so, it would be great to have a version that outputs RGB.

I would appreciate any help. This function is very useful.

raffriff42
13th January 2016, 02:18
The filter does work in RGB internally. You can avoid the conversion by a small change to Gray_Balance.avsi (http://forum.doom9.org/showthread.php?p=1629321#post1629321): ...
RW = default(RW, 255) # RW Default
GW = default(GW, 255) # GW Default
BW = default(BW, 255) # BW Default

Last=Clp
(Interlaced == True && Matrix_In == "Rec709") ? Clp.ConvertToRGB24...
(Interlaced == True && Matrix_In == "PC.709") ? Clp.ConvertToRGB24...
(Interlaced == True && Matrix_In == "Rec601") ? Clp.ConvertToRGB24...
(Interlaced == True && Matrix_In == "PC.601") ? Clp.ConvertToRGB24...
...

Now call the function with an RGB24 source, set Matrix_In and Matrix_Out to nonexistent values, and no conversions will occur:Gray_Balance(..., Matrix_In="NONE", Matrix_Out="NONE")

BTW, this script was written for SmoothAdjust (http://avisynth.nl/index.php/SmoothAdjust#Levels_and_Chroma) v2.xx. For SmoothAdjust v.3.xx, you need to replace "smooth=100" with "interp=100"
-- or delete ", smooth=100, dither=50" altogether, since these are the default arguments to SmoothCustom anyway.

------------------------------------------------------------------------
Re: blown out whites, you are probably selecting a color in the picture that is not truly white. This happened to me just now:

Attempting to select a "white" sample; it's not white enough (white luma should be 255)
https://www.dropbox.com/s/8nju0p6ky0ko48h/GrayBalance-setup02%20white.jpg?raw=1

Attempting to select a "gray" sample; it's too close to "white" (gray luma should be 128)
https://www.dropbox.com/s/v3ux24wtm2b5s6d/GrayBalance-setup00%20gray.jpg?raw=1

"Corrected" result:
https://www.dropbox.com/s/ccr8j2fu9b8z3gr/GrayBalance-test02%20corr%3Dbad%20420x320.jpg?raw=1

Ouch, not so nice. I would suggest "faking" better gray & white levels (scaling your sample values), like so:ImageSource("r2cc lvl compare 3_crop.jpg")
ConvertToRGB24 ## RGB24 required with Matrix_XXX="NONE"
#return Gray_Balance(TestMode=true) ## test mode
gray_adj = 128.0 / 197 [* 2nd number is actual luma value of gray sample *]
white_adj= 255.0 / 219 [* 2nd number is actual luma value of white sample *]
Gray_Balance(
\ gray_adj*197, gray_adj*181, gray_adj*192, [* gray sample *]
\ 22, 1, 6, [* black sample *]
\ white_adj*215, white_adj*207, white_adj*196, [* white sample *]
\ Matrix_In="NONE",
\ Matrix_Out="NONE"
\ )
#Info


Input as RGB:
https://www.dropbox.com/s/8udgpc2cf5ks3dw/GrayBalance-test01%20in%3DRGB%20420x320.jpg?raw=1

Corrected result with "fake" gray and white:
https://www.dropbox.com/s/c60nd9e1497r5zq/GrayBalance-test03%20corr%3Dgood%20420x320.jpg?raw=1

Richard1485
13th January 2016, 15:13
You can avoid the conversion by a small change to Gray_Balance.avsi.

Thanks! That's very useful.

BTW, this script was written for SmoothAdjust v2.xx. For SmoothAdjust v.3.xx, you need to replace "smooth=100" with "interp=100"
-- or delete ", smooth=100, dither=50" altogether, since these are the default arguments to SmoothCustom anyway.

Ah, yes. I had worked out that SmoothAdjust() 3.xx did not work and had reverted to 2.xx. It's useful to be able to make it work with 3.xx. :D

Re: blown out whites, you are probably selecting a color in the picture that is not truly white...
...I would suggest "faking" better gray & white levels (scaling your sample values), like so:

I'll give that a try. I had been working round the blown-out whites by calling MergeChroma() afterwards, but that was not completely satisfactory, because of (I assume) rounding errors resulting from the YUV<->RGB conversion.

EDIT: It looks as if I might have to adjust the saturation after calling Gray_Balance().