Zoom or pan shift before selecting a ROI

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.
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일

0 개 추천

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

태그

질문:

2020년 6월 3일

편집:

2022년 2월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by