how to plot the centroids on Matlab

8 visualizaciones (últimos 30 días)
bhavya vendra
bhavya vendra el 11 de Abr. de 2016
Comentada: Image Analyst el 11 de Abr. de 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.

Respuesta aceptada

Image Analyst
Image Analyst el 11 de Abr. de 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.
The second approach is that you might use RANSAC to identify potential columns.
Neither approach is easy - good luck.
  2 comentarios
bhavya vendra
bhavya vendra el 11 de Abr. de 2016
Hey Thank you so much, I will try to perform this. If I were to use this on a stack of images in 3D, is there a way to do this still?
Image Analyst
Image Analyst el 11 de Abr. de 2016
I don't know. Try it and see.

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