public void testInpaint2() {
//原图
Mat imageSource=Imgcodecs.imread("D:\\360MoveData\\Users\\lxn\\Desktop\\opencv\\xf.jpg");
Mat imageGray=new Mat();
Mat dts=new Mat(imageSource.size(), CvType.CV_8SC3);
//转换为灰度图
Imgproc.cvtColor(imageSource, imageGray, Imgproc.COLOR_BGR2GRAY);
Mat imageMask =new Mat(imageSource.size(), CvType.CV_8UC1, new Scalar(0,0,0));
Imgproc.threshold(imageGray, imageMask, 150, 160, Imgproc.THRESH_BINARY);
int width=imageSource.cols();
int height=imageSource.rows();
Mat imageMask1=new Mat(imageMask.size(), CvType.CV_8UC1, new Scalar(0));
Mat mat=imageMask.submat(new Rect(new Point(width-200,height-50), new Point(width,height)));
Mat blurMat=new Mat();
Imgproc.GaussianBlur(mat, blurMat, new Size(5, 5), 3);
Rect rect=new Rect(new Point(width-200,height-50),mat.size());
blurMat.copyTo(imageMask1.submat(rect));
HighGui.imshow("修复前",imageSource);
HighGui.imshow("修复模板", imageMask1);
Photo.inpaint(imageSource, imageMask1, dts, 5, Photo.INPAINT_TELEA);
HighGui.imshow("修复结果", dts);
HighGui.waitKey(0);
}
public static void main(String[] args) throws Exception {
ResourceBundle bundle = ResourceBundle.getBundle("opencv");
String opencvDllName = bundle.getString("opencv.dllpath");
System.load(opencvDllName);
new PhotoTest().testInpaint2();
}