How to select the ROI of specific size over the image ?
显示 更早的评论
Hi
I want to select the ROI of 128 by 128 within the image attached. Using the imrect function we can draw the ROI but I wanted to select constant size of 128 by 128 can you please suggest some method where I can provide the size roi and it will get draw on image. Thank you
采纳的回答
更多回答(2 个)
Image Analyst
2015-5-28
0 个投票
Either rectangle(), plot(), or line() can do that. Be sure you call "hold on" before you draw the box over the image or else the box will blow the image away.
Jonas Thomalla
2020-11-11
With the newer roi-commands it also can look like this:
height = 128;
width = height;
imshow(image)
roi = images.roi.Rectangle(gca,'Position',[1,1,width,height],'FixedAspectRatio',true,'InteractionsAllowed','translate');
roi = customWait(roi);
function oROI = customWait(hROI)
%from function customWait https://www.mathworks.com/help/images/use-wait-function-after-drawing-roi-example.html
% Listen for mouse clicks on the ROI
l = addlistener(hROI,'ROIClicked',@clickCallback);
% Block program execution
uiwait;
% Remove listener
delete(l);
% Return the current roi
oROI = hROI;
end
function clickCallback(~,evt)
if strcmp(evt.SelectionType,'double')
uiresume;
end
end
Hope this helps anyone because I was searching for a solution for a few days.
类别
在 帮助中心 和 File Exchange 中查找有关 ROI-Based Processing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
