Using ROI in MATLAB

17.9k views Asked by At

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

There are 1 answers

0
Ghaul On BEST ANSWER

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