Azzera filtri
Azzera filtri

how get centroid contour distance every 1 degrees?

2 visualizzazioni (ultimi 30 giorni)
Robin
Robin il 10 Giu 2014
Risposto: LOKESH KAVULURU il 5 Apr 2017
I have an image and I already get the boundary and the weighted centroid of region of interest. I want to get the coordinate point of boundary at certain degrees. It starts from the fartest distance of center to edge and its counterclockwise. I have tried, using bwboundaries but the result is not appropriate with my goal. Can anyone help me about this? Thx for the help
this is my code
% BW = imread('fyc-00_1-006.png');
BW1 = bwareaopen(BW, 1000);
BW2 = imfill(BW1, 'holes');
s = regionprops(BW, 'centroid');
centroids = cat(1, s.Centroid);
[meanx,meany] = ait_centroid(BW2);
meanx;
meany;
[B,L,N,A] = bwboundaries(BW2);
imshow(BW2); hold on;
for j=1:N,
if(~sum(A(j,:)))
thisboundary = B{j};
plot(thisboundary(:,2),...
thisboundary(:,1),'r','LineWidth',2);
for l=find(A(:,j))'
thisboundary = B{l};
plot(thisboundary(:,2),...
thisboundary(:,1),'g','LineWidth',2);
end
end
end
plot(centroids(:,1), centroids(:,2), 'b*');
title('Binary Image', 'FontSize',20);
axis on;
x = thisboundary(:,2); %Column
y = thisboundary(:,1); %Rows
deltaY = y - meany;
deltaX = x - meanx;
distances = sqrt((x - meanx).^2 + (y - meany).^2);
<</matlabcentral/answers/uploaded_files/13965/pict.png>>

Risposte (2)

Image Analyst
Image Analyst il 10 Giu 2014
What is "ait_centroid"? It's not defined anywhere. Also, you're not calculating the angles of the boundary coordinates to the centroid or weighted centroid. You said you did it but didn't show how you did it. I don't see any reason why that should not work.
  2 Commenti
Robin
Robin il 10 Giu 2014
ait_centroid is a function that I used to find centroid point. This is my code to calculate angles of boundary
% xCenter = meanx;
yCenter = meany;
angles=zeros(length(y),1);
for j = 1 :length(y)
angle = atand(abs(deltaY(j) ./ deltaX(j)));
% Convert to 0-360
if y(j) <= yCenter && x(j) >= xCenter
angles(j) = angle;
quadrant = 1;
elseif y(j) <= yCenter && x(j) <= xCenter
angles(j) = 180 - angle;
quadrant = 2;
elseif y(j) >= yCenter && x(j) <= xCenter
angles(j) = 180 + angle;
quadrant = 3;
elseif y(j) >= yCenter && x(j) >= xCenter
angles(j) = 360 - angle;
quadrant = 4;
end
end
please help me how to find the coordinate point of boundary every one degrees and It starts from the fartest distance of center to edge and its counterclockwise.
Image Analyst
Image Analyst il 10 Giu 2014
That's not exactly how I'd do it. First tell me what is a typical angle you'd want to find the boundary coordinate closest to? 20 degrees? 45 degrees? Something else?

Accedi per commentare.


LOKESH KAVULURU
LOKESH KAVULURU il 5 Apr 2017
I also struck in this situation, i should calculate boundary for every 45 degrees

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by