Size of data points in random scatter image

2 views (last 30 days)
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.

Accepted Answer

Matt Kindig
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!

Sign in to comment.

More Answers (1)

Image Analyst
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;
Image Analyst
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.

Sign in to comment.


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!