Zoom or pan shift before selecting a ROI

19 次查看(过去 30 天)
I have a loop for interactively selecting several point ROIs on an image. I would have to pan shift and zoom the image for each new ROI point selection to get it placed accurately enough. Any suggestions for doing this?
  2 个评论
Johanna Torppa
Johanna Torppa 2020-6-3
This was more simple than I thought. I only now realized, that you can click again the zoom and pan icons to deactivate them and return to ROI selection.
Robert Morhard
Robert Morhard 2021-3-7
Thanks for posting this, I was having the same issue and you saved me some time!

请先登录,再进行评论。

回答(1 个)

Zhenfei Jiao
Zhenfei Jiao 2022-2-17
编辑:Zhenfei Jiao 2022-2-17
Hey Johanna,
I was also working on something similar recently. But I found a trick in the Matlab 2021a (not sure if it works in the previous version) during drawing the polygon ROIs if you want to pan, zoom in/out of the image simultaneously.
Here is the code I used:
Img = imread('coins.png');
h = figure;
ax = h.Children;
imagesc(Img);axis image;
n=3;
roi=cell(n,1);
for ii = 1:n
roi{ii}=drawpolygon(ax,'color','r','Label',num2str(ii));
end
If you run the code above, a figure will pop up with your curse changed to a cross. Technically you can select the first ROI. But if you want to zoom in on your image, you can select the [zoom in button] on the top-right toolbar. Then the [zoon in] icon will change to light-blue and the cursor will change to a magnifying lens. Now you can scroll the middle button of your mouse to zoom in/out of your image. Let's say if you also want to pan it a bit before your selection. You can click the [pan button] of the top-right toolbar. Then the [pan button] will change to light-blue then you can move your image to the place you want. Now, let's say the image has been moved to the desired place as you want, You have to click the [pan button] again to make it gray. Then your cursor on the image will change to cross again. You want to select your ROI now.
The key idea is: If you want to pan or zoom in/out before drawing the polygon ROIs. You need to click the pan button of the top-right toolbar to make it light blue. But remember to click the [pan button] again to make the it gray before you want to select the ROIs.

标签

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by