Example usage for org.opencv.imgproc Imgproc getGaborKernel

List of usage examples for org.opencv.imgproc Imgproc getGaborKernel

Introduction

In this page you can find the example usage for org.opencv.imgproc Imgproc getGaborKernel.

Prototype

public static Mat getGaborKernel(Size ksize, double sigma, double theta, double lambd, double gamma, double psi,
            int ktype) 

Source Link

Usage

From source file:emotion.StaticFunctions.java

public static Mat gabor(Mat image) {
    Mat img = image.clone();// w w w. j  a  v  a  2s . c  o  m

    double ksize = 15;
    double sigme = 4;
    double gamma = 1;
    double psi = 50;
    int lambd[] = new int[] { 5, 6, 7, 10/*,15,13,2*/ };
    double theta[] = new double[] { 180, 200 };
    ArrayList<Mat> kernels = new ArrayList<>();
    for (int i = 0; i < theta.length; i++) {
        for (int j = 0; j < lambd.length; j++) {
            kernels.add(Imgproc.getGaborKernel(new Size(ksize, ksize), sigme, theta[i], lambd[j], gamma, psi,
                    CvType.CV_32F));
        }
    }

    Mat result = new Mat(img.height(), img.width(), img.type(), new Scalar(0, 0, 0));
    for (Mat kernel : kernels) {
        Mat temp = new Mat(img.height(), img.width(), img.type(), new Scalar(0, 0, 0));
        Imgproc.filter2D(img, temp, -1, kernel);
        Core.add(result, temp, result);
    }

    //imwrite("gaborResult.jpg",result);
    return result;
}