[英]Coordinates of the farthest point from centroid
我已经计算出图像的质心,现在想知道距质心最远点的坐标。
我用下面的代码来计算最大距离。
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);
如果有人知道如何计算距质心的物体边界上最远点的坐标。 距质心最远点的距离在上面计算为maxRadius。 在此,a2,b2是对象“ pad”的质心坐标。
在这里,您似乎在问“我如何找到max
选择了哪个输入值作为最大值”。 您需要使用max
的第二个输出参数。 对于您的特定情况,这给出了类似的内容:
[maxRadius, maxInd] = max(distances);
maxCoord = thisBoundary(maxInd, :);
请阅读max
函数的文档 。 另外,请再次提出您要澄清的确切问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.