Javaexamples-apply-blur-to-image

提供:Dev Guides
移動先:案内検索

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");
   }
}

入力

OpenCV Copy Input

出力

ぼかした画像