How to select the ROI of specific size over the image ?
Afficher commentaires plus anciens
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
Réponse acceptée
Plus de réponses (2)
Image Analyst
le 28 Mai 2015
0 votes
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
le 11 Nov 2020
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.
Catégories
En savoir plus sur ROI-Based Processing dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
