You are on page 1of 4

Dgital Image Processing

Lab Week-1
17BEC1085

Aditya Harichandar

sampe image:

1-a) Basic array operations on the image (RGB PLANES)


clc % R,G,B plane spliiting of the image
clear all
I=imread('Lenna.jpg');

%rows and columns in image

r=size(I,1);
c=size(I,2);

%creating zero matrices

R=zeros(r,c,3); %3 needed coz of colour mapping issues


G=zeros(r,c,3);
B=zeros(r,c,3);

%declaring seperate rgb planes

R(:,:,1)=I(:,:,1);
G(:,:,2)=I(:,:,2);
B(:,:,3)=I(:,:,3);

figure(1);
imshow(uint8(R));
figure(2);
imshow(uint8(G));
figure(3);
imshow(uint8(B));

Output

2)Array operations on image- upside down, left to right


// horizontal flip

a=imread('Lenna.jpg'); %horizontal

[m,n,p]=size(a)
b=zeros(m,n)
b=a(end:-1:1,:,:)
figure(1);
imshow(uint8(a));

figure(2);
imshow(uint8(b));
Output

//vertical flip

a=imread('Lenna.jpg');
%vertical

[m,n,p]=size(a)
b=zeros(m,n)
b=a(:,end:-1:1,:)
figure(1);
imshow(uint8(a));

figure(2);
imshow(uint8(b));

Output

3) Bitplane Slicing
clc
clear all
a = rgb2gray(imread('Lenna.jpg'));
[m,n] = size(a);
b1 = [];
b2 = [];
b3 = [];
b4 = [];
b5 = [];
b6 = [];
b7 = [];
b8 = [];
for i = 1:m
for j = 1:n
t = de2bi(a(i,j),8,'left-msb');
b1(i,j) = t(1,1);
b2(i,j) = t(1,2);
b3(i,j) = t(1,3);
b4(i,j) = t(1,4);
b5(i,j) = t(1,5);
b6(i,j) = t(1,6);
b7(i,j) = t(1,7);
b8(i,j) = t(1,8);

end
end
imshow(a)
figure
imshow(b1)
figure
imshow(b2)
figure
imshow(b3)
figure
imshow(b4)
figure
imshow(b5)
figure
imshow(b6)
figure
imshow(b7)
figure
imshow(b8)

Output:

You might also like