Colour Image
Processing.
Extracting
Red Green Blue Components of Given image
clearall;
closeall;
clc;
a
= imread('Arjunsunn2.jpg');
[row
col dim] = size(a);
r
= a(:,:,1);
g
= a(:,:,2);
b
= a(:,:,3);
mat
= zeros(row,col);
r1
= cat(3,r,mat,mat);
g1
= cat(3,mat,g,mat);
b1
= cat(3,mat,mat,b);
figure(1)
image(a),
colorbar; title('ORIGINAL
IMAGE');
figure(2)
image(r1),
colormap([[0:1/255:1]', zeros(256,1), zeros(256,1)]), colorbar;
title('RED COMPONENT OF COLOUR IMAGE');
figure(3)
image(g1),
colormap([zeros(256,1),[0:1/255:1]', zeros(256,1)]), colorbar;
title('GREEN COMPONENT OF COLOUR IMAGE');
figure(4)
image(b1),
colormap([zeros(256,1), zeros(256,1), [0:1/255:1]']), colorbar;
title('BLUE COMPONENT OF COLOUR IMAGE');
Histogram
of Luminance, Hue and Saturation
Components of Given image
clearall;
closeall;
clc;
a
= imread('Arjunsunn2.jpg');
a1
= rgb2gray(a);
[row
col dim] = size(a)
r
= a(:,:,1);
g
= a(:,:,2);
b
= a(:,:,3);
mat
= zeros(row,col);
r1
= cat(3,r,mat,mat);
g1
= cat(3,mat,g,mat);
b1
= cat(3,mat,mat,b);
subplot(2,2,1)
imhist(a1);
title('HISTOGRAMS OF GIVEN IMAGE');
subplot(2,2,2)
imhist(r);
title('HISTOGRAM OF RED PLANE OF
GIVEN IMAGE');
subplot(2,2,3)
imhist(g);
title('HISTOGRAM OF GREEN PLANE OF
GIVEN IMAGE');
subplot(2,2,4)
imhist(b);
title('HISTOGRAM OF BLUE PLANE OF
GIVEN IMAGE');
Extracting
Hue, Saturation and Value Components of
Given image
clearall;
closeall;
clc;
a
= imread('sunatom.jpg');
[row
col dim] = size(a);
hsv
= rgb2hsv(a);
h
= hsv(:,:,1);
s
= hsv(:,:,2);
v
= hsv(:,:,3);
c
= input('enter the
value of C : ')
v1
= c.*(log(1+v));
subplot(2,3,2)
imshow(h),
colormap, title('HUE PLANE OF
IMAGE');
subplot(2,3,5)
imshow(s),
title('SATURATION PLANE OF IMAGE');
subplot(2,3,3)
imshow(v),
title('VALUE PLANE OF IMAGE');
subplot(2,3,6)
imshow(v1),
title('logarithmic transform of third
band of IMAGE');
subplot(2,3,4)
imshow(hsv),
title('HSV image converted from RGB
image');
subplot(2,3,1)
imshow(a),
title('ORIGINAL IMAGE');
Histogram
of Luminance, Hue and Saturation
Components of Given image
clearall;
closeall;
clc;
a
= imread('sunatom.jpg');
[row
col dim] = size(a);
hsv
= rgb2hsv(a);
h
= hsv(:,:,1);
s
= hsv(:,:,2);
v
= hsv(:,:,3);
c
= input('enter the value
of C : ')
v1
= c.*(log(1+v));
subplot(2,3,2)
imhist(h),
colormap, title('HISTORGRAM OF
HUE PLANE OF IMAGE');
subplot(2,3,5)
imhist(s),
title('HISTORGRAM OF SATURATION PLANE
OF IMAGE');
subplot(2,3,3)
imhist(v),
title('HISTORGRAM OF VALUE PLANE OF
IMAGE');
subplot(2,3,6)
imhist(v1),
title('HISTORGRAM OF logarithmic
transform of third band of IMAGE');
subplot(2,3,4)
imhist(rgb2gray(hsv)),
title('HISTORGRAM OF HSV image
converted from RGB image');
subplot(2,3,1)
imhist(rgb2gray(a)),
title('HISTORGRAM OF ORIGINAL IMAGE');
Extracting
Luminance, Hue and Saturation Components
of Given image
clearall;
closeall;
clc;
a
= imread('sunatom.jpg');
[row
col dim] = size(a);
%
r = a(:,:,1);
%
g = a(:,:,2);
%
b = a(:,:,3);
%
y = 0.299*r + 0.587*g + 0.114*b;
%
i = 0.596*r - 0.274*g - 0.322*b;
%
q = 0.211*r - 0.523*g + 0.312*b;
ntsc
= rgb2ntsc(a);
y
= ntsc(:,:,1);
i
= ntsc(:,:,2);
q
= ntsc(:,:,3);
c
= input('enter the
value of C : ')
q1
= c.*(log(1+(q)));
subplot(2,3,2)
imshow(y),
colormap, title('LUMINANCE
PLANE OF IMAGE');
subplot(2,3,5)
imshow(i),
title('HUE PLANE OF IMAGE');
subplot(2,3,3)
imshow(q),
title('SATURATION PLANE OF IMAGE');
subplot(2,3,6)
imshow(q1),
title('logarithmic transform of third
band of IMAGE');
subplot(2,3,4)
imshow(a),
title('NTSC image, converted from RGB
image');
subplot(2,3,1)
imshow(a),
title('ORIGINAL IMAGE');
Histogram
of Luminance, Hue and Saturation
Components of Given image
clearall;
closeall;
clc;
a
= imread('sunatom.jpg');
[row
col dim] = size(a);
%
r = a(:,:,1);
%
g = a(:,:,2);
%
b = a(:,:,3);
%
y = 0.299*r + 0.587*g + 0.114*b;
%
i = 0.596*r - 0.274*g - 0.322*b;
%
q = 0.211*r - 0.523*g + 0.312*b;
ntsc
= rgb2ntsc(a);
y
= ntsc(:,:,1);
i
= ntsc(:,:,2);
q
= ntsc(:,:,3);
c
= input('enter the
value of C : ')
q1
= c.*(log(1+(q)));
subplot(2,3,2)
imhist(y),
title('LUMINANCE PLANE OF IMAGE');
subplot(2,3,5)
imhist(i),
title('HUE PLANE OF IMAGE');
subplot(2,3,3)
imhist(q),
title('SATURATION PLANE OF IMAGE');
subplot(2,3,6)
imhist(q1),
title('logarithmic transform of third
band of IMAGE');
subplot(2,3,4)
imhist(rgb2gray(ntsc)),
title('NTSC image, converted from RGB
image');
subplot(2,3,1)
imhist(rgb2gray(a)),
title('ORIGINAL IMAGE');
clearall;
closeall;
clc;
a1
= imread('Arjuncapture.JPG');
a
= double(a1);
[row,col,dim]
= size(a);
r
= a(:,:,1)/256;
g
= a(:,:,2)/256;
b
= a(:,:,3)/256;
c
= 1-r;
m
= 1-g;
y
= 1-b;
c1
= input('enter the
value of C : ')
y1
= c.*(log(1+(y)));
subplot(2,3,2)
imagesc(c), title('CYAN
PLANE OF IMAGE');
subplot(2,3,5)
imagesc(m),
title('MAGENTA PLANE OF IMAGE');
subplot(2,3,3)
imagesc(y),
title('YELLOW PLANE OF IMAGE');
subplot(2,3,6)
imagesc(y1),
title('logarithmic transform of third
band of IMAGE');
subplot(2,3,4)
imagesc(imcomplement(a1)),
title('CMY image, converted from RGB
image');
subplot(2,3,1)
imagesc(a1),
title('ORIGINAL IMAGE');
Histogram
of Cyan, Magenta and Yellow Components
of Given image
clearall;
closeall;
clc;
a1
= imread('Arjuncapture.JPG');
a
= double(a1);
[row,col,dim]
= size(a);
r
= a(:,:,1)/256;
g
= a(:,:,2)/256;
b
= a(:,:,3)/256;
c
= 1-r;
m
= 1-g;
y
= 1-b;
c1
= input('enter the
value of C : ')
y1
= c.*(log(1+(y)));
subplot(2,3,2)
imhist(c), title('CYAN
PLANE OF IMAGE');
subplot(2,3,5)
imhist(m),
title('MAGENTA PLANE OF IMAGE');
subplot(2,3,3)
imhist(y),
title('YELLOW PLANE OF IMAGE');
subplot(2,3,6)
imhist(y1),
title('logarithmic transform of third
band of IMAGE');
subplot(2,3,4)
imhist(rgb2gray(imcomplement(a1))),
title('CMY image, converted from RGB
image');
subplot(2,3,1)
imhist(rgb2gray(a1)),
title('ORIGINAL IMAGE');
Extracting Y, Cb, Cr Components of Given image
clearall;
closeall;
clc;
a
= imread('Arjunleaves.jpg');
[row
col dim] = size(a);
yCbCr
= rgb2ycbcr(a);
y
= yCbCr(:,:,1);
Cb
= yCbCr(:,:,2);
Cr
= yCbCr(:,:,3);
%
y = 16 + ((65.481*r)+(128.553*g)+(24.966*b));
%
Cb = 128 + ((-37.797*r)-(74.203*g)+(112*b));
%
Cr = 128 + ((112*r)-(93.786*g)-(18.214*b));
c
= input('enter the
value of C : ')
Cr1 =
c.*(log(1+double(Cr)));
subplot(2,3,2)
imagesc(y), title('Y
Component OF IMAGE');
subplot(2,3,5)
imagesc(Cb),
title('Cb Component OF IMAGE');
subplot(2,3,3)
imagesc(Cr),
title('Cr component OF IMAGE');
subplot(2,3,6)
imagesc(Cr1),
title('logarithmic transform of third
band of IMAGE');
subplot(2,3,4)
imagesc(yCbCr),
title('YCbCr image, converted from
RGB image');
subplot(2,3,1)
imagesc(a),
title('ORIGINAL IMAGE');
Histogram of Y, Cb, Cr Components of Given image
clearall;
closeall;
clc;
a
= imread('Arjunleaves.jpg');
[row
col dim] = size(a);
yCbCr
= rgb2ycbcr(a);
y
= yCbCr(:,:,1);
Cb
= yCbCr(:,:,2);
Cr
= yCbCr(:,:,3);
%
y = 16 + ((65.481*r)+(128.553*g)+(24.966*b));
%
Cb = 128 + ((-37.797*r)-(74.203*g)+(112*b));
%
Cr = 128 + ((112*r)-(93.786*g)-(18.214*b));
c
= input('enter the
value of C : ')
Cr1
= c.*(log(1+double(Cr)));
subplot(2,3,2)
imhist(y), title('Y
Component OF IMAGE');
subplot(2,3,5)
imhist(Cb),
title('Cb Component OF IMAGE');
subplot(2,3,3)
imhist(Cr),
title('Cr component OF IMAGE');
subplot(2,3,6)
imhist((Cr)),
title('logarithmic transform of third
band of IMAGE');
subplot(2,3,4)
imhist(rgb2gray(yCbCr)),
title('YCbCr image, converted from
RGB image');
subplot(2,3,1)
imhist(rgb2gray(a)),
title('ORIGINAL IMAGE');
Extracting Hue, Saturation and Intensity Components of Given image
clc;
clearall;
closeall;
a1
= imread('sunn2.jpg');
a
= double(a1);
[row
col dim] = size(a);
red
= a(:,:,1);
[row
col] = size(red);
green
= a(:,:,2);
blue
= a(:,:,3);
numer
= 0.5*((red-green)+(red-blue));
deno
= sqrt((red-green).^2+(red-blue).*(green-blue));
theta
= acos(numer./(deno+eps));
for x=1:1:row
for y=1:1:col
if green(x,y)<blue(x,y)
H(x,y) = (2*pi)-theta(x,y);
else
H(x,y) = theta(x,y);
end
end
end
numer
= min(min(red,green),blue);
deno
= red+green+blue;
deno(deno==0)=eps;
S=1-(3.*numer./deno);
I=(red+green+blue)/3;
subplot(2,2,1)
imagesc((a1));
title('ORIGINAL IMAGE');
subplot(2,2,2)
imagesc(H);
title('HUE COMPONENT OF IMAGE');
subplot(2,2,3)
imagesc(S);
title('SATURATION COMPONENT OF IMAGE');
subplot(2,2,4)
imagesc(I);
title('INTENSITY COMPONENTS OF IMAGE');
No comments:
Post a Comment