Fixed sized positionable rectangular ROI

조회 수: 5 (최근 30일)
ian Handsportman
ian Handsportman 2020년 7월 5일
댓글: ian Handsportman 2020년 7월 5일
I need to select fixed area Rois from a set of images. I have code working fine that uses imrect - the box is drawn, can be dragged around and waits for a mouseclick to record position but I can't suss out how to do it with drawrectangle - for my own satisfation.
The nearest I've got it to draw rectangle with mouse then resize after, which is clunky and I can't figure out how to make that box draggable. Here's the relevant part of the code, obviously there'd be an image open.
% Get positions
for Roicount=1:Roinumber
Framesize = [1 1 Lanelength Lanewidth];
Im1 = imrect(gca, Framesize); %can't see how to do this with drawrectangle
setResizable(Im1,0);
Position = wait(Im1);
for m=1:4 %Store positions
Regions(Roicounter,m)=Position(m);
end
end
The positions are used later to crop out the regions of interest.

채택된 답변

Image Analyst
Image Analyst 2020년 7월 5일
Try drawrectangle(). Use can click and drag. Set up a listener that resets the size in the event that they click a handle to change the size.
  댓글 수: 1
ian Handsportman
ian Handsportman 2020년 7월 5일
That seems like long way round to achieve the same result, why is imrect not recommended?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

태그

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by