Want to find the coordinates of the particles from an image
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I want to find the cordinates of the non spherical particles from an image to estimate the local structure from an image. The image attached for the reference. I have been trying to do this but the overlapped particles creates the problem. Please help me with this problem. Thanks in advanve.
2 commentaires
Walter Roberson
le 30 Juil 2022
Have you experimented with finding the dividing lines so that you can mask out the round particles, instead of having to take the properties of all particles in the image and ignore the ones with low eccentricities (that is, the round ones)?
Réponses (2)
Ayush
le 25 Oct 2023
Hey Aashna,
I understand that you want to find the co-ordinates of the non spherical particles from an image to estimate the local structure from an image and you are facing issues with the overlapping particles.
So, to estimate the coordinates of non-spherical particles in an image and ignore the spherical particles, you can try the following approach:
- Convert the image to grayscale if it is not already in grayscale.
- Apply a thresholding technique to segment the particles from the background. This will create a binary image where the particles are white and the background is black. You can experiment with different thresholding methods such as global thresholding, adaptive thresholding, or Otsu's thresholding.
- Use morphological operations like erosion and dilation to remove noise and refine the particle shapes. This can help separate the overlapping particles to some extent.
- Use the regionprops function in MATLAB to extract the properties of the connected components in the binary image. Specifically, you can extract the eccentricity of each particle. The eccentricity value ranges from 0 (perfect circle) to 1 (line-like shape). Filter out the particles with low eccentricities (e.g., below a certain threshold) to exclude the spherical particles.
- Once you have the filtered particles, you can estimate their coordinates using the centroid property provided by the regionprops function.
Here is an example code snippet that demonstrates the steps mentioned above:
% Read the image
image = imread('DSC_0029.jpg');
% Convert to grayscale
grayImage = rgb2gray(image);
% Apply thresholding
threshold = graythresh(grayImage);
binaryImage = imbinarize(grayImage, threshold);
% Perform morphological operations
se = strel('disk', 3);
binaryImage = imopen(binaryImage, se);
% Extract properties of connected components
props = regionprops(binaryImage, 'Centroid', 'Eccentricity');
% Filter out spherical particles
eccentricityThreshold = 0.8;
nonSphericalParticles = props([props.Eccentricity] > eccentricityThreshold);
% Extract coordinates of non-spherical particles
coordinates = cat(1, nonSphericalParticles.Centroid);
% Display the results
imshow(image);
hold on;
scatter(coordinates(:, 1), coordinates(:, 2), 'r', 'filled');
hold off;
You can adjust the parameters and thresholds as per your specific requirements.
Once you have the coordinates of the non-spherical particles, you can proceed with estimating the Kernel Density using the "ksdensity" function in MATLAB.
Hope the above information helps!
0 commentaires
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!