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?
Kshitij Singh answered .
2025-11-20
% 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')