Placing and labeling ROIs on an image

7 views (last 30 days)
Veena Chatti
Veena Chatti on 8 Mar 2020
Edited: Veena Chatti on 9 Mar 2020
Hi!
I'm looking to place ROI circles of the same size on about 5-10 coordinate points in an image.
So far, I've extracted and plotted the coordinates of these points by clicking on them with crosshairs:
imshow(Image,[]);
set(gcf, 'units','normalized','outerposition',[0 0 1 1]); %For fullscreen
[x, y] = getpts; % I know this function isn't recommended any more, any better ideas?
hold on
plot(x, y, 'o', 'MarkerSize', 5, 'MarkerEdgeColor','green', 'MarkerFaceColor','green');
hold off
(Green dots in the image)
What I'd like to do further is to place circle ROIs of a specific radius on each dot, and create a mask with each circle ROI separately, retaining its specific coordinate information.
It would be ideal to have labels for each circle ROI on the final image.
I look forward to hearing your suggestions!
Thanks,
Veena
  2 Comments
Image Analyst
Image Analyst on 9 Mar 2020
Where do you want to place the circles? Where the user clicks? Random locations? Some locations determined from the image content?
Anyway, once you have the locations decided upon, you can either use
plot(x, y, 'ro', 'MarkerSize', 30);
and change the MarkerSize to whatever you want.
Or else to get exact radii in pixels, use the FAQ: https://matlab.fandom.com/wiki/FAQ#How_do_I_create_a_circle.3F
Veena Chatti
Veena Chatti on 9 Mar 2020
Edited: Veena Chatti on 9 Mar 2020
I have been working some more on this.
Now I can get it to place the ROIs on the specified coordinates, but somehow, I can't get it to save an image with all the ROIs. It only saves the last one. I feel like it's something really simple I'm missing with this loop:
Labels = int2str(coordinates(:,3));
for q = 1:length(coordinates)
imshow(merge,[]);
hold on
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
h(q) = drawcircle('Center', [x(q), y(q)], 'Radius', 5, 'InteractionsAllowed', 'none');
mask = h(q).createMask;
m = mask(mask>0);
hold off
end
saveas(gcf, Labels(2, 1:3), 'jpg')
This saves an image that looks like this:
(Note just the one blue circle representing my ROI, the last one in the loop.)
Thanks so much for all your help!

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!