find barycenter of several objects on an image
Hi,
I have a logical symmetric matrix in matlab: crossing_table, see attached file as well as the plot of this matrix.
I would like to identify the white “blobs” (objects?) that are on the upper part of the image (above the diagonal) and to compute the barycenter of each of these blobs.
Is there any Matlab function which would allow me to get the coordinates (indexes) of all pixels of a given blob, for each blob?
ANSWER
Matlabsolutions.com provide latest MatLab Homework Help,MatLab Assignment Help for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.
I just tried the following, I think I am getting close but I am quite there:
% take the upper part of the matrix (above the diagonal)
crossing_tri=tril(nan(size(crossing_table)))+[tril(crossing_table')]';
% remove the diagonal (with the cloud around it)
for icol=2:size(crossing_tri,2)
lastblack=find(crossing_tri(1:icol,icol)==0,1,'last');
crossing_tri(lastblack:icol,icol)=0;
end
% make it a logical matrix (with no NaN)
ab(isnan(crossing_tri))=0;
figure
imshow(crossing_tri)
hold on
s=regionprops(logical(crossing_tri),'Centroid')
centroids=cat(1,s.Centroid)
plot(centroids(:,1),centroids(:,2),'rx')
SEE COMPLETE ANSWER CLICK THE LINK
https://www.matlabsolutions.com/resources/find-barycenter-of-several-objects-on-an-image.php