how to plot the centroids on Matlab
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
bhavya vendra
le 11 Avr 2016
Commenté : Image Analyst
le 11 Avr 2016
clear;clc
image = '328100%beforethresholded.jpg';
I = imread(image);
%Crops image to specific area for observation and analysis
I = imcrop(I);
imshow(I)
%[n m] = size(I);
title('File Name')
%Converts image from color RGB to grayscale
I1 = rgb2gray(I);
background = imopen(I, strel('disk',550)); %vary size of radius depending on size of "dots"
I2 = I - background;
level = graythresh(I2);
bw = im2bw(I,level);
bw = bwareaopen(bw, 8); %Set to 8 for 2D images and 26 for 3D images
%Determine the centroid and the filled area of each cell/nucleus
s = regionprops(bw, {'Centroid', 'Area'});
figure
imshow(I)
title('Before');
hold on
boundaries = bwboundaries(bw, 'holes');
numObj = numel(s);
for k = 1 : numObj
b = boundaries{k};
plot(s(k).Centroid(1), s(k).Centroid(2), 'r.', b(:,2), b(:,1), 'g', 'LineWidth', 1)
end
hold off
Using this code, I was able to locate centroids for my cells. I was wondering if there is anyway I could plot the centroids based on the closest cell. As you can see, the cells have a columnar arrangement. and I want to get the shape of the column by plotting the centroids.

0 commentaires
Réponse acceptée
Image Analyst
le 11 Avr 2016
It's kind of hard, given one single blob, to determine where the "column" is that it belongs to. I see two approaches, neither of which is easy or straightforward. The first is to use the radon transform to find out the overall alignment of the "columns". You could use the radon transform to identify the angle the columns are gong along. Then rotate them so they're going vertical, then use sum() or mean() to get the mean profile and try to identify where each columns starts and stops. Then you have some "zones" where you can classify each blob into. See attached demo.
Neither approach is easy - good luck.
2 commentaires
Plus de réponses (0)
Voir également
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!