Professional Documents
Culture Documents
DIP(TH) ASSIGNMENT 01
SUBMITTED BY:
MAHEERA AFTEB
21-SE-07
ALPHA
SUBMITTED TO:
Dr. ALI JAVED
DATE: 07-Feb-2024
Q1. For the given binary image strip, implement Connected Component Labeling
Algorithm for 8-connectivity in Matlab. You can use built-in functions only for
reading and displaying images (imread/ imshow etc).
11100000
11101100
11101100
11100010
11100010
11100010
11100110
11100000
Ans. Matlab Code
% Define the binary image strip
binary_strip = [1 1 1 0 0 0 0 0;
1 1 1 0 1 1 0 0;
1 1 1 0 1 1 0 0;
1 1 1 0 0 0 1 0;
1 1 1 0 0 0 1 0;
1 1 1 0 0 0 1 0;
1 1 1 0 0 1 1 0;
1 1 1 0 0 0 0 0];
Q2. Pick the image (cameraman.tif) from the matlab and perform the following
operations.
a) Convert the image into binary without a built-in function (e.g im2bw).
Ans. Matlab code:
% Read the image
image = imread('cameraman.tif');
subplot(1, 3, 2);
imshow(d4_dist, []);
title('D-4 Distance Transform');
subplot(1, 3, 3);
imshow(d8_dist, []);
title('D-8 Distance Transform');
Output: