Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

silhouette extraction from depth

Hello I have a depth image, I want to extract the person(human) silhouette from that. I used pixel thresholding like this:

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

but there is some part left. Is there any way to remove that?

Original_image: enter image description here

Extracted_silhouette: enter image description here

like image 484
Frq Khan Avatar asked Dec 20 '25 20:12

Frq Khan


2 Answers

According to this thread depth map boundaries can be found based on the direction of estimated surface normals.
To estimate the direction of the surface normals, you can

[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

A simple way would be to threshold

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

Resulting with
enter image description here

A more sophisticated method of deriving silhouette from boundary can be found in this answer.

like image 67
Shai Avatar answered Dec 22 '25 14:12

Shai


This is hard to do by thresholding, because the couch is at the same depth as the person's upper body. Do you need to segment out the entire person, or would it be sufficient to segment out the upper body? In the latter case, you can try using vision.CascadeObjectDetector is the Computer Vision System Toolbox to detect the person's upper body in the RGB image.

like image 42
Dima Avatar answered Dec 22 '25 13:12

Dima



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!