Size of data points in random scatter image

2 次查看(过去 30 天)
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
Matt Kindig 2013-6-12
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.
  4 个评论
J B
J B 2013-6-14
Hi Kelly, thanks for commenting. Does this method work for a figure?
J B
J B 2013-6-17
Managed to succeed using this simple method. Thanks!

请先登录,再进行评论。

更多回答(1 个)

Image Analyst
Image Analyst 2013-6-12
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 个评论
J B
J B 2013-6-14
Thanks for responding. The figure has 256 gray levels. I will post an image tomorrow. To be clear, I am wanting to convert the figure I produce to black and white without having to save it.
Image Analyst
Image Analyst 2013-6-14
"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.

请先登录,再进行评论。

Community Treasure Hunt

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

Start Hunting!

Translated by