From fcb47f382826bd9f2d1789397d2557ce952652e2 Mon Sep 17 00:00:00 2001 From: Jim Martens Date: Tue, 30 May 2017 20:59:32 +0200 Subject: [PATCH] [CCV] Removed hardcoded gabor parameters Signed-off-by: Jim Martens --- ccv/saliency/includes/oriented_pyramid.h | 11 +++++++++-- ccv/saliency/oriented_pyramid.cpp | 16 ++++++++-------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/ccv/saliency/includes/oriented_pyramid.h b/ccv/saliency/includes/oriented_pyramid.h index 3620c38..e058651 100644 --- a/ccv/saliency/includes/oriented_pyramid.h +++ b/ccv/saliency/includes/oriented_pyramid.h @@ -14,15 +14,22 @@ private: /** * Initializes the Gabor filters. * @param num_orientations the number of orientations to use + * @param size the size of the Gabor filter + * @param wavelength the wavelength + * @param standard_deviation the standard deviation */ - void initialize_gabor_filters(float num_orientations); + void initialize_gabor_filters(float num_orientations, int size, double wavelength, double standard_deviation); public: /** * Initializes the oriented pyramid. * @param pyramid the laplacian pyramid * @param num_orientations the number of Gabor filters to apply + * @param size the size of the Gabor filter + * @param wavelength the wavelength + * @param standard_deviation the standard deviation */ - oriented_pyramid(const laplacian_pyramid& pyramid, int num_orientations); + oriented_pyramid(const laplacian_pyramid& pyramid, int num_orientations, int size, + double wavelength, double standard_deviation); /** * Computes the feature maps. diff --git a/ccv/saliency/oriented_pyramid.cpp b/ccv/saliency/oriented_pyramid.cpp index da89373..467a664 100644 --- a/ccv/saliency/oriented_pyramid.cpp +++ b/ccv/saliency/oriented_pyramid.cpp @@ -1,12 +1,13 @@ #include "includes/oriented_pyramid.h" #include "includes/fusion.h" -oriented_pyramid::oriented_pyramid(const laplacian_pyramid &pyramid, int num_orientations) { +oriented_pyramid::oriented_pyramid(const laplacian_pyramid &pyramid, int num_orientations, int size, + double wavelength, double standard_deviation) { _gabor_filters = std::vector(); _orientation_maps = std::vector>(); _feature_maps = std::vector(); - initialize_gabor_filters(num_orientations); + initialize_gabor_filters(num_orientations, size, wavelength, standard_deviation); unsigned long number_of_layers = pyramid.get_number_of_layers(); for (unsigned long i = 0; i < num_orientations; i++) { std::vector orientation_vector = std::vector(); @@ -20,14 +21,13 @@ oriented_pyramid::oriented_pyramid(const laplacian_pyramid &pyramid, int num_ori } -void oriented_pyramid::initialize_gabor_filters(float num_orientations) { - cv::Size size = cv::Size(20, 20); - double wavelength = 3; - double standard_deviation = 18; +void oriented_pyramid::initialize_gabor_filters(float num_orientations, int size, + double wavelength, double standard_deviation) { + cv::Size size_obj = cv::Size(size, size); double start_level = num_orientations / 2.0; for (double level = start_level; level >= 0; level--) { - _gabor_filters.push_back(cv::getGaborKernel(size, standard_deviation, (level/num_orientations) * CV_PI, wavelength, + _gabor_filters.push_back(cv::getGaborKernel(size_obj, standard_deviation, (level/num_orientations) * CV_PI, wavelength, 1, 0, CV_32F)); } @@ -35,7 +35,7 @@ void oriented_pyramid::initialize_gabor_filters(float num_orientations) { start_level = num_orientations - 1; for (double level = start_level; level > end_level; level--) { - _gabor_filters.push_back(cv::getGaborKernel(size, standard_deviation, (level/num_orientations) * CV_PI, wavelength, + _gabor_filters.push_back(cv::getGaborKernel(size_obj, standard_deviation, (level/num_orientations) * CV_PI, wavelength, 1, 0, CV_32F)); } }