Identifying the objects based on labeling
Steps To Be Performed:
- Convert the RGB image to binary image.
- Fill the holes in the image.
- Label the objects in the image based on connectivity 8
- 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.
![]() |
Original Image |
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.
4 comments:
very nice :) keep posting :)
good for reference
keep posting........
Excellent
thank you, this is great
Enjoyed Reading? Share Your Views