You have no items in your shopping cart.

Subtotal:Rs.0.00
Matlab Tips and Tracks

Matlab Code to Count the no of Objects in a Binary Image

matlab-code-to-count-the-no-of-objects-in-a-binary-image

Matlab Code to Count the no of Objects in a Binary Image

clc;

clear;

close all;

% Read the Input Image

InputImage=imread(‘eight.tif’);

% Display the Input Image

subplot(2,2,1);

imshow(InputImage);title(‘InputImage’);

% Convery Gray Scale Image to Binary Image

BinaryImage=im2bw(InputImage);

%Display Binary Image

subplot(2,2,2);

imshow(BinaryImage);

% Complement the Binary Image

ComplementImage=imcomplement(BinaryImage);

subplot(2,2,3);

imshow(ComplementImage);

%     Fill in the holes of a binary image

HolesClearedImage = imfill(ComplementImage,’holes’);

%Display Holes Cleared Image

subplot(2,2,4);

imshow(HolesClearedImage);title(‘HolesClearedImage’);

%Apply Labels for each  connected components in 2-D binary image

[L,Num] = bwlabel(HolesClearedImage)

 %Display each label

figure;
for i=1:Num

subplot(2,2,i);
imshow(L==i);
pause(1)
end

Simulation Results

matlab-code-to-count-the-no-of-objects-in-image

 

 

 

 

Tags : Matlab code for segmentationMatlab Code to Count the no of Objects in a Binary Image
jeevarajan

The author jeevarajan