Re: Color balance in YUV/YCbCr domain
From: Dave Martindale (davem_at_cs.ubc.ca)
Date: 06/04/04
- Next message: Medical Imaging Careers: "RADIOGRAPHY.COM.AU"
- Previous message: Jonathon: "Re: Finding Position of Maximum of Surface"
- In reply to: Jason: "Color balance in YUV/YCbCr domain"
- Next in thread: IlGab: "Re: Color balance in YUV/YCbCr domain"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 4 Jun 2004 05:27:33 +0000 (UTC)
jason@cintec.cuhk.edu.hk (Jason) writes:
>In RGB domain, I can do "Auto Level" to get a color balanced photo by
>working on R, G and B histogram independently. i.e. to widen the
>dynamic range of each color channel to 0-255.
That isn't colour balancing. It might work that way if the brightest
object in the image also happens to be white, but not otherwise.
Auto levels messes with the black level too, which isn't correct if
there isn't anything truly black in the image.
Colour balancing is selecting an area in the image that you know is
colour-neutral, and then scaling the RGB values to make that area
neutral.
>However, in YUV/YCbCr domain, how can I do color balancing? Any work
>around or simple method to do this?
>I tried to derive a color balancing formula from RGB<->YUV matrix.
>However, it seems that direct transformation is very complicated.
If you know what scaling factors are needed to colour-balance the RGB
image, you can write the transformation that maps RGB to RGB' as a 3x3
matrix which is diagonal. You already know the matrix that maps
RGB->YUV and its inverse. So the operation that colour-balances a YUV
image can be described as taking each YUV value, converting to RGB
using the YUV->RGB matrix, applying the colour-balancing matrix, and
then applying the RGB->YUV matrix to convert back to YUV. If you
multiply these three 3x3 matrices together, you get a single 3x3 matrix
that performs the operation on YUV values, yielding a YUV result.
Multiplying three 3x3 matrices together is *not* complicated.
Now, you should be able to figure out the matrix needed working entirely
in YUV. The result of the matrix multiplication above has 9 numbers but
only 3 degrees of freedom, because there were only 3 variables total in
the 3 original matrices. For an area in the input image that you know
is colour-neutral, the input pixel code (Y, U, V) should map to an
output code of (Y, 0, 0). In other words, the luminance should not
change, and the two colour difference components should become zero.
This gives you 3 linear equations in 3 unknowns, which should be easily
solvable. And that gives you the full 3x3 matrix needed to do the
colour balancing.
Dave
- Next message: Medical Imaging Careers: "RADIOGRAPHY.COM.AU"
- Previous message: Jonathon: "Re: Finding Position of Maximum of Surface"
- In reply to: Jason: "Color balance in YUV/YCbCr domain"
- Next in thread: IlGab: "Re: Color balance in YUV/YCbCr domain"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|