MATLAB Answers


how can i obtain only hand after skin detection?

Asked by YUNUS
on 20 Mar 2014
Latest activity Edited by Image Analyst
on 6 Aug 2014

hi; im working on the hand detection, firstly i used skin detection algorithm but i dont know how can i obtain hand after skin detection, here my code;

vid = videoinput('winvideo', 1, 'YUY2_640x480');
set(vid, 'FramesPerTrigger', Inf);
set(vid, 'ReturnedColorspace', 'rgb')
vid.FrameGrabInterval =5;
I = getsnapshot(vid);
%%skin detection
cb =  0.148* I(:,:,1) - 0.291* I(:,:,2) + 0.439 * I(:,:,3) + 128;
cr =  0.439 * I(:,:,1) - 0.368 * I(:,:,2) -0.071 * I(:,:,3) + 128;
[w h]=size(I(:,:,1));
for i=1:w
  for j=1:h            
      if  140<=cr(i,j) && cr(i,j)<=165 && 140<=cb(i,j) && cb(i,j)<=195 && 0.01<=hue(i,j) && hue(i,j)<=0.1     
subplot(1,1,1);imshow(uint8(im));title('My Edge Detection')
clear all


2 Answers

Answer by Image Analyst
on 20 Mar 2014

segment is your mask. Assuming your algorithm for creating that skin mask is good, then you multiply segment by your original image to blacken outside the mask. So what's the problem? That is "only the hand", I mean other than the black surround. Do you want to crop to the bounding rectangle, or what?


Answer by YUNUS
on 20 Mar 2014

my fundemental problem is to obtain hand, im new at image processing and i dont know how can i obtain hand


Image Analyst
on 20 Mar 2014

Can you reply to my questions instead of offering an "Answer" to your original question, which actually wasn't an Answer at all? Did you notice that I had questions about what your intent was? I need to know the answers to those questions so I can understand what "only the hand" means to you, precisely. What you say is vague.

on 6 Aug 2014

@Image Analyst I think what he meant by saying "only the hand" is when the program runs it detects hand as well as face or other object of color similar to skin.

So the questions is how to isolate hand?

Image Analyst
on 6 Aug 2014

You might be able to do it based on the size. You might need to combine that with temporal tracking with the pretty good assumption that, in a video, the hand will move around a lot more than the face or other skin-colored items in the background do. He didn't provide a photo so that makes answering his question basically a guess.

Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi test

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!