【发布时间】:2017-04-27 09:20:51
【问题描述】:
我是opencv的新手,我一直在使用CIEXYZ进行皮肤检测。但是我得到了将RGB转换为CIE Lab以获得肤色区域的问题,我根据this从RGB进行了一些计算。
原图
这是二值图像
但我想这样显示
这是我的源代码:
Mat img_color_space = new Mat();
Mat mask = new Mat();
Imgproc.cvtColor(src, img_color_space, colorBgr2hsv);
Imgcodecs.imwrite(path+"CIELAB/hsv.jpg",img_color_space);
Imgproc.blur(img_color_space, img_color_space, new Size(3,3));
Mat canny_output = new Mat();
Scalar minValues = new Scalar(0,10,60);
Scalar maxValues = new Scalar(20,150,255);
// show the current selected HSV range
String valuesToPrint = "Hue range: " + minValues.val[0] + "-" + maxValues.val[0]
+ "\tSaturation range: " + minValues.val[1] + "-" + maxValues.val[1] + "\tValue range: "
+ minValues.val[2] + "-" + maxValues.val[2];
//System.out.println("tresholding:"+valuesToPrint);
Core.inRange(img_color_space, minValues, maxValues, mask);
Imgcodecs.imwrite(path+"CIELAB/mask.jpg",mask);
List<MatOfPoint> contours = new ArrayList<>();
Mat hierarchy = new Mat();
Imgproc.findContours(mask, contours, hierarchy, Imgproc.RETR_TREE, Imgproc.CHAIN_APPROX_SIMPLE,new Point(0,0));
int s = findBiggestContour(contours);
Mat drawing = Mat.zeros(mask.size(), CvType.CV_8UC3);
Imgproc.drawContours(drawing, contours, s, new Scalar(255, 255, 255), -1,8,hierarchy,0,new Point(0,0));
Imgproc.blur(drawing, drawing, new Size(3,3));
Imgcodecs.imwrite(path+"CIELAB/biggest.jpg",drawing);
我的代码有问题吗?提前致谢!
【问题讨论】:
标签: java opencv image-processing