I want to hide the circles and only plot centroids with "+" sign

2 ビュー (過去 30 日間)
MashalS
MashalS 2021 年 9 月 2 日
回答済み: Image Analyst 2021 年 9 月 5 日
I have attached the images and m file

回答 (2 件)

darova
darova 2021 年 9 月 5 日
  • binarize
  • use regionprops

Image Analyst
Image Analyst 2021 年 9 月 5 日
Try this:
baseFileName = 'circle1.JPG';
fullFileName = fullfile(pwd, baseFileName);
rgbImage=imread(fullFileName);
[rows, columns, numberOfColorChannels] = size(rgbImage);
subplot(2, 1, 1);
imshow(rgbImage);
axis('on', 'image');
blueChannel = rgbImage(:, :, 3);
% imshow(blueChannel);
% Binarize
mask = ~imbinarize(blueChannel);
% Find centroid(s)
props = regionprops(mask, 'Centroid');
xy = vertcat(props.Centroid)
xCenter = xy(:, 1)
yCenter = xy(:, 2)
hold on
plot(xCenter, yCenter, 'b+', 'MarkerSize', 60, 'LineWidth', 3);
% Now show an image where the circle(s) is/are hidden
% and only the centroid(s) is shown, like the poster wanted.
subplot(2, 1, 2);
plot(xCenter, yCenter, 'b+', 'MarkerSize', 60, 'LineWidth', 3);
axis('on', 'ij'); % Flip axes vertically.
xlim([1, columns]);
ylim([1, rows]);

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by