Circle centers plot aren't in the same place as the circles in a figure

1 view (last 30 days)
Hello All,
I have a code that detects circles in an image of cells and then draws the circles around the cells, i am trying to plot the centers of the circles as Xs but they are being plotted in the left most side of the figure, any idea how can i shift them to be in the right location?
I = imread ( 'globules3.jpg');
BW = im2bw(I,.8);
BW=~BW;
[centers, radii, metric] = imfindcircles(BW,[15 30]);
centersStrong = centers(1:40,:);
radiiStrong = radii(1:40);
metricStrong = metric(1:40);
figure, imshow(I), hold on
viscircles(centersStrong, radiiStrong,'EdgeColor','b');
plot(centersStrong,'r*', 'MarkerSize', 4, 'LineWidth', 2);
Annotation 2019-11-17 125407.png

Accepted Answer

Star Strider
Star Strider on 17 Nov 2019
I cannot run your code.
However, since ‘centersStrong’ is a two-column matrix of the x and y coordinates, your plot call would need to separate them:
plot(centersStrong(:,1), centersStrong(:,2), 'r*', 'MarkerSize', 4, 'LineWidth', 2);
Since plot coordinates are different from image coordinates, you may also need to use:
set(gca, 'YDir','reverse')
As I mentioned, I cannot run your code, so I cannot experiment with this. I leave tht to you.

More Answers (0)

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!