Prepare to merge KAZE and AKAZE nldiffusion_functions source files (work in progress).
authorIevgen Khvedchenia <ekhvedchenya@gmail.com>
Thu, 1 May 2014 15:27:24 +0000 (18:27 +0300)
committerIevgen Khvedchenia <ekhvedchenya@gmail.com>
Thu, 1 May 2014 15:27:24 +0000 (18:27 +0300)
modules/features2d/src/akaze/AKAZEFeatures.cpp
modules/features2d/src/akaze/fed.h [deleted file]
modules/features2d/src/akaze/nldiffusion_functions.cpp
modules/features2d/src/akaze/nldiffusion_functions.h
modules/features2d/src/kaze/fed.h
modules/features2d/src/kaze/nldiffusion_functions.cpp

index 4f33508..dd7876d 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #include "AKAZEFeatures.h"
-#include "fed.h"
+#include "../kaze/fed.h"
 #include "nldiffusion_functions.h"
 
 using namespace std;
diff --git a/modules/features2d/src/akaze/fed.h b/modules/features2d/src/akaze/fed.h
deleted file mode 100644 (file)
index 4ac82f6..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-#ifndef FED_H
-#define FED_H
-
-//******************************************************************************
-//******************************************************************************
-
-// Includes
-#include <iostream>
-#include <vector>
-
-//*************************************************************************************
-//*************************************************************************************
-
-// Declaration of functions
-int fed_tau_by_process_time(const float& T, const int& M, const float& tau_max,
-                            const bool& reordering, std::vector<float>& tau);
-int fed_tau_by_cycle_time(const float& t, const float& tau_max,
-                          const bool& reordering, std::vector<float> &tau) ;
-int fed_tau_internal(const int& n, const float& scale, const float& tau_max,
-                     const bool& reordering, std::vector<float> &tau);
-bool fed_is_prime_internal(const int& number);
-
-//*************************************************************************************
-//*************************************************************************************
-
-#endif // FED_H
index e0e2990..f64e504 100644 (file)
@@ -235,7 +235,6 @@ namespace cv {
              * @param scale Scale factor for the derivative size
              */
             void compute_scharr_derivatives(const cv::Mat& src, cv::Mat& dst, int xorder, int yorder, int scale) {
-
                 Mat kx, ky;
                 compute_derivative_kernels(kx, ky, xorder, yorder, scale);
                 sepFilter2D(src, dst, CV_32F, kx, ky);
@@ -243,6 +242,58 @@ namespace cv {
 
             /* ************************************************************************* */
             /**
+             * @brief Compute Scharr derivative kernels for sizes different than 3
+             * @param kx_ The derivative kernel in x-direction
+             * @param ky_ The derivative kernel in y-direction
+             * @param dx The derivative order in x-direction
+             * @param dy The derivative order in y-direction
+             * @param scale The kernel size
+             */
+            void compute_derivative_kernels(cv::OutputArray kx_, cv::OutputArray ky_, int dx, int dy, int scale) {
+
+                const int ksize = 3 + 2 * (scale - 1);
+
+                // The usual Scharr kernel
+                if (scale == 1) {
+                    getDerivKernels(kx_, ky_, dx, dy, 0, true, CV_32F);
+                    return;
+                }
+
+                kx_.create(ksize, 1, CV_32F, -1, true);
+                ky_.create(ksize, 1, CV_32F, -1, true);
+                Mat kx = kx_.getMat();
+                Mat ky = ky_.getMat();
+
+                float w = 10.0f / 3.0f;
+                float norm = 1.0f / (2.0f*scale*(w + 2.0f));
+
+                for (int k = 0; k < 2; k++) {
+                    Mat* kernel = k == 0 ? &kx : &ky;
+                    int order = k == 0 ? dx : dy;
+                    float kerI[1000];
+
+                    for (int t = 0; t < ksize; t++) {
+                        kerI[t] = 0;
+                    }
+
+                    if (order == 0) {
+                        kerI[0] = norm;
+                        kerI[ksize / 2] = w*norm;
+                        kerI[ksize - 1] = norm;
+                    }
+                    else if (order == 1) {
+                        kerI[0] = -1;
+                        kerI[ksize / 2] = 0;
+                        kerI[ksize - 1] = 1;
+                    }
+
+                    Mat temp(kernel->rows, kernel->cols, CV_32F, &kerI[0]);
+                    temp.copyTo(*kernel);
+                }
+            }
+
+            /* ************************************************************************* */
+            /**
              * @brief This function performs a scalar non-linear diffusion step
              * @param Ld2 Output image in the evolution
              * @param c Conductivity image
@@ -302,27 +353,6 @@ namespace cv {
 
             /* ************************************************************************* */
             /**
-             * @brief This function downsamples the input image with the kernel [1/4,1/2,1/4]
-             * @param img Input image to be downsampled
-             * @param dst Output image with half of the resolution of the input image
-             */
-            void downsample_image(const cv::Mat& src, cv::Mat& dst) {
-
-                int i1 = 0, j1 = 0, i2 = 0, j2 = 0;
-
-                for (i1 = 1; i1 < src.rows; i1 += 2) {
-                    j2 = 0;
-                    for (j1 = 1; j1 < src.cols; j1 += 2) {
-                        *(dst.ptr<float>(i2)+j2) = 0.5f*(*(src.ptr<float>(i1)+j1)) + 0.25f*(*(src.ptr<float>(i1)+j1 - 1) + *(src.ptr<float>(i1)+j1 + 1));
-                        j2++;
-                    }
-
-                    i2++;
-                }
-            }
-
-            /* ************************************************************************* */
-            /**
              * @brief This function downsamples the input image using OpenCV resize
              * @param img Input image to be downsampled
              * @param dst Output image with half of the resolution of the input image
@@ -335,57 +365,7 @@ namespace cv {
                 resize(src, dst, dst.size(), 0, 0, cv::INTER_AREA);
             }
 
-            /* ************************************************************************* */
-            /**
-             * @brief Compute Scharr derivative kernels for sizes different than 3
-             * @param kx_ The derivative kernel in x-direction
-             * @param ky_ The derivative kernel in y-direction
-             * @param dx The derivative order in x-direction
-             * @param dy The derivative order in y-direction
-             * @param scale The kernel size
-             */
-            void compute_derivative_kernels(cv::OutputArray kx_, cv::OutputArray ky_, int dx, int dy, int scale) {
-
-                const int ksize = 3 + 2 * (scale - 1);
-
-                // The usual Scharr kernel
-                if (scale == 1) {
-                    getDerivKernels(kx_, ky_, dx, dy, 0, true, CV_32F);
-                    return;
-                }
 
-                kx_.create(ksize, 1, CV_32F, -1, true);
-                ky_.create(ksize, 1, CV_32F, -1, true);
-                Mat kx = kx_.getMat();
-                Mat ky = ky_.getMat();
-
-                float w = 10.0f / 3.0f;
-                float norm = 1.0f / (2.0f*scale*(w + 2.0f));
-
-                for (int k = 0; k < 2; k++) {
-                    Mat* kernel = k == 0 ? &kx : &ky;
-                    int order = k == 0 ? dx : dy;
-                    float kerI[1000];
-
-                    for (int t = 0; t < ksize; t++) {
-                        kerI[t] = 0;
-                    }
-
-                    if (order == 0) {
-                        kerI[0] = norm;
-                        kerI[ksize / 2] = w*norm;
-                        kerI[ksize - 1] = norm;
-                    }
-                    else if (order == 1) {
-                        kerI[0] = -1;
-                        kerI[ksize / 2] = 0;
-                        kerI[ksize - 1] = 1;
-                    }
-
-                    Mat temp(kernel->rows, kernel->cols, CV_32F, &kerI[0]);
-                    temp.copyTo(*kernel);
-                }
-            }
         }
     }
 }
\ No newline at end of file
index 0fab6c5..b6dd2e8 100644 (file)
@@ -28,7 +28,6 @@ namespace cv {
             float compute_k_percentile(const cv::Mat& img, float perc, float gscale, int nbins, int ksize_x, int ksize_y);
             void compute_scharr_derivatives(const cv::Mat& src, cv::Mat& dst, int xorder, int, int scale);
             void nld_step_scalar(cv::Mat& Ld, const cv::Mat& c, cv::Mat& Lstep, const float& stepsize);
-            void downsample_image(const cv::Mat& src, cv::Mat& dst);
             void halfsample_image(const cv::Mat& src, cv::Mat& dst);
             void compute_derivative_kernels(cv::OutputArray kx_, cv::OutputArray ky_, int dx, int dy, int scale);
             bool check_maximum_neighbourhood(const cv::Mat& img, int dsize, float value, int row, int col, bool same_img);
index d9e8c49..c313b81 100644 (file)
@@ -5,11 +5,6 @@
 //******************************************************************************
 
 // Includes
-#include <iostream>
-#include <stdlib.h>
-#include <stdio.h>
-#include <cstdlib>
-#include <math.h>
 #include <vector>
 
 //*************************************************************************************
index 23ffaf1..a24a1a5 100644 (file)
 // Namespaces
 using namespace std;
 using namespace cv;
-using namespace cv::details::kaze;
 
-//*************************************************************************************
-//*************************************************************************************
+/* ************************************************************************* */
 
 namespace cv {
     namespace details {
         namespace kaze {
+
+            /* ************************************************************************* */
             /**
              * @brief This function smoothes an image with a Gaussian kernel
              * @param src Input image
@@ -44,8 +44,7 @@ namespace cv {
              * @param ksize_y Kernel size in Y-direction (vertical)
              * @param sigma Kernel standard deviation
              */
-            void gaussian_2D_convolution(const cv::Mat& src, cv::Mat& dst,
-                int ksize_x, int ksize_y, float sigma) {
+            void gaussian_2D_convolution(const cv::Mat& src, cv::Mat& dst, int ksize_x, int ksize_y, float sigma) {
 
                 int ksize_x_ = 0, ksize_y_ = 0;
 
@@ -68,9 +67,7 @@ namespace cv {
                 GaussianBlur(src, dst, Size(ksize_x_, ksize_y_), sigma, sigma, cv::BORDER_REPLICATE);
             }
 
-            //*************************************************************************************
-            //*************************************************************************************
-
+            /* ************************************************************************* */
             /**
              * @brief This function computes the Perona and Malik conductivity coefficient g1
              * g1 = exp(-|dL|^2/k^2)
@@ -83,9 +80,7 @@ namespace cv {
                 cv::exp(-(Lx.mul(Lx) + Ly.mul(Ly)) / (k*k), dst);
             }
 
-            //*************************************************************************************
-            //*************************************************************************************
-
+            /* ************************************************************************* */
             /**
              * @brief This function computes the Perona and Malik conductivity coefficient g2
              * g2 = 1 / (1 + dL^2 / k^2)
@@ -98,9 +93,7 @@ namespace cv {
                 dst = 1. / (1. + (Lx.mul(Lx) + Ly.mul(Ly)) / (k*k));
             }
 
-            //*************************************************************************************
-            //*************************************************************************************
-
+            /* ************************************************************************* */
             /**
              * @brief This function computes Weickert conductivity coefficient g3
              * @param Lx First order image derivative in X-direction (horizontal)
@@ -118,9 +111,7 @@ namespace cv {
                 dst = 1.0f - dst;
             }
 
-            //*************************************************************************************
-            //*************************************************************************************
-
+            /* ************************************************************************* */
             /**
              * @brief This function computes a good empirical value for the k contrast factor
              * given an input image, the percentile (0-1), the gradient scale and the number of
@@ -208,9 +199,7 @@ namespace cv {
                 return kperc;
             }
 
-            //*************************************************************************************
-            //*************************************************************************************
-
+            /* ************************************************************************* */
             /**
              * @brief This function computes Scharr image derivatives
              * @param src Input image
@@ -219,16 +208,13 @@ namespace cv {
              * @param yorder Derivative order in Y-direction (vertical)
              * @param scale Scale factor or derivative size
              */
-            void compute_scharr_derivatives(const cv::Mat& src, cv::Mat& dst,
-                int xorder, int yorder, int scale) {
+            void compute_scharr_derivatives(const cv::Mat& src, cv::Mat& dst, int xorder, int yorder, int scale) {
                 Mat kx, ky;
                 compute_derivative_kernels(kx, ky, xorder, yorder, scale);
                 sepFilter2D(src, dst, CV_32F, kx, ky);
             }
 
-            //*************************************************************************************
-            //*************************************************************************************
-
+            /* ************************************************************************* */
             /**
              * @brief Compute derivative kernels for sizes different than 3
              * @param _kx Horizontal kernel values
@@ -237,8 +223,7 @@ namespace cv {
              * @param dy Derivative order in Y-direction (vertical)
              * @param scale_ Scale factor or derivative size
              */
-            void compute_derivative_kernels(cv::OutputArray _kx, cv::OutputArray _ky,
-                int dx, int dy, int scale) {
+            void compute_derivative_kernels(cv::OutputArray _kx, cv::OutputArray _ky, int dx, int dy, int scale) {
 
                 int ksize = 3 + 2 * (scale - 1);
 
@@ -273,9 +258,7 @@ namespace cv {
                 }
             }
 
-            //*************************************************************************************
-            //*************************************************************************************
-
+            /* ************************************************************************* */
             /**
              * @brief This function performs a scalar non-linear diffusion step
              * @param Ld2 Output image in the evolution
@@ -336,9 +319,7 @@ namespace cv {
                 Ld = Ld + Lstep;
             }
 
-            //*************************************************************************************
-            //*************************************************************************************
-
+            /* ************************************************************************* */
             /**
              * @brief This function checks if a given pixel is a maximum in a local neighbourhood
              * @param img Input image where we will perform the maximum search
@@ -349,8 +330,7 @@ namespace cv {
              * @param same_img Flag to indicate if the image value at (x,y) is in the input image
              * @return 1->is maximum, 0->otherwise
              */
-            bool check_maximum_neighbourhood(const cv::Mat& img, int dsize, float value,
-                int row, int col, bool same_img) {
+            bool check_maximum_neighbourhood(const cv::Mat& img, int dsize, float value, int row, int col, bool same_img) {
 
                 bool response = true;