- Java 编程示例
- 示例 - 首页
- 示例 - 环境
- 示例 - 字符串
- 示例 - 数组
- 示例 - 日期和时间
- 示例 - 方法
- 示例 - 文件
- 示例 - 目录
- 示例 - 异常
- 示例 - 数据结构
- 示例 - 集合
- 示例 - 网络
- 示例 - 线程
- 示例 - 小程序
- 示例 - 简单图形用户界面
- 示例 - JDBC
- 示例 - 正则表达式
- 示例 - Apache PDF Box
- 示例 - Apache POI PPT
- 示例 - Apache POI Excel
- 示例 - Apache POI Word
- 示例 - OpenCV
- 示例 - Apache Tika
- 示例 - iText
- Java 教程
- Java - 教程
- Java 有用的资源
- Java - 快速指南
- Java - 有用的资源
如何使用 Java 对图像应用模糊
问题说明
如何使用 Java 对图像应用模糊。
解决方案
以下是使用 Java 对图像应用模糊的程序。
import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.core.Point;
import org.opencv.core.Size;
import org.opencv.imgcodecs.Imgcodecs;
import org.opencv.imgproc.Imgproc;
public class BlurToAnImage {
public static void main(String args[]) {
//Loading the OpenCV core library
System.loadLibrary( Core.NATIVE_LIBRARY_NAME );
//Reading the Image from the file and storing it in to a Matrix object
String file = "C:/opencv/logo.jpg";
Mat src = Imgcodecs.imread(file);
//Creating an empty matrix to store the result
Mat dst = new Mat();
//Applying Blur effect on the Image
Imgproc.blur(src, dst, new Size(45, 45), new Point(20, 30), Core.BORDER_DEFAULT);
//blur(Mat src, Mat dst, Size ksize, Point anchor, int borderType)
//Writing the image
Imgcodecs.imwrite("C:/opencv/blurOP.jpg", dst);
System.out.println("Image processed");
}
}
输入
输出
java_opencv
广告