giving index numabers to objects in an image

HEllo,I want to give index numbers to objects in an image like 1,2..... when we are detecting the objects in an image using canny detection algorithm.Is it possible.Thanks in advance!!!!

Réponses (1)

Image Analyst
Image Analyst le 22 Juil 2015
Please post your image. You would not believe the number of people who think edge detection is the first step in an image processing algorithm when it's actually not even appropriate, or the best approach. It seems like the whole world thinks edge detection is the approach to use first before all others. It's usually not .
Anyway, you can attach numbered labels to the objects with bwlabel or bwconncomp:
labeledImage = bwlabel(binaryImage);

5 commentaires

yashwine ganji
yashwine ganji le 23 Juil 2015
labels are not coming for the image if i use bwlabel. if i use bwconncomp ,i am getting the error like Error using imageDisplayValidateParams Expected input number 1, I, to be one of these types:
double, single, uint8, uint16, uint32, uint64, int8, int16, int32, int64, logical
Instead its type was struct.
Image Analyst
Image Analyst le 23 Juil 2015
bwlabel() DOES give labels if you pass it your binary image . Didn't you get a binary image and give it to bwlabel? Evidently not. Please attach your binary image and your code that you claim does not give labels to the binary blobs in your binary image.
You DID do image segmentation first to get your binary image, right? You didn't just pass it your original gray scale image did you? Because that would be wrong - the objects haven't been identified yet!
Image Analyst
Image Analyst le 24 Juil 2015
I think you need to run my Image Segmentation Tutorial in my File Exchange to understand what labeling is and how it works. Here is the link: http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862
yashwine ganji
yashwine ganji le 29 Juil 2015
Modifié(e) : yashwine ganji le 29 Juil 2015
Please give me the code for detecting the objects in that image and display them separately in windows.
You can easily do this with the Image Segmentation tutorial I gave. You just need to add the ConvexHull to what you measure.
[labeledImage, numObjects] = bwlabel(binaryImage);
measurements = regionprops(labeledImage, 'ConvexHull');
Then pick out some number - you can put this in a loop if you want - and use its convex hull as a mask on the original image to extract just that object.
for k = 1 : numObjects
thisObjectMask = measurements(k).ConvexHull;
% Mask the image.
maskedRgbImage = bsxfun(@times, rgbImage, cast(thisObjectMask, class(rgbImage)));
figure;
imshow(maskedRgbImage);
end
Or something like that.

Connectez-vous pour commenter.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by