how to plot the centroids on Matlab
显示 更早的评论
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 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Image Segmentation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!