How to choose a specific area of an image?

I would like to ask you how to choose a specific area of an image and then use the elements of this content?

5 Comments

Stephen23
Stephen23 on 5 Oct 2015
Edited: Stephen23 on 5 Oct 2015
How are you going to selct this particular region? Is the "specific region" defined by coordinates, some properties of the image, some external data, is the region picked randomly? Each of these requires a slightly different approach, so if you tell us how you select this specific region, then we can help you extract those values.
What kind of image do you have? RGB or indexed or B&W? What size is the image array?
I want to select a ROI of an image using impoly which is easy.But then I want to select all the elements of this ROI, not just the coordinates of the polygon. My image is DICOM but that is not my concern...
Define "select". I offered to give you masking demos in my answer but you didn't ask. So, I don't know what you mean now by "select". Please define it. Do you want all the pixel in the area in a 1-D list of intensity values? Do you want a 2D image with outside the polygon blacked out? Do you want the polygon part cropped out to a new image? What??? Be specific.
Hi, I have a question here. Lets say, I have defined an area of polygon using its x and y coordinates. But,how do I able to find out the mean pixels intensity of this area of polygon? Secondly,how should I apply the"if" condition to thershold a certain value of mean intensity of this polygon area.
Kindly advice
Make a mask and then use mean on the masked image:
mask = poly2mask(x, y, rows, columns);
theMeanIntensity = mean(grayImage(mask));

Sign in to comment.

 Accepted Answer

You need to use some kind of array indexing. Often the easiest is to use logical indexing, which would allow you to select the area that you want.

More Answers (1)

Categories

Asked:

on 5 Oct 2015

Commented:

on 9 Dec 2017

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!