I have successfully detected skin color but not able to understand the working of find function in it.

2 views (last 30 days)
I have successfully executed below code but i am not getting what does it means?
img_ycbcr = rgb2ycbcr(img);
Cb = img_ycbcr(:,:,2);
Cr = img_ycbcr(:,:,3);
y = img_ycbcr(:,:,1);
%Detect Skin
[r,c,v] = find(Cb>=86 & Cb<135 & Cr>=136 & Cr<180 & y>80);
my question is what comes under r, c,v . what does they store?
in my example Cb,Cr,Y are of size [501X401]
and r,c,v are of size [76901 X 1] what find function does and how to write it in mathematical terms?
thank you in advance.

Answers (1)

Daniel Pollard
Daniel Pollard on 11 Dec 2020
It's tricky to say when we can't run the code, but I'll give it my best shot.
It seems like the code imports an image. The image file is an array of size 501x401x3. The 501x401 represents the size of the image in pixels, and the 3 is because there are three "versions" of the image file; red, green and blue. This code seperates them out, so Cr is one part of the image (probably red), Cb is another (probably blue) and y is the third.
find is a Matlab built in function which finds the indices of an array which satisfy a condition. You can read the (excellent) documentation
to see more details. In your code what it's doing is storing the indices in Cb which have values greater than or equal to 86, indices in Cb which are less than 135, and so on.
Use the Matlab documentation to help you out with questions about specific functions. Type help find or doc find into the Matlab command window to read it.

Categories

Find more on Convert Image Type in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!