Circle centers plot aren't in the same place as the circles in a figure
1 view (last 30 days)
Show older comments
Nadir Shakhshir
on 17 Nov 2019
Commented: Star Strider
on 17 Nov 2019
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);
0 Comments
Accepted Answer
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.
2 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!