how get centroid contour distance at every 10 degrees?

5 次查看(过去 30 天)
I have an image and I already get the boundary/edge and the weighted centroid of region of interest. I want to get the coordinate point of boundary at every 10 degrees. It starts from the fartest distance of center to edge. I have tried, but the result is not appropriate with my goal. Can anyone help me about this? Thx for the help
  5 个评论
Image Analyst
Image Analyst 2016-1-8
See attached shape recognition demo. One of the ways it calculates the number of sides it to look at the centroid-to-perimeter distance and look for valleys and peaks and take the larger of them. Look at function FindNumberOfVertices(). It's meant to work with a labeled image where you pass in the labeled image and the blob number you want it to inspect. If you have questions, then start a new question and attach your image and segmentation code.
poonam
poonam 2016-2-11
'MinPeakProminence' is not supported in 'matlab13a'. is there any other way to get minimum and maximum distance in graph.
This new thread is started for this error.
https://in.mathworks.com/matlabcentral/answers/267617-problem-with-minpeakvariance-in-findpeak

请先登录,再进行评论。

采纳的回答

Image Analyst
Image Analyst 2012-12-3
So you said that you already got the boundary/edge - presumably from using bwboundaries() - and you already got the centroid - presumably from using regionprops, so what help do you need? You just need to run around the boundary and for each boundary point, calculate the angle using simple trigonometry and the distance using the Pythagorean theorem or hypot(). It's just a simple for loop. Write back if you still need help figuring it out.
  18 个评论
Ruksana siddique
Ruksana siddique 2019-3-7
hello mr. walter, i also want to draw the angle but in the image at 30 degree. more i want to crop each angle part. i am showing the image like this
Muhammad Andi Yusran
hello Mr. Image Analyst, how can i represent this code to the image, im just beginner, thanks before :).
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables.
workspace; % Make sure the workspace panel is showing.
format longg;
format compact;
fontSize = 20;
angles = 0 : 10 : 360;
x = cosd(angles);
y = sind(angles);
plot(x, y, 'ro-');
xlabel('X', 'FontSize', fontSize);
ylabel('Y', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
grid on;
xCenter = 0;
yCenter = 0;
for k = 1 : length(angles)
% Draw a line from the center to the edge of the circle.
line([xCenter x(k)], [yCenter y(k)], 'LineWidth', 3);
% Calculate the angle of that line
angle = atand(y(k)/x(k));
% Convert to 0-360
if y(k) >= yCenter && x(k) >= xCenter
quadrant = 1;
elseif y(k) >= yCenter && x(k) <= xCenter
angle = 180 + angle;
quadrant = 2;
elseif y(k) <= yCenter && x(k) < xCenter
angle = 180 + angle;
quadrant = 3;
elseif y(k) <= yCenter && x(k) >= xCenter
angle = 360 + angle;
quadrant = 4;
end
promptMessage = sprintf('This latest line, going from (0,0) to (%.8f, %.8f),\nis at angle %f, and in quadrant %d.', ...
x(k), y(k), angle, quadrant);
fprintf('%s\n', promptMessage);
titleBarCaption = 'Continue?';
button = questdlg(promptMessage, titleBarCaption, 'Continue', 'Cancel', 'Continue');
if strcmp(button, 'Cancel')
break;
end
end

请先登录,再进行评论。

更多回答(1 个)

Kay CH
Kay CH 2015-6-12
Thank you very much. It's very useful for me too.

类别

Help CenterFile Exchange 中查找有关 Graphics Object Properties 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by