Which mask can I use to count particles in an image?

15 views (last 30 days)
Hello, I have this image and I want to count particles in it. I have binarized the image with the code reported below and now I have to count particles. It was told me that I have to find a mask that compare white particles to an objet (maybe a circle) of established dimensions and if the object is contained in the white particles than I can consider it a particle, if is not I go on. What can I use?
clear all
close all
clc
I=imread('dapi_cd105-FGF.jpg');
I2=I(:,:,3);
BW=imbinarize(I2);

Accepted Answer

Image Analyst
Image Analyst on 24 Nov 2019
There are a number of measures you can do to compare it to a circle, such as the aspect ratio (ask for BoundingBox), Solidity, and circularity (ask for Area and perimeter);
props = regionprops(mask, 'Area', 'Perimeter', 'Solidity', 'BoundingBox');
allAreas = [props.Area];
allPerim = [props.Perimeter];
circularities = allPerim .^2 ./ (4 * pi * allAreas);
bb = vertcat(props.BoundingBox);
aspectRatios = bb(:, 3) ./ bb(:, 4);
Aspect ratios, solidities, and circularities should all be around 1 or so. Anything more than about 2 or 3 is not very circular.
  2 Comments
Marianna Pizzo
Marianna Pizzo on 24 Nov 2019
Thank you so much, finding areas I maneged to get the number of particles.
Image Analyst
Image Analyst on 25 Nov 2019
If all you needed was a count of the blobs in the binary image, you could use bwlabel():
[labeledImage, numberOfBlobs] = bwlabel(binaryImage);
but that's on the original image, not the number that you'd have after you post process to extract only round blobs.

Sign in to comment.

More Answers (1)

KALYAN ACHARJYA
KALYAN ACHARJYA on 24 Nov 2019
Edited: KALYAN ACHARJYA on 24 Nov 2019
No need any special mask, use regionprops function
Steps:
  1. Convert to binary image with adjustable threshold value
  2. Counts the blobs in binary image, here blobs represents the particles in the image
As first step you have already done, for second step here is the code
blobs_data=regionprops(binary_image);
num_blobs=numel(blobs_data);
Or
From your code
I=imread('dapi_cd105-FGF.jpg');
I2=I(:,:,3);
BW=imbinarize(I2);
blobs_data=regionprops(BW);
num_blobs=numel(blobs_data)

Community Treasure Hunt

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

Start Hunting!