opencv3_java 提取图像的RGB三原色分割图像Split Core.split

提取图像的RGB三原色分割图像Split Core.split


package opencv_java_demo;

import java.util.List;

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

public class Split {

	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");
			}
			
			List<Mat> dst=new java.util.ArrayList<Mat>(3);
			Core.split(src, dst);
			
			Imgcodecs.imwrite("./images/b.jpg", dst.get(0));
			Imgcodecs.imwrite("./images/g.jpg", dst.get(1));
			Imgcodecs.imwrite("./images/r.jpg", dst.get(2));
		}catch(Exception e){
			System.out.println("例外:" + e);
		}

	}

}







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