giving index numabers to objects in an image

1 次查看(过去 30 天)
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!!!!

回答(1 个)

Image Analyst
Image Analyst 2015-7-22
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 个评论
yashwine ganji
yashwine ganji 2015-7-29
编辑:yashwine ganji 2015-7-29
Please give me the code for detecting the objects in that image and display them separately in windows.
Image Analyst
Image Analyst 2015-7-29
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.

请先登录,再进行评论。

Community Treasure Hunt

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

Start Hunting!

Translated by