滤波矩阵
用下图做演示
multiply()
顾名思义,乘法函数。使用该函数可以将像素的每个通道值乘以这个参数。
public static void main(String[] args) {
String libraryPath= System.getProperty("user.dir")+"\\lib\\opencv_java460.dll";
System.load(libraryPath);
Mat mat = new Mat(3,3, CvType.CV_8UC3,new Scalar(122,122,122));
System.out.println("mat1>>"+mat.dump());
Core.multiply(mat,new Scalar(0.0,0.5,1.0),mat,3,CvType.CV_8UC3);
System.out.println("mat2>>"+mat.dump()+"=="+mat);
HighGui.imshow("mat",mat);
HighGui.waitKey(0);
}
执行结果
读取图像
示例:
public static void main(String[] args) {
String libraryPath= System.getProperty("user.dir")+"\\lib\\opencv_java460.dll";
System.load(libraryPath);
Mat mat = Imgcodecs.imread("flower.jpg");
Core.multiply(mat,new Scalar(0.0,0.5,1.0),mat,1.0,CvType.CV_8UC3);
HighGui.imshow("mat",mat);
HighGui.waitKey(0);
}
结果
亮度演示:
示例:
public static void main(String[] args) {
String libraryPath= System.getProperty("user.dir")+"\\lib\\opencv_java460.dll";
System.load(libraryPath);
Mat mat = Imgcodecs.imread("flower.jpg");
//为演示效果,将Scalar设为(1.0,1.0,1.0)
Core.multiply(mat,new Scalar(1.0,1.0,1.0),mat,2.0,CvType.CV_8UC3);
HighGui.imshow("mat",mat);
HighGui.waitKey(0);
}
结果: