Using ROI in MATLAB

巧了我就是萌 提交于 2019-12-06 08:09:43

问题


I have a final project in MATLAB and I need help.

I build a GUI and display an image using imshow function, now i want to select area from the image and get the pixls of the Selected area.

i know the ROI method but i don't know how to use it, so i be very happy if someone could explain it to me. thanks.


回答1:


Selecting a ROI is pretty easy if you have the image processing toolbox. There are many ways to do it, but I recommend using the roipoly function. Simply write:

BW = roipoly(I);

where I is your image. You will then be promoted to select points for your ROI. The output BW will be a binary image with value 1 inside the ROI and 0 outside.

For more information look at:

http://www.mathworks.com/help/toolbox/images/ref/roipoly.html

EDIT:

You can use the function imrect to create rectangular ROIs. Note that this function works on the current axes, so you need to use imshow before imrect. The output of the function is a roi handle, so you need to use the function createMask to get a binary image out.

imshow(I); 
h = imrect;
BW = createMask(h);

http://www.mathworks.com/help/toolbox/images/ref/imrect.html



来源:https://stackoverflow.com/questions/4850816/using-roi-in-matlab

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!