MATLAB Answers


finding a region of interest

Asked by Itzik Ben Shabat on 6 Nov 2012

Hi, I have an grayscale image matrix (basicly a 0,1 matrix). I am "drawing" a binary image using rectangle(). ( using a for loop on the matrix to identify the color and draw a each rectangle). (i know i can use imshow and enter a matrix there is a reason why im not using it). so far it works fine what i want to do next is select a region (say rectangular or circular). i want to know which of the rectangles the region is covering. is there a way to do this ? thanks


1 Answer

Answer by Image Analyst
on 6 Nov 2012
 Accepted answer

See code in my comment here to find out if rectangles overlap.


thanks. that helps. but its not taking me all the way. I am using a GUI. is there a way to dray the rectangle interactively?

found it myself. with getPosition(imrect()) should do the trick. thanks

Oh, I thought you already knew the rectangle because you said you were drawing it with rectangle(), which requires you to know the coordinates already. If you don't know them, you can use imrect(), or rbbox().

Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!