Lets Learn together... Happy Reading

" Two roads diverged in a wood, and I,
I took the one less traveled by,
And that has made all the difference "-Robert Frost

Identifying the objects based on count(bwlabel)

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.






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.













like button Like "IMAGE PROCESSING" page

4 comments:

Aaesha S said... Reply to comment

very nice :) keep posting :)

Kavita Deshpande said... Reply to comment

good for reference
keep posting........

Kavita Deshpande said... Reply to comment

Excellent

Balun Qui said... Reply to comment

thank you, this is great

Enjoyed Reading? Share Your Views

Previous Post Next Post Home
Related Posts Plugin for WordPress, Blogger...
Google ping Hypersmash.com