【发布时间】:2015-05-14 05:33:45
【问题描述】:
我想在matlab中以逆时针的方式找到手部轮廓的边界点(坐标)。即从任意点开始逆时针遍历并存储坐标。
简单的行列扫描没有用,因为坐标必须是 8 连接的。
请帮帮我
【问题讨论】:
标签: matlab coordinates boundary
我想在matlab中以逆时针的方式找到手部轮廓的边界点(坐标)。即从任意点开始逆时针遍历并存储坐标。
简单的行列扫描没有用,因为坐标必须是 8 连接的。
请帮帮我
【问题讨论】:
标签: matlab coordinates boundary
你可以用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 向量中。结果是:
最好的,
【讨论】:
bin = linspace(1,numel(x), 11); 中选择点的坐标,这里给出 11 个点。如何获得这些点的坐标?使用fliplr时,我以顺时针方式获得积分,与您所说的完全相反。 % --- Arrange the contour counter-clockwise x = fliplr(C(1,2:end)); y = fliplr(C(2,2:end));
x和y中,bin部分仅用于可视化。而fliplr 只是翻转矢量,因此根据您的方向,您可能想要也可能不想使用它。如果您的矢量是垂直的,您可能需要使用flipud。清楚吗?
imread 吗?如果是这样,class(Img) 和 max(Img(:)) 的输出是什么?
class(img) 的输出是合乎逻辑的 & max(Img(:)) : 1 lmage Link