You are on page 1of 4

% Colour Image Enhancement by Virtual Histogram Approach % M,N the width ana Height of the image %Initial Step

clc; img=imread('royal-baby.jpg'); % Read Image info=imfinfo('royal-baby.jpg'); % Get Information of Image, %Information about graphics file figure(2),subplot(4,2,1),imshow(img); title('Original RGB Image'); [M N]=size(img); % Get Size of Image %Step 1: %In RGB Colour channel,each individual histogram entry % Extract the individual red, green, and blue color channels from RBG image % Using the individual red, green, and blue color channels value,draw the % histogram for each channel %For example, the red, green, and blue color %components of the pixel (10,5) are store %in RGB(10,5,1), RGB(10,5,2),and RGB(10,5,3),respectively. red = img(:, :, 1); figure(2),subplot(4,2,3),imshow(red); title('Red Channel Image'); figure(2),subplot(4,2,4),imhist(red); title('Red Channele Histogram'); [rcounts,r]=imhist(red); green = img(:, :, 2); figure(2),subplot(4,2,5),imshow(green); title('Green Channel Image'); figure(2),subplot(4,2,6),imhist(green); title('Green Channele Histogram'); [gcounts,g]=imhist(green); blue = img(:, :, 3); figure(2),subplot(4,2,7),imshow(blue); title('Blue Channel Image'); figure(2),subplot(4,2,8),imhist(blue);

title('Blue Channele Histogram'); [bcounts,b]=imhist(blue); %Step 2: % Extract the luma channel from YCRCB image YCBCR = rgb2ycbcr(img); %Conver RGB Image To YCBCR Image figure(3),subplot(2,2,1),imshow(YCBCR); % Display YCBCR Image title('YCBCR Image'); Y = YCBCR(:, :, 1); figure(3);subplot(2,2,2),imshow(Y); title('YCRCB Y Channel Image'); figure(3);subplot(2,2,3),imhist(Y); title('YCRCB Y Channele Histogram'); [ycounts,l]=imhist(Y); %Move Histogram Value ihistr=imhist(red); ihistg=imhist(green); ihistb=imhist(blue); ihistl=imhist(Y); % Step 3: %Cumulative Distributive Histogram cr=cumsum(ihistr); cg=cumsum(ihistg); cb=cumsum(ihistb); cy=cumsum(ihistl);

% Edge Enhancement for R,G,B Channel Using Laplacian Filter % bw=edge(blue); % imshow(bw); H= fspecial('laplacian',.1);

lred = imfilter(red,H,'conv'); figure(4),subplot(3,1,3); imshow(lred); title(' Red Channel Image Edge'); lgreen = imfilter(green,H,'conv'); figure(4),subplot(3,1,2);imshow(lgreen); title(' Green Channel Image Edge');

lblue= imfilter(blue,H,'conv'); figure(4),subplot(3,1,1);imshow(lblue); title(' blue Channel Image Edge'); %For verification Purpose [row,column]=size(lred); [row1,column1]=size(lgreen); [row2,column2]=size(lblue);

%Sum Of RGB channels for i=1:row for j=1:column s2(i,j)=lred(i,j)+lgreen(i,j)+lblue(i,j); end; end; % Display the RGB channel figure(5),subplot(1,2,1),imshow(s2); title('Sum of all channels'); %Apply the threshold thres=3; for i=1:row for j=1:column if s2(i,j)>thres s2(i,j)=255; else s2(i,j)=0; end

end end % Display the threshold Image figure(5),subplot(1,2,2),imshow(s2); title('Applying Threshold');

//This the doubt portion why i am asking this is //Next they calculated Hyv=card{c/xy(c)=p,c belongs to C,c blongs tos2} here xy represents Y that is luma component(histogram of luma) c represents pixel in a image C contain image width and height(full pixel information) s2 contain threshold applied value. so i used this coding Y = YCBCR(:, :, 1); figure(3);subplot(2,2,2),imshow(Y); title('YCRCB Y Channel Image'); figure(3);subplot(2,2,3),imhist(Y); title('YCRCB Y Channele Histogram');

You might also like