How can I track these fine particles?
9 views (last 30 days)
Show older comments
Answers (2)
DGM
on 18 Sep 2023
Here's one idea. I'm sure there are better ways. It really depends which specks are necessary. With the limited depth of field, it seems a lot of the specks are barely visible.
% fetch the image
inpict = imread('image.jpeg');
inpict = im2gray(inpict);
inpict = rot90(inpict,1); % so that it fits better on the forum display
% find the undesired features
bgmask = ~imbinarize(inpict,'adaptive','foregroundpolarity','dark','sensitivity',0.36);
bgmask = imfill(bgmask,'holes');
bgmask = bwareaopen(bgmask,25);
imshow(bgmask,'border','tight')
% flatten and normalize
fpict = imbothat(inpict,strel('disk',3));
fpict = mat2gray(fpict);
imshow(fpict,'border','tight')
% binarize
pmask = fpict > 0.35;
pmask = pmask & ~bgmask;
imshow(pmask,'border','tight')
% do the rest
S = regionprops(pmask,'centroid');
C = vertcat(S.Centroid);
imshow(inpict,'border','tight'); hold on
plot(C(:,1),C(:,2),'rx','markersize',10);
Is that all of the specks? No. Are there things selected which are not specks? Probably. You'll have to play around with it.
Ultimately, these objects are only a few pixels in diameter. They are tiny, low-contrast features in a noisy image that has a bunch of JPG compression artifacts all over it. Many of the specks are barely distinguishable from noise. It's going to be difficult to get everything reliably.
0 Comments
Jerbin J
on 18 Sep 2023
Is this what you are looking for?
% Read the image
image = imread('imageTest.jpeg');
% Preprocess the image
gray_image = rgb2gray(image);
bw_image = imbinarize(gray_image, 'adaptive', 'ForegroundPolarity', 'dark', 'Sensitivity', 0.4);
% Measure properties of connected components (particles)
stats = regionprops(bw_image, 'Centroid');
centroids = cat(1, stats.Centroid);
% Display the original image with centroids
imshow(image);
hold on;
plot(centroids(:, 1), centroids(:, 2), 'r*', 'MarkerSize', 10);
hold off;
% If required save centroids to CSV file
csvwrite('centroids.csv', centroids);
1 Comment
See Also
Categories
Find more on Image Segmentation and Analysis 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!