Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

need help to explain MATLAB skin detection codes

Status
Not open for further replies.

bug1not

Banned
Joined
Dec 5, 2010
Messages
21
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
0
Good day!

I saw this website while surfing for some skin detection codes..

Code:
http://www.urwelcome.us/Jstill/Matlab/Skin_Detection.htm

Can you guyz please answer my questions below? Because I don't understand what the functions are of some lines in the codes..
The following are the codes I don't understand..

Code:
http://www.urwelcome.us/Jstill/Matlab/skin_detection/hs_skin_detection.m

% Extract the Hue & Saturation into new different variables
h = hsvimage:),:,1);
s = hsvimage:),:,2);


What does :),:,1 or 2) means? Why is it 1 or 2?


%targeted values determined by looking at the plotted skin H S figures
h_range = [0 .11];
s_range = [0.2 1.5];
detectSkin('girl.jpg', h_range, s_range);


What are the purpose of h_range and s_range? Why there are 2 numbers?



Code:
http://www.urwelcome.us/Jstill/Matlab/skin_detection/hs_detectSkin.m

function detectSkin(filename, h_range, s_range)

%read in image & convert to HSV
im = imread(filename);
im1 = double(im);
hsv_im1 = rgb2hsv(im1);


Why does "im" needs to be double?


%pull out H & S data into new variables
H = hsv_im1:),:,1);
S = hsv_im1:),:,2);


What do these lines mean?


%prevents errors
I = H+S;
I(find(I==0))=Inf;


What do these lines mean?


%targets skin by only selecting values within the rectangle skin range
skin = ((s>s_range(1)) & (s<s_range(2)) &(h>h_range(1)) & (h<h_range(2)));


What does this line means?



Hoping you guyz can help me answer my queries above because I really like to understand the codes above..

Thanks a lot!

bug1not
 

I'm afraid that you need to go through some basic MatLab course to get more knowledge about fundamental MatLab definitions.

>>What does :),:,1 or 2) means? Why is it 1 or 2?

The imported into HSV is a 3 dimentional array (X - Y for the image and Z for the H, S, V). Colons :)) are used to denote all elements from X and Y,

You access different parts of the color vector and create a new variables (2 dimensional) which shows how this color component is spreaded accross the image. If the conversion is Hue/Saturation/Value then index 1 will bring you the Hue and index 2 - the Saturation. Value (sometimes called brightness) in your case doesn't matter.

The color (or as they call it Hue) range - when colors are represented as HSV it's very easy to define the face color simply with 2 digits - the low and the high boundary, so you simply filter all pixels which fulfil this criteria - color is bigger or less than some values

The same is with saturation - in HSV the tone of the skin can be only valid in some range
 
Last edited:
I'm afraid that you need to go through some basic MatLab course to get more knowledge about fundamental MatLab definitions.

>>What does :),:,1 or 2) means? Why is it 1 or 2?

The imported into HSV is a 3 dimentional array (X - Y for the image and Z for the H, S, V). Colons :)) are used to denote all elements from X and Y,

You access different parts of the color vector and create a new variables (2 dimensional) which shows how this color component is spreaded accross the image. If the conversion is Hue/Saturation/Value then index 1 will bring you the Hue and index 2 - the Saturation. Value (sometimes called brightness) in your case doesn't matter.

The color (or as they call it Hue) range - when colors are represented as HSV it's very easy to define the face color simply with 2 digits - the low and the high boundary, so you simply filter all pixels which fulfil this criteria - color is bigger or less than some values

The same is with saturation - in HSV the tone of the skin can be only valid in some range

thanks a lot for the reply..

can u please also answer my other queries?

thanks..

bug1not
 

Why im should be double - when using imread the output data is in uint8 or uint16 format. But for math calculations the type should be single or double. MatLab uses some automatic conversion of types so in fact you can <write im1 = im;> and the program will continue work in the same way.


I = H+S;
I(find(I==0))=Inf;
you create a new variable I which contains the sum of H and S element by element. If in some cell H+S = 0 it will be changed to infinity. I don't see how this is used in the code later.
 
Why im should be double - when using imread the output data is in uint8 or uint16 format. But for math calculations the type should be single or double. MatLab uses some automatic conversion of types so in fact you can <write im1 = im;> and the program will continue work in the same way.


I = H+S;
I(find(I==0))=Inf;
you create a new variable I which contains the sum of H and S element by element. If in some cell H+S = 0 it will be changed to infinity. I don't see how this is used in the code later.

how about this? how did this functions?

% calc 3D Plot
map = zeros(100,100);
for x = 1:length(H:),1)),
for y = 1:length(S(1,:)),
if ceil(H(x,y)) > 0 & ceil(H(x,y)) < 100,
if ceil(S(x,y)) > 0 & ceil(S(x,y)) < 100,
map(ceil(H(x,y)),ceil(S(x,y))) = map(ceil(H(x,y)),ceil(S(x,y))) +1;
end;
end;
end;
end;

thanks a lot for the help..
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top