public Mat erodeMat(Mat src) { // 读取图像 //Mat src = Imgcodecs.imread("test.pgm"); // 定义结构元素 Mat kernel = new Mat(31, 31, CvType.CV_8UC1, new Scalar(1)); Point anchor = new Point(-1, -1); double delta = 0; int ddepth = -1; // 膨胀图像 Mat dst = new Mat(); //Imgproc.dilate(src, dst, kernel, anchor, 1); Imgproc.erode(src, dst, kernel); return dst; }
##############