MATLAB: Converting a rectangle position on an image to image matrix index

digital image processing

Hi, I have drawn an greyscale image from a matrix using imshow. I used Imrect to draw a rectangle on a region of the image. from Imrect i get the xmin, ymin hight and width of the rectangle. but what i really need is to know which pixels it contains e.g the image matrix indexes. how do i do this conversion? thanks

Best Answer

If H is the handle returned by IMRECT, then you can use its createMask method to get a logical index mask of the region,
Indices=H.createMask;