how get centroid contour distance every 1 degrees?
2 views (last 30 days)
Show older comments
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>>
0 Comments
Answers (2)
Image Analyst
on 10 Jun 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 Comments
Image Analyst
on 10 Jun 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?
LOKESH KAVULURU
on 5 Apr 2017
I also struck in this situation, i should calculate boundary for every 45 degrees
0 Comments
See Also
Categories
Find more on Image Processing Toolbox in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!