How to select the ROI of specific size over the image ?
Mostrar comentarios más antiguos
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
Respuesta aceptada
Más respuestas (2)
Image Analyst
el 28 de Mayo de 2015
0 votos
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
el 11 de Nov. de 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.
Categorías
Más información sobre ROI-Based Processing en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
