How can I track these fine particles?

4 次查看(过去 30 天)
Raju
Raju 2023-9-18
回答: DGM 2023-9-18
Hello,
Is it possible to track these fine particles (black dots in the attached image) using their centroids?

回答(2 个)

DGM
DGM 2023-9-18
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.

Jerbin J
Jerbin J 2023-9-18
Hi Raju,
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);

类别

Help CenterFile Exchange 中查找有关 Image Segmentation and Analysis 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by