Lets Learn together... Happy Reading

" Two roads diverged in a wood, and I,
I took the one less traveled by,
And that has made all the difference "-Robert Frost

YIQ Image to RGB Image

MATLAB code:
%YIQ to RGB

%R=Y+0.956*I+0.621*Q
%G=Y-0.272*I-0.647*Q
%B=Y-1.106*I+1.703*Q
RGB=uint8(zeros(size(YIQ)));
for i=1:size(YIQ,1)
    for j=1:size(YIQ,2)
          RGB(i,j,1)=YIQ(i,j,1)+0.956*YIQ(i,j,2)+0.621*YIQ(i,j,3);
          RGB(i,j,2)=YIQ(i,j,1)-0.272*YIQ(i,j,2)-0.647*YIQ(i,j,3);
          RGB(i,j,3)=YIQ(i,j,1)-1.106*YIQ(i,j,2)+1.703*YIQ(i,j,3);
    end
end

figure,imshow(RGB);
title('RGB Image');

like button Like "IMAGE PROCESSING" page

RGB Image to YIQ Image

YIQ  builds the basis for the NTSC (National Television System Commitee) format.
The Component division of YIQ :
Y=0.30R+0.59G+0.11B
I=0.60R-0.28G-0.32B
Q=0.21R-0.52G+0.31B


MATLAB code:
Im=imread('peppers.png');


figure,imshow(Im);
title('Original Image')

%y=0.2989 * R + 0.5870 * G + 0.1140 * B 

%I=0.60*R - 0.28*G-0.32*B
%Q=0.21*R -0.52*G+0.31*B
YIQ=uint8(zeros(size(Im)));
for i=1:size(Im,1)
    for j=1:size(Im,2)
        YIQ(i,j,1)=0.2989*Im(i,j,1)+0.5870*Im(i,j,2)+0.1140*Im(i,j,3);
        YIQ(i,j,2)=0.596*Im(i,j,1)-0.274*Im(i,j,2)-0.322*Im(i,j,3);
        YIQ(i,j,3)=0.211*Im(i,j,1)-0.523*Im(i,j,2)+0.312*Im(i,j,3);
    end
end
figure,imshow(YIQ);
title('YIQ Image');

like button Like "IMAGE PROCESSING" page

RGB Image to Grayscale Image without using rgb2gray function

A gray-scale image is composed of different shades of grey color.
A true color image can be converted to a gray scale image by preserving the luminance(brightness) of the image.

Here the RGB image is a combination of RED, BLUE AND GREEN colors.
The RGB image is 3 dimensional. In an image ,
at a particular position say  ( i,j)
Image(i,j,1) gives the value of RED pixel.
Image(i,j,2) gives the value of BLUE pixel.
Image(i,j,3) gives the value of GREEN pixel.
The combination of these primary colors are normalized with R+G+B=1;
This gives the neutral white color.

The grayscale image is obtained from the RGB image by combining 30% of RED , 60% of GREEN and 11% of BLUE.
This gives the brightness information of the image. The resulting image will be two dimensional. The value 0 represents black and the value 255 represents white. The range will be between black and white values.


MATLAB CODE:

Im=imread('peppers.png');

figure,imshow(Im);
title('Original Image');

%0.2989 * R + 0.5870 * G + 0.1140 * B
GIm=uint8(zeros(size(Im,1),size(Im,2)));
for i=1:size(Im,1)
      for j=1:size(Im,2)
          GIm(i,j)=0.2989*Im(i,j,1)+0.5870*Im(i,j,2)+0.1140*Im(i,j,3);
      end
end

%Without using for loop:
%GIm=0.2989*Im(:,:,1)+0.5870*Im(:,:,2)+0.1140*Im(:,:,3);


figure,imshow(GIm);
title('Grayscale Image');











Check out : Partially colored gray scale image - MATLAB CODE
like button Like "IMAGE PROCESSING" page
Previous Post Next Post Home
Google ping Hypersmash.com