no commit message

devA
yuxue 5 years ago
parent 6ffda65393
commit 078f942bbc

@ -27,15 +27,25 @@ public class ImageUtil {
public static void main(String[] args) {
String tempPath = DEFAULT_BASE_TEST_PATH ;
String tempPath = DEFAULT_BASE_TEST_PATH + System.currentTimeMillis() + "/";
FileUtil.createDir(tempPath); // 创建文件夹
// String filename = DEFAULT_BASE_TEST_PATH + "test01.jpg";
String filename = DEFAULT_BASE_TEST_PATH + "test.png";
Mat inMat = opencv_imgcodecs.imread(filename);
Boolean debug = true;
// ImageUtil.gaussianBlur(inMat, true, tempPath);
ImageUtil.rgb2Hsv(inMat, true, tempPath);
Mat gsMat = ImageUtil.gaussianBlur(inMat, debug, tempPath);
Mat grey = ImageUtil.grey(gsMat, debug, tempPath);
Mat sobel = ImageUtil.sobel(grey, debug, tempPath);
// ImageUtil.rgb2Hsv(inMat, debug, tempPath);
}
@ -112,6 +122,22 @@ public class ImageUtil {
/**
* 256 1 0
* @param inMat
* @param debug
* @param tempPath
* @return
*/
public static Mat threshold(Mat inMat, Boolean debug, String tempPath) {
Mat dst = new Mat();
opencv_imgproc.threshold(inMat, dst, 0, 255, opencv_imgproc.CV_THRESH_OTSU + opencv_imgproc.CV_THRESH_BINARY);
if (debug) {
opencv_imgcodecs.imwrite(tempPath + "debugThreshold.jpg", dst);
}
return dst;
}

Loading…
Cancel
Save