简体   繁体   English

离质心最远点的坐标

[英]Coordinates of the farthest point from centroid

i have calculated the centroid of the image and now want to know the coordinates of the farthest point on the object boundary from the centroid. 我已经计算出图像的质心,现在想知道距质心最远点的坐标。

i used following code to calculate the maximum distance. 我用下面的代码来计算最大距离。

 boundaries = bwboundaries(pad);
thisBoundary = boundaries{1};
boundaryX=thisBoundary(:,1); 
boundaryY=thisBoundary(:,2);
% Get the distances of the boundary pixels from the centroid.
distances= sqrt((boundaryX - a2).^2 + (boundaryY - b2).^2); 
% Scan the boundary to find the pixel on it that is
% farthest from the centroid.
maxRadius = max(distances);
 disp(maxRadius);

please if any one know how to calculate the coordinates of the farthest point on the object boundary from the centroid. 如果有人知道如何计算距质心的物体边界上最远点的坐标。 the distance of the farthest point from the centroid is calculated above as maxRadius. 距质心最远点的距离在上面计算为maxRadius。 here a2, b2 are the centroid coordinates of the object 'pad'. 在此,a2,b2是对象“ pad”的质心坐标。

Here, you seem to be asking "how do I find which of the input values max has chosen as the maximum". 在这里,您似乎在问“我如何找到max选择了哪个输入值作为最大值”。 You need to use the second output argument of max . 您需要使用max的第二个输出参数。 For your specific case, this gives something like: 对于您的特定情况,这给出了类似的内容:

[maxRadius, maxInd] = max(distances);
maxCoord = thisBoundary(maxInd, :);

Please read the max function's documentation . 请阅读max函数的文档 Please also make the exact question you are asking a bit clearer next time. 另外,请再次提出您要澄清的确切问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM