Size of data points in random scatter image

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

 Réponse acceptée

Matt Kindig
Matt Kindig le 12 Juin 2013

0 votes

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 commentaires

J B
J B le 12 Juin 2013
Thanks for the reply! Been messing around with it a bit. I should mention that the graph was produced in Matlab, it is not a saved image. It would be great if I could convert the figure produced in Matlab to the black and white binary form in the same script.
I have been attempting to use the graythresh function before im2bw. Is it possible to jump straight from the figure to the binary version without having to convert to an image?
Thanks again. Already a big help,
Jack.
By "without converting to an image", do you mean you don't want to produce an image file? If so,
im = frame2im(getframe(gca));
J B
J B le 14 Juin 2013
Hi Kelly, thanks for commenting. Does this method work for a figure?
J B
J B le 17 Juin 2013
Managed to succeed using this simple method. Thanks!

Connectez-vous pour commenter.

Plus de réponses (1)

Image Analyst
Image Analyst le 12 Juin 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 commentaires

J B
J B le 14 Juin 2013
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 le 14 Juin 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.

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by