我想在matlab中以逆时针方式找到手轮廓的边界点(坐标)。即从任何点开始逆时针移动并存储坐标。
简单的行列扫描没有用,因为坐标必须是8连接的。
请帮帮我
答案 0 :(得分:2)
您可以使用imcontour
获取轮廓,然后使用fliplr
逆时针排列。
用你的形象:
I = imread('Image.jpg');
% --- Get a BW image, remove the title
BW = rgb2gray(I)<200;
BW(1:50,:) = 0;
% With a logical image, simply use:
% BW = double(Img);
% --- Find the outer contour coordinates
BW = imfill(BW, 'holes');
C = imcontour(BW,1);
% --- Arrange the contour counter-clockwise
x = fliplr(C(1,2:end));
y = fliplr(C(2,2:end));
% --- Display
imshow(BW)
hold on
plot(x, y);
% --- Display regularly spaced markers to check the order
bin = linspace(1,numel(x), 11);
bin = round(bin(1:end-1));
cm = jet(numel(bin));
for i = 1:numel(bin)
scatter(x(bin(i)), y(bin(i)), 'o', 'MarkerEdgeColor', 'none', ...
'MarkerFaceColor', cm(i,:));
text(x(bin(i)), y(bin(i))+10, num2str(i), 'color', cm(i,:));
end
轮廓存储在x
和y
向量中。结果是:
最佳,