Matlab Code for Identifying the Objects Based on Labeling

Steps To Be Performed:


1. Convert the RGB image to binary image.

2. Fill the holes in the image.

3. Label the objects in the image based on connectivity 8

4. Display the images in a RGB format

4.1.  Store the co-ordinates(x,y) of the object 1 which is  labeled as 1.

4.2.  Calculate the image size for object one. The length can be found by subtracting the maximum
and the minimum of y values. Similary for x find the width by subtracting the maximum and minimum of x values.

4.3.  Now map the pixel value to the new image.

Fig: Input Image

MATLAB CODE

A=imread('num2.jpg');
figure,imshow(A);
title('Original image');
C=~im2bw(A);
B=imfill(C,'holes');
label=bwlabel(B,8);
for j=1:max(max(label))

[row, col] = find(label==j);

len=max(row)-min(row)+2;
breadth=max(col)-min(col)+2;
target=uint8(zeros([len breadth 3] ));
sy=min(col)-1;
sx=min(row)-1;

for i=1:size(row,1)
    x=row(i,1)-sx;
    y=col(i,1)-sy;
    target(x,y,:)=A(row(i,1),col(i,1),:);
end
mytitle=strcat('Object Number:',num2str(j));
figure,imshow(target);title(mytitle);
end


The objects that are displayed in a RGB format.



Contact:
Mr. Roshan P. Helonde
Mobile: +91-7276355704
WhatsApp: +91-7276355704
Email: roshanphelonde@rediffmail.com
Share:

Total Pageviews

CONTACT US

Prof. Roshan P. Helonde
Mobile: +917276355704
WhatsApp: +917276355704
Email: roshanphelonde@rediffmail.com

Enter Project Title

Popular Projects

All Archive

Contact Form

Name

Email *

Message *