Monday, 4 March 2013

RGB to YUV and YUV to RGB color space conversion

RGB  to YUV conversion is and YUV to RGB conversion is so simple.There are two different formulas for these two operation:-

RGB to YUV Conversion

Y  =ceil ( (0.257 * R) + (0.504 * G) + (0.098 * B) + 16)

V = ceil ((0.439 * R) - (0.368 * G) - (0.071 * B) + 128)

U = ceil(-(0.148 * R) - (0.291 * G) + (0.439 * B) + 128)

YUV to RGB Conversion

B =ceil (1.164(Y - 16)+ 2.018(U - 128))

G =ceil (1.164(Y - 16) - 0.813(V - 128) - 0.391(U - 128))

R =ceil (1.164(Y - 16) + 1.596(V - 128)) 

 Here is the input and output images for this program:


RGB to YUV Conversion:-

Input RGB Image


Output YUV Image






YUV to RGB Conversion:-


Input YUV Image
                                       



Output RGB Image





Sunday, 3 March 2013

RGB to TSL and RGB to noramalized RGB

Here we need to discuss some color space conversion which are helpful in face detection .In this program we take 24-Bit color image as an input.

RGB to TSL :- RGB to TSL conversion in which we use following formula :-


T =
\begin{cases}
\frac{1}{2\pi} \arctan{\frac{r'}{g'}} + \frac{1}{4}, & \mbox{if}~g'>0 \\
\frac{1}{2\pi} \arctan{\frac{r'}{g'}} + \frac{3}{4}, & \mbox{if}~g'<0 \\
0,                                         & \mbox{if}~g'=0 \\
\end{cases}
S = \sqrt{\frac{9}{5}\left( r'^2 + g'^2 \right)}
L = 0.299R + 0.587G + 0.114B
where:
r' = r - \tfrac{1}{3}*255
g' = g - \tfrac{1}{3}*255
r = \tfrac{R}{R+G+B}*255
g = \tfrac{G}{R+G+B}*255

Here is the input  and output image for this program:-
Input Color Image 

Output TSL Image


RGB to noramalized RGB:-In this approach the each normalized RGB channel is formed by the dividing the respective  channel with the sum of all three channel values and further multiplying it by 255.Here is the input and output image for this program:-
Input color image

Normalized RGB image