【发布时间】:2018-02-04 20:22:52
【问题描述】:
基于以前的工作 (https://www.mathworks.com/matlabcentral/answers/144559-centroid-contour-for-a-binary-image-containing-multiple-objects),我正在尝试使用位于 http://cs.mcgill.ca/~pcrane/ 的手势图像绘制轮廓距离
很遗憾,我的剧情好像不太一样,有什么原因吗?算错了吗?
我只展示了第一张图片。
非常感谢。
脚本:
clc;
clear;
RGB = imread('E:/00000.jpg');
I = rgb2gray(RGB);
binaryImage = imbinarize(I);
binaryImage = bwareaopen(binaryImage,30);
binaryImage = imfill(binaryImage,'holes');
imshow(binaryImage);
%[B,L] = bwboundaries(binaryImage,'noholes'); % no need
boundaries = bwboundaries(binaryImage);
measurements = regionprops(binaryImage, 'Centroid');
centroids = [measurements.Centroid];
% centroidx = centroids(1:2:end); % no need
% centroidy = centroids(2:2:end); % no need
centroidx = centroids(1);
centroidy = centroids(2);
numberOfBoundaries = size(boundaries, 1);
for k = 1 : numberOfBoundaries %in case that there are more objects
thisBoundary = boundaries{k};
boundaryx = thisBoundary(:, 2);
boundaryy = thisBoundary(:, 1);
plot(boundaryx, boundaryy, 'r-', 'LineWidth', 2);
allDistances = sqrt((boundaryx - centroidx(k)).^2 + (boundaryy - centroidy(k)).^2);
end
sequence = rot90(flip(0:numel(allDistances)-1));
plot(sequence,allDistances)
【问题讨论】:
-
哪些情节,与什么相同?每个图像有 3 个图,绘制不同的东西,不是吗?您希望看到什么?
-
抱歉,忘记添加了
-
在我看来他们非常接近。请注意,没有唯一的开始轮廓的位置。他们在您开始的地方以外的地方开始了它。您可以使用
circshift修改一个图表,使其看起来更像另一个。