How to identify particles in image
Show older comments
I have been working on this project for quite some time and am now seeking some outside opinions. I must create a script that will identify each of the small particles. I have looked at multiple threshold techniques and not many seem to be working. For example, I tried turning it into a binary image and getting rid of noise using the function bwareaopen, but there is still a lot of noise and the imfindcircles function is being thrown off. Any fresh ideas to identify these beads would be very helpful. Accuracy is a must in this project! The small beads are the ones I'm identifying, they are the ones that have the most consistent size in the image.

Answers (1)
Image Analyst
on 15 May 2017
Have you tried a Bottom Hat Filter, imbothat()?
rgbImage = imread('StackOverflow#1.JPG');
subplot(2,2,1);
grayImage = rgb2gray(rgbImage);
imshow(grayImage, []);
axis on;
subplot(2,2,2);
se = strel('disk', 4, 0);
filteredImage = imbothat(grayImage, se);
imshow(filteredImage, []);
axis on;
% Histogram
subplot(2,2,3);
histogram(filteredImage, 256);
grid on;
xticks(0:16:255);
% Threshold
binaryImage = filteredImage > 40;
subplot(2,2,4);
imshow(binaryImage);
8 Comments
Isaiah Stefan Engle
on 15 May 2017
Edited: Image Analyst
on 16 May 2017
Image Analyst
on 16 May 2017
Yeah, so? So just don't do that. No need to use findcircles() because the blobs are found using a different segmentation algorithm (bottom hat filter and thresholding). Why would you want to run findcircles()? You'll notice I did not use it and there is a reason for that.
Isaiah Stefan Engle
on 16 May 2017
Image Analyst
on 16 May 2017
And my code doesn't do that? Sure it does. Apparently much better than find circles does. Of course if the dots are too close together, like you showed, it will count it as one blob instead of 2. If you want to throw out blobs bigger than the size of one dot, you can do that, or you can count it as two dots instead of 1. Maybe the area fraction of dots would be a better metric than the count of the dots. They would be perfectly correlated if all dots were isolated but if they're touching then the count can be wrong but the area would be right. So I'd encourage you to consider area fraction instead of count as a useful metric.
Isaiah Stefan Engle
on 16 May 2017
Image Analyst
on 17 May 2017
Here is what I get with this code:
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
imtool close all; % Close all imtool figures.
clear; % Erase all existing variables.
workspace; % Make sure the workspace panel is showing.
format longg;
format compact;
fontSize = 20;
rgbImage = imread('StackOverflow#1.JPG');
subplot(2,2,1);
grayImage = rgb2gray(rgbImage);
imshow(grayImage, []);
axis on;
title('Original Gray Scale Image', 'FontSize', fontSize);
subplot(2,2,2);
se = strel('disk', 4, 0);
filteredImage = imbothat(grayImage, se);
imshow(filteredImage, []);
axis on;
title('Bottom Hat Filtered Image', 'FontSize', fontSize);
% Histogram
subplot(2,2,3);
histogram(filteredImage, 256);
grid on;
xticks(0:16:255);
title('Histogram of Gray Levels', 'FontSize', fontSize);
xlabel('Gray Level', 'FontSize', fontSize);
ylabel('Pixel Count', 'FontSize', fontSize);
% Threshold
binaryImage = filteredImage > 40;
subplot(2,2,4);
imshow(binaryImage);
title('Binary Image', 'FontSize', fontSize);
% Label the image
labeledImage = bwlabel(binaryImage);
% Measure the areas
props = regionprops(labeledImage, 'Area');
allAreas = [props.Area];
% Show histogram of blob areas:
figure;
histogram(allAreas);
grid on;
title('Histogram of Blob Areas', 'FontSize', fontSize);
xlabel('Area', 'FontSize', fontSize);
ylabel('Blob Count', 'FontSize', fontSize);


You can see the distribution of blob areas. What is a "bonded circles"? Can it be identified as a certain area? Like if the area is more than 10 pixels, it's 2 blobs connected together instead of one single blob? What are "bonded circles"?
Isaiah Stefan Engle
on 17 May 2017
Indrajit Nandi
on 31 Mar 2021
Were you able to solve the problem?
Categories
Find more on Image Processing Toolbox in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


