opencv3_java 图片的ROI的领域合成 AddRoi

图片的ROI的领域合成 AddRoi


package opencv_java_demo;

import org.opencv.core.*;
import org.opencv.imgcodecs.*;

public class AddRoi {

	public static void main(String[] args) {
		try{
			System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
			
			Mat src1=Imgcodecs.imread("./images/lenna.jpg");
			Mat src2=Imgcodecs.imread("./images/Sobel.jpg");
			//读取图像到矩阵中
			if(src1.empty()||src2.empty()){
				throw new Exception("no file");
			}
			
			Mat dst = src1.clone();
			
			Rect roiArea=new Rect(src1.width()/4,src1.height()/4,src1.width()/2,src1.height()/2);
			
			Mat src1Roi=new Mat(src1,roiArea);
			Mat src2Roi=new Mat(src2,roiArea);
			Mat dstRoi=new Mat(dst,roiArea);
			Core.add(src1Roi, src2Roi, dstRoi);
			
			Imgcodecs.imwrite("./images/AddRoi.jpg", dst);
		}catch(Exception e){
			System.out.println("例外:" + e);
		}

	}

}




你可能感兴趣的:(java,opencv3)