フィルターのクリア

Putting index on centroids determined from image processing

2 ビュー (過去 30 日間)
Sean Ivan Roxas
Sean Ivan Roxas 2022 年 3 月 27 日
コメント済み: Image Analyst 2022 年 3 月 28 日
How can index each centroid determined from blob analysis?
hBlobAnalysis = vision.BlobAnalysis('MinimumBlobArea', 10000,'MaximumBlobArea',150000);
[objArea,objCentroid,bboxOut] = step(hBlobAnalysis, IBWopen);
So I have this part of my code that basically gets the centroid coordinates, what I would like to do is assign an index to each centroid determined and use it for an interative code later on.

回答 (1 件)

Image Analyst
Image Analyst 2022 年 3 月 27 日
You can do it this way
binaryImage = bwareafilt(binaryImage, [10000, 150000]);
props = regionprops(binaryImage, 'Centroid', 'BoundingBox');
xy = vertcat(props.Centroid);
imshow(binaryImage); % Display image.
hold on;
% Show boxes and centroids.
for k = 1 : length(props)
rectangle('Position', props(k).BoundingBox, 'EdgeColor', 'r');
xt = xy(k, 1);
yt = xy(k, 2);
str = sprintf(' (%.1f, %.1f)', xt, yt);
text(xt, yt, str, 'HorizontalAlignment', 'left', 'VerticalAlignment', 'middle')
plot(xt, yt, 'r+', 'MarkerSize', 30, 'LineWidth', 2)
end
  4 件のコメント
Sean Ivan Roxas
Sean Ivan Roxas 2022 年 3 月 28 日
The blob detection that I made is already okay as it is. Is there any way to index the coordinates? as in mathematically represent it?
Image Analyst
Image Analyst 2022 年 3 月 28 日
I don't usually use the Computer Vision toolbox way of finding blobs. Are you in a loop? Can't you just index the values
[objArea(k), objCentroid(k), bboxOut(k,:)] = step(hBlobAnalysis, IBWopen);

サインインしてコメントする。

Community Treasure Hunt

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

Start Hunting!

Translated by