从深度提取剪影

时间:2015-01-12 14:09:48

标签: matlab image-processing kinect matlab-cvst

你好,我有一个深度图像,我想从中提取人(人)轮廓。我像这样使用像素阈值:

for i=1:240 
  for j=1:320 
    if b(i,j)>2400 || b(i,j)<1900 
      c(i,j)=5000; 
    else 
      c(i,j)=b(i,j); 
    end 
  end
end

但还有一部分遗留下来。有没有办法删除它?

Original_image: enter image description here

Extracted_silhouette: enter image description here

3 个答案:

答案 0 :(得分:4)

根据this thread深度图,可以根据估计的曲面法线的方向找到边界 要估计表面法线的方向,您可以

[dzx dzy] = gradient( depth_map ); %// horizontal and vertical derivatives of depth map
n = cat( 3, dzx, dzy, ones(size(dzx)) );
n = bsxfun( @rdivide, n, sqrt( sum( n.^2, 3 ) ) ); %// normalize to unit length

一种简单的方法是阈值

e = abs( n(:,:,3) ) < 1e-2;

结果与 enter image description here

可以在this answer中找到从边界导出轮廓的更复杂方法。

答案 1 :(得分:1)

这很难通过阈值处理来实现,因为沙发与人的上半身处于同一深度。 你是否需要将整个人分割出来,还是足以分割出上半身?在后一种情况下,您可以尝试使用vision.CascadeObjectDetector计算机视觉系统工具箱来检测RGB图像中人物的上半身。

答案 2 :(得分:0)

@Shai above的工作基础上,您可以获取阈值的输出,然后对该图像应用边界。下面是一个示例,您可以从前面步骤的输出中输入[YOUR_IMAGE],然后修改[ADJUST]的值,直到只选择了该人。

此代码正在根据大小查找边界,并且不会选择大于您输入值的任何内容。简单地说,但它对我有用。希望这会有所帮助。

boundaries = bwboundaries([YOUR_IMAGE]);    
 numberOfBoundaries = size(boundaries)
   if (size(boundaries) < [ADJUST])
      for k = 1 : numberOfBoundaries
         thisBoundary = boundaries2{k}
         plot(thisBoundary(:,2), thisBoundary(:,1), 'b', 'LineWidth', 2);   
      end
   end