how do I calculate area, size and number of colored dots in an image then tabulate them?

5 views (last 30 days)
numberfiles = length(allFileNames)
circle_count = zeros(numfiles, 1);
% since this is a code for processing multiple images it requires a for
% loop
for k = 1 : numberfiles
fprintf('Processing file #%d of %d : "%s".\n', k, numfiles, allFileNames{k});
% this is the line of code for the images that will be input into a string
% for counting the cells in the image
grayImage = allFileNames{k};
imageData = imread(grayImage);
bw = im2bw(imageData); % Binarize the image
bw = bwareafilt(bw, [10 inf]); % Extract only blobs 10 pixels and larger .
%if you output the data here it would give you the name, size, bytes, class
%and attributes of the image uploaded which is needed for the code to count
%and sum over the number of cells in the image
% Count the number of blobs
[~, numCircles] = bwlabel(bw);
% Save the number of pixels
circle_count(k) = numCircles;
Here is my code that I made for counting the number of colored dots and tabulating them but it is not successfully when applied, maybe the pixels are too small to be counted? Thanks!

Answers (1)

Image Analyst
Image Analyst on 23 Jan 2023
I have no idea, not having seen your image. Maybe get rid of call to bwareafilt().
If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:
  9 Comments
jabez
jabez on 25 Jan 2023
I don't think that answers my question.. can you explain why this possibly would answer my question?
Image Analyst
Image Analyst on 25 Jan 2023
Because you said "Can I ignore the colors?" I made a mask that ignores the colors. Any non-white blob is a foreground pixel in the mask regardless of what the color it.
And because you said "I don't want the area of all of the dots, I want the area of the dots in half of the image" so I made masks of only half the image. Now you can analyze each half by itself instead of analyzing the whole image. You can get the area of each individual cot, or sum them all up to get the area of all dots together.
So I'm meeting both criteria you laid out. Why do you think I don't?

Sign in to comment.

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!