# Size of data points in random scatter image

2 views (last 30 days)
J B on 12 Jun 2013
I have produced a graph/image which is a random plot containing thousands of dark and light patches. My next task is to evaluate the size of these patches.
I am wandering if anyone is aware of a method for determining the average size of a dark/light patch in the image?
Early on in the process so not had too much break through.
Any suggestions would be hugely welcome.
Thanks,
Jack

Matt Kindig on 12 Jun 2013
This is actually a relatively straightforward process. Steps:
1. Threshold image to convert to black and white. im2bw() function
2. Calculate area of each light (now white) patch: regionprops() function.
3. Extract area and find average size (in number of pixels): mean() function.
For the dark patches, do the same steps, but thresholding for dark rather than light patches.
J B on 17 Jun 2013
Managed to succeed using this simple method. Thanks!

### More Answers (1)

Image Analyst on 12 Jun 2013
Might be as easy as Matt says, or might be tougher, depending on what your image looks like and how you define light and dark. Are there just 3 gray levels: one for light, one for background, and one for dark? Or are there lots of gray levels, up to 256 or even more? Can you post an image. The simplest would be to just label the image (to count the patches) and calculate the area and divide by the number of patches:
binaryImage = grayImage > 100; % or whatever.
[labeledImage, numberOfBlobs] = bwlabel(binaryImage);
meanArea = sum(double(binaryImage))/numberOfBlobs;
##### 2 CommentsShowHide 1 older comment
Image Analyst on 14 Jun 2013
"black and white" is ambiguous. To some people that means "gray scale" or "monochrome" - in other words a uint8 or uint16 image with lots of gray levels. To others, or in a different context, it may mean the appearance of a "binary" or "logical" image where the pixel values have the values false or true, or, less often 0 or 1, or 0 or 255. When this type of image is displayed, it has only completely 100% black pixels and completely 100% pure white pixels with no other gray pixels of any intensity at all. If you have a grayscale image, you can binarize it into two classes ("foreground" and "background") using the first line of my code above.

### Categories

Find more on Convert Image Type in Help Center and File Exchange

### Community Treasure Hunt

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

Start Hunting!