use*_*612 4 matlab image-processing computer-vision image-segmentation
我正在尝试为静态姿势创建一个手势识别系统.在进行特征提取之前,我目前正在尝试实施手腕裁剪程序.
我遇到了一个算法(在这里引用:http://admin.csie.ntust.edu.tw/IEET/syllabus/course/961_CS5014702_65_aGlnaDIucGRm.pdf),但我不确定它的技术实现(该论文引用了另一个来源)这是我无法找到的.描述了2种方法,如下图所示:
第一个是基于手腕长度,第二个是基于图像轮廓的变化.我不确定如何实现这一点,并希望得到任何帮助.
我有一个简单的想法(对于第一种方法),你将扫描像素(从图像的底部开始),计算否.每行上的像素数,直到遇到比前一行有更多像素的行(表示手掌区域的开始).然而,这将假设手的定位总是垂直的.任何改进的想法,以便手不必总是垂直或如何实现基于轮廓的方法(在那里你会发现轮廓的急转弯,指示手腕)?我对Matlab很新.谢谢.
输入示例:
使用Miki的解决方案,在更多测试图像上输出一些:
原始图片:
一个简单的方法是:
这里的代码(版本2):
% Read the image
img = imread(path_to_image);
% Binarize the image
bw = img > 127;
% Compute principal component orientation and rotate
orientation = regionprops(bw, 'Orientation');
centroid = regionprops(bw,'centroid');
% Correct rotation according to centroid
rotationAngle = -90 - orientation.Orientation;
if(centroid.Centroid(1) < size(img,2)/2)
rotationAngle = 90 - orientation.Orientation;
end
rotated = imrotate(bw, rotationAngle);
rows = size(rotated,1);
dist = zeros(rows, 1); % vector of distances of contour points
imshow(rotated);
hold on;
% Compute the distances
for r=1:rows
s = find(rotated(r,:), 1, 'first');
e = find(rotated(r,:), 1, 'last');
if(~isempty(s) && ~isempty(e))
dist(r) = e - s;
plot(s, r, 'xg');
plot(e, r, 'xr');
end
end
% Smooth for cleaner peaks
%dist = smooth(dist, 15);
% Find peaks
[pks, locs] = findpeaks(-dist);
% Select the peak carefully...
th = 20; % A threshold on the distance among peaks
loc = locs(end);
for i = length(locs)-1 : -1 : 1
if(abs(locs(i) - loc) > th)
break;
else
loc = locs(i);
end
end
% Keep best
ycut = loc;
plot([1, size(rotated,2)], [ycut, ycut], 'b');
hold off;
figure();
plot(dist);
hold on;
plot(locs, -pks, 'vg');
hold off;
Run Code Online (Sandbox Code Playgroud)
结果
归档时间: |
|
查看次数: |
883 次 |
最近记录: |