Pavan Kumar Sharma
Pavan Kumar Sharma
Pavan Kumar Sharma
APPLICATIONS
INDEX
Exp. Page
Program
No. No.
4 Create chessboard. 2
Commands:-
Implement:-
Img = imread(’cameraman.tif’);
imshow(Img);
Output:-
Experiment -3
Implement:-
%horizontal strips
hor_strip = uint8(zero_arr);
hor_strip(2:2:10,:) = 255;
subplot(1,2,1),imshow(hor_strip)
%vertical strip
ver_strip = uint8(zero_arr);
ver_strip(:,2:2:20) = 255; % array(st_row:diff:end_row,st_col:diff:end_col)
subplot(1,2,2),imshow(ver_strip)
Output:-
Experiment -4
Implement:-
Output:-
Experiment -5
Objective:- Read the colored image and check attributes.
Implement:-
i1 = imread ("peppers.png");
r = i1 (:,:,1);
g = i1(:,:,2);
b = i1(:,:,3);
subplot(2,2,1);
imshow (i1);
subplot(2,2,2);
imshow (r);
subplot(2,2,3);
imshow (g);
subplot(2,2,4);
imshow (b);
Output:-
Experiment -6
Objective:- Perform Log Transformation on Image.
Implement:-
img = imread('cameraman.tif');
subplot(1,2,1), imshow(img)
Output:-
Experiment -7
Objective:- Perform Negative Transformation on Image.
Implement:-
img = imread('cameraman.tif');
%Negative Transformation - 1
neg=255-img;
subplot(1,2,1),imshow(img)
%Negative Transformation - 2
neg=img;
for row=1:size(img,1)
for col=1:size(img,2)
neg(row,col,:)=255-img(row,col,:);
end
end
subplot(1,2,2),imshow(neg)
Output:-
Experiment -8
Objective:- Perform Power Log Transformation on Image.
Implement:-
img = imread('cameraman.tif');
subplot(1,2,1), imshow(img)
Output:-
Experiment -9
Objective:- Perform Gray Level Slicing with and without background.
Implement:-
Output:-
Experiment -10
Objective:- Perform Histogram Equalization on image.
Implement:-
img=imread('cameraman.tif');
[n,m]=size(img);
%n-->row
%m-->col
for i=1:256
t(i,3)=t(i,2)/(256*256);
end
t(1,4)=t(1,3)
for i=2:256
t(i,4)=t(i-1,4)+t(i,3);
end
for i=1:256
t(i,5)=t(i,4)*255;
end
for i=1:256
t(i,6)=round(t(i,5));
end
for i=1:256s(i,1)=i-1;
s(i,2)=0;
end
for i=1:256
pix=t(i,6)+1;
s(pix,2)=s(pix,2)+t(i,2);
end
img_2=img;
for i=1:n
for j=1:m
img_2(i,j)=t(img(i,j)+1,6);
end
end
subplot(3,2,1),imshow(img),title('Original');
subplot(3,2,2),imshow(img_2),title('Manual Transform');
subplot(3,2,3),bar(t(:,1),t(:,2)),title('Histogram');
subplot(3,2,4),bar(s(:,1),s(:,2)),title('Histogram');
subplot(3,2,5),imhist(img_2),title("Equalized");
Output:-
Experiment -11
Objective:- Find Four, Diagonal and Eight Neighbours of image.
Implement:-
% Four Neighbour
if x > 1
fourN(1) = img(x - 1, y);
end
if y > 1
fourN(2) = img(x, y - 1);
end
if x < height
fourN(3) = img(x + 1, y);
end
if y < width
fourN(4) = img(x, y + 1);
end
% Diagonal Neighbour
if x > 1 && y > 1
diagonalN(1) = img(x - 1, y - 1);
end
Output:-
Experiment -12
Implement:-
Output:-
Experiment -13
subplot(1, 2, 2),imshow(erodedBinaryImage);
title('Manually Eroded Binary Image');
Output:-
Experiment -14
Implement:-
%Closing
% Create a binary image
binaryImage = imread('cameraman.tif')
binaryImage = im2bw(binaryImage);
% Create a structuring element (a simple 3x3 square)
se = logical(ones(3, 3));
Output:-