How to keep roi points visible when replotting
8 views (last 30 days)
Show older comments
I have a GUI where I plot an image using imshow. There are 2 color versions of this image.
By clicking on the image, the user can select data points to export the color code of the selected pixel. The selected location is indicated on the image using the drawpoint function.
Using a dropdown menu, they can switch between the 2 color version. The only problem I have there, is that the drawpoints disappear. Is there any way to keep them visible, like placing the imshow in the backgrond and not overwriting the drawpoints?
imshow(image, 'Parent', ax);
%selecting data points and visualising them on the image
roi = drawpoint(ax);
x(i) = roi.Position(1);
y(i) = roi.Position(2);
%changing the displayed image
value = app.DropDownVisual.Value;
switch value
case "Decor"
cla(ax,'reset')
imshow(image, 'Parent', ax);
case "Delta E"
imshow(deltaE, 'Parent', ax); colormap(ax, jet); caxis(ax, [0 max(deltaE(:))]); colorbar(ax);
end
0 Comments
Accepted Answer
DGM
on 24 Feb 2022
Edited: DGM
on 24 Feb 2022
Whenever you draw a new image with imshow(), and definitely when you clear the axes, the roi object gets deleted. You'll have to recreate it. Off the top of my head, I don't know of a simpler way around it.
image = imread('cameraman.tif');
deltaE = flipud(image);
ax = gca;
i = 1;
imshow(image, 'Parent', ax);
%selecting data points and visualising them on the image
roi = drawpoint(ax);
x(i) = roi.Position(1);
y(i) = roi.Position(2);
%changing the displayed image
value = "Delta E";
switch value
case "Decor"
imshow(image, 'Parent', ax);
roi = images.roi.Point(ax);
roi.Position = [x(i) y(i)];
case "Delta E"
imshow(deltaE, 'Parent', ax); colormap(ax, jet); caxis(ax, [0 max(deltaE(:))]); colorbar(ax);
roi = images.roi.Point(ax);
roi.Position = [x(i) y(i)];
end
3 Comments
More Answers (0)
See Also
Categories
Find more on Graphics Performance in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!