Ask Your Question
0

extract skin color area from image using opencv in java

asked 2017-10-04 14:03:28 -0600

updated 2017-10-05 01:06:40 -0600

berak gravatar image

i am working on a project in which i want to extract skin color area from image . i have detected the skin color area but that area is white and the non skin area is black so i want to fill that skin color area which is white with skin color to show only skin color object.. here is my code

Mat hsv=new Mat(); Imgproc.cvtColor(srcHSV,hsv,Imgproc.COLOR_BGR2HSV); Core.inRange(hsv,new Scalar(0,58,40),new Scalar(35,174,255),hsv);

i am getting the following result and i want that white area to be filled with skin color

C:\fakepath\hand2.png

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-10-05 01:03:00 -0600

berak gravatar image

updated 2017-10-05 01:24:39 -0600

you can use the binary mask image from inRange() with bitwise_and

Mat combined = Mat.zeros(bgr.size(), bgr.type());

Core.bitwise_and( bgr, bgr, combined, mask );
// or:
bgr.copyTo(combined, mask);
edit flag offensive delete link more

Comments

1

thanks a lot.. i just use the mat.copy() function and copy that mask area to a new image.. that works fine.. here is the code srcHSV.copyTo(out_mat,mask); "srcHSV" is the source image

tehseen gravatar imagetehseen ( 2017-10-05 02:01:19 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2017-10-04 14:03:28 -0600

Seen: 1,050 times

Last updated: Oct 05 '17