opencv3_java 图形图像模块化Mozaic Imgproc.resize

图形图像模块化Mozaic Imgproc.resize


package opencv_java_demo;

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

public class Mozaic {

	public static void main(String[] args) {
		try{
			System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
			
			Mat src=Imgcodecs.imread("./images/lenna.jpg");
			//读取图像到矩阵中
			if(src.empty()){
				throw new Exception("no file");
			}
			
			Mat dst = new Mat();
			//复制矩阵进入dst
			
			Imgproc.resize(src,dst,new Size(),0.2,0.2,Imgproc.INTER_NEAREST);
			Imgproc.resize(src,dst,new Size(),1/0.2,1/0.2,Imgproc.INTER_NEAREST);
			
			Imgcodecs.imwrite("./images/Mozaic.jpg", dst);
		}catch(Exception e){
			System.out.println("例外:" + e);
		}

	}

}





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