我正在尝试对图像进行自适应阈值处理,但它给了我这个错误:
OpenCV Error: Assertion failed (src.type() == CV_8UC1) in adaptiveThreshold
我似乎无法理解为什么,这是我的代码:
Mat source = Highgui.imread("camera.jpg",
Highgui.CV_LOAD_IMAGE_COLOR);
Mat destination = new Mat(source.rows(),source.cols(),source.type());
Imgproc.cvtColor(source, destination, Imgproc.COLOR_RGB2GRAY);
Highgui.imwrite("grayscale.jpg", destination);
Mat source2 = Highgui.imread("grayscale.jpg",
Highgui.CV_LOAD_IMAGE_COLOR);
Mat destination2 = new Mat(source.rows(),source.cols(),source.type());
Imgproc.adaptiveThreshold(source2, destination2, 255,
Imgproc.ADAPTIVE_THRESH_MEAN_C, Imgproc.THRESH_BINARY_INV, 15, 4);