how get centroid contour distance at every 10 degrees?

조회 수: 13 (최근 30일)
Diah
Diah 2012년 12월 3일
댓글: Muhammad Andi Yusran 2019년 12월 9일
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
Muhammad Andi Yusran 2019년 12월 9일
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