how to Identify the centre of atom

47 visualizaciones (últimos 30 días)
玥
el 12 de Abr. de 2024 a las 6:34
Comentada: DGM el 13 de Abr. de 2024 a las 23:56
how to Identify the centre of gravity like the fllowing figure

Respuesta aceptada

DGM
DGM el 12 de Abr. de 2024 a las 10:08
Here's a start.
% the original image
inpict = imread('image.png');
inpict = im2gray(inpict);
% crop out the subimages
A0 = imcrop(inpict,[31.51 30.51 277.98 277.98]);
B0 = imcrop(inpict,[326.51 30.51 277.98 277.98]);
C0 = imcrop(inpict,[621.51 30.51 277.98 277.98]);
% process A
A = imflatfield(A0,10);
A = adapthisteq(A);
A = imopen(A,strel('disk',3,0));
maskA = imextendedmax(A,50); % roughly get a mask of minimal regions
maskA = imclearborder(maskA); % get rid of partial blobs
imshow(maskA,'border','tight')
% process B
maskB = imextendedmin(B0,80); % roughly get a mask of minimal regions
maskB = imclearborder(maskB); % get rid of partial blobs
imshow(maskB,'border','tight')
% process C
C = imflatfield(C0,10);
C = adapthisteq(C);
maskC = imextendedmin(C,80); % roughly get a mask of minimal regions
maskC = imclearborder(maskC); % get rid of partial blobs
imshow(maskC,'border','tight')
% for example, find the centroids of the blobs in one of the masks
Sc = regionprops(maskC,'centroid');
centers = vertcat(Sc.Centroid);
% mark the centers on the mask
hold on;
plot(centers(:,1),centers(:,2),'x','linewidth',2)
  7 comentarios
Image Analyst
Image Analyst el 13 de Abr. de 2024 a las 14:57
@DGM in your first response, since he specifically wanted the center of gravity, you should have used "WeightedCentroid" instead of 'Centroid', though for this image it looks like they should be really close to the same location.
Maybe, after field flattening, you can use kmeans to classify a pixel as light, dark, or gray.
DGM
DGM el 13 de Abr. de 2024 a las 23:56
That's a pretty good point. I'll throw in an example just for sake of completeness.
% the original image
inpict = imread('image.png');
inpict = im2gray(inpict);
% crop out the subimages (i'm just going to use C)
C0 = imcrop(inpict,[621.51 30.51 277.98 277.98]);
% process C (same as before)
C = imflatfield(C0,10);
C = adapthisteq(C);
maskC = imextendedmin(C,80); % roughly get a mask of minimal regions
maskC = imclearborder(maskC); % get rid of partial blobs
% for example, find the weighted centroids of the blobs in one of the masks
% in this call to regionprops, it's important to make sure that the second argument
% has a light-on-dark polarity, hence the use of imcomplement() in the case of B or C.
% A is already light-on-dark, so we wouldn't need to complement it.
Sc = regionprops(maskC,imcomplement(C),'weightedcentroid');
centers = vertcat(Sc.WeightedCentroid);
imshow(maskC,'border','tight'); hold on;
plot(centers(:,1),centers(:,2),'x','linewidth',2)

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by