Wrapped nldiffusion functions with details::kaze or details::amaze namespace to avoid collision of function names
This commit is contained in:
parent
c68cbfced3
commit
c1bf453266
@ -114,7 +114,7 @@ struct AKAZEOptions {
|
|||||||
|
|
||||||
float kcontrast; ///< The contrast factor parameter
|
float kcontrast; ///< The contrast factor parameter
|
||||||
float kcontrast_percentile; ///< Percentile level for the contrast factor
|
float kcontrast_percentile; ///< Percentile level for the contrast factor
|
||||||
size_t kcontrast_nbins; ///< Number of bins for the contrast factor histogram
|
int kcontrast_nbins; ///< Number of bins for the contrast factor histogram
|
||||||
|
|
||||||
bool save_scale_space; ///< Set to true for saving the scale space images
|
bool save_scale_space; ///< Set to true for saving the scale space images
|
||||||
bool save_keypoints; ///< Set to true for saving the detected keypoints and descriptors
|
bool save_keypoints; ///< Set to true for saving the detected keypoints and descriptors
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace cv;
|
using namespace cv;
|
||||||
|
using namespace cv::details::akaze;
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
/**
|
/**
|
||||||
@ -110,8 +111,7 @@ int AKAZEFeatures::Create_Nonlinear_Scale_Space(const cv::Mat& img) {
|
|||||||
evolution_[0].Lt.copyTo(evolution_[0].Lsmooth);
|
evolution_[0].Lt.copyTo(evolution_[0].Lsmooth);
|
||||||
|
|
||||||
// First compute the kcontrast factor
|
// First compute the kcontrast factor
|
||||||
options_.kcontrast = compute_k_percentile(img, options_.kcontrast_percentile,
|
options_.kcontrast = compute_k_percentile(img, options_.kcontrast_percentile, 1.0f, options_.kcontrast_nbins, 0, 0);
|
||||||
1.0f, options_.kcontrast_nbins, 0, 0);
|
|
||||||
|
|
||||||
//t2 = cv::getTickCount();
|
//t2 = cv::getTickCount();
|
||||||
//timing_.kcontrast = 1000.0*(t2 - t1) / cv::getTickFrequency();
|
//timing_.kcontrast = 1000.0*(t2 - t1) / cv::getTickFrequency();
|
||||||
|
@ -19,11 +19,15 @@
|
|||||||
* @author Pablo F. Alcantarilla, Jesus Nuevo
|
* @author Pablo F. Alcantarilla, Jesus Nuevo
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "nldiffusion_functions.h"
|
#include "akaze/nldiffusion_functions.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace cv;
|
using namespace cv;
|
||||||
|
|
||||||
|
namespace cv {
|
||||||
|
namespace details {
|
||||||
|
namespace akaze {
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
/**
|
/**
|
||||||
* @brief This function smoothes an image with a Gaussian kernel
|
* @brief This function smoothes an image with a Gaussian kernel
|
||||||
@ -33,8 +37,7 @@ using namespace cv;
|
|||||||
* @param ksize_y Kernel size in Y-direction (vertical)
|
* @param ksize_y Kernel size in Y-direction (vertical)
|
||||||
* @param sigma Kernel standard deviation
|
* @param sigma Kernel standard deviation
|
||||||
*/
|
*/
|
||||||
void gaussian_2D_convolution(const cv::Mat& src, cv::Mat& dst, const size_t& ksize_x,
|
void gaussian_2D_convolution(const cv::Mat& src, cv::Mat& dst, int ksize_x, int ksize_y, float sigma) {
|
||||||
const size_t& ksize_y, const float& sigma) {
|
|
||||||
|
|
||||||
int ksize_x_ = 0, ksize_y_ = 0;
|
int ksize_x_ = 0, ksize_y_ = 0;
|
||||||
|
|
||||||
@ -148,16 +151,15 @@ void charbonnier_diffusivity(const cv::Mat& Lx, const cv::Mat& Ly, cv::Mat& dst,
|
|||||||
* @param ksize_y Kernel size in Y-direction (vertical) for the Gaussian smoothing kernel
|
* @param ksize_y Kernel size in Y-direction (vertical) for the Gaussian smoothing kernel
|
||||||
* @return k contrast factor
|
* @return k contrast factor
|
||||||
*/
|
*/
|
||||||
float compute_k_percentile(const cv::Mat& img, float perc, float gscale,
|
float compute_k_percentile(const cv::Mat& img, float perc, float gscale, int nbins, int ksize_x, int ksize_y) {
|
||||||
size_t nbins, size_t ksize_x, size_t ksize_y) {
|
|
||||||
|
|
||||||
size_t nbin = 0, nelements = 0, nthreshold = 0, k = 0;
|
int nbin = 0, nelements = 0, nthreshold = 0, k = 0;
|
||||||
float kperc = 0.0, modg = 0.0, lx = 0.0, ly = 0.0;
|
float kperc = 0.0, modg = 0.0, lx = 0.0, ly = 0.0;
|
||||||
float npoints = 0.0;
|
float npoints = 0.0;
|
||||||
float hmax = 0.0;
|
float hmax = 0.0;
|
||||||
|
|
||||||
// Create the array for the histogram
|
// Create the array for the histogram
|
||||||
std::vector<size_t> hist(nbins, 0);
|
std::vector<int> hist(nbins, 0);
|
||||||
|
|
||||||
// Create the matrices
|
// Create the matrices
|
||||||
cv::Mat gaussian = cv::Mat::zeros(img.rows, img.cols, CV_32F);
|
cv::Mat gaussian = cv::Mat::zeros(img.rows, img.cols, CV_32F);
|
||||||
@ -194,7 +196,7 @@ float compute_k_percentile(const cv::Mat& img, float perc, float gscale,
|
|||||||
|
|
||||||
// Find the correspondent bin
|
// Find the correspondent bin
|
||||||
if (modg != 0.0) {
|
if (modg != 0.0) {
|
||||||
nbin = (size_t)floor(nbins*(modg / hmax));
|
nbin = (int)floor(nbins*(modg / hmax));
|
||||||
|
|
||||||
if (nbin == nbins) {
|
if (nbin == nbins) {
|
||||||
nbin--;
|
nbin--;
|
||||||
@ -207,7 +209,7 @@ float compute_k_percentile(const cv::Mat& img, float perc, float gscale,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Now find the perc of the histogram percentile
|
// Now find the perc of the histogram percentile
|
||||||
nthreshold = (size_t)(npoints*perc);
|
nthreshold = (int)(npoints*perc);
|
||||||
|
|
||||||
for (k = 0; nelements < nthreshold && k < nbins; k++) {
|
for (k = 0; nelements < nthreshold && k < nbins; k++) {
|
||||||
nelements = nelements + hist[k];
|
nelements = nelements + hist[k];
|
||||||
@ -384,3 +386,6 @@ void compute_derivative_kernels(cv::OutputArray kx_, cv::OutputArray ky_, int dx
|
|||||||
temp.copyTo(*kernel);
|
temp.copyTo(*kernel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -5,7 +5,8 @@
|
|||||||
* @author Pablo F. Alcantarilla, Jesus Nuevo
|
* @author Pablo F. Alcantarilla, Jesus Nuevo
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#ifndef AKAZE_NLDIFFUSION_FUNCTIONS_H
|
||||||
|
#define AKAZE_NLDIFFUSION_FUNCTIONS_H
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
// Includes
|
// Includes
|
||||||
@ -13,20 +14,27 @@
|
|||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
// Declaration of functions
|
// Declaration of functions
|
||||||
void gaussian_2D_convolution(const cv::Mat& src, cv::Mat& dst, const size_t& ksize_x,
|
|
||||||
const size_t& ksize_y, const float& sigma);
|
namespace cv {
|
||||||
void image_derivatives_scharr(const cv::Mat& src, cv::Mat& dst,
|
namespace details {
|
||||||
const size_t& xorder, const size_t& yorder);
|
namespace akaze {
|
||||||
|
|
||||||
|
void gaussian_2D_convolution(const cv::Mat& src, cv::Mat& dst, int ksize_x, int ksize_y, float sigma);
|
||||||
|
void image_derivatives_scharr(const cv::Mat& src, cv::Mat& dst, int xorder, int yorder);
|
||||||
void pm_g1(const cv::Mat& Lx, const cv::Mat& Ly, cv::Mat& dst, const float& k);
|
void pm_g1(const cv::Mat& Lx, const cv::Mat& Ly, cv::Mat& dst, const float& k);
|
||||||
void pm_g2(const cv::Mat& Lx, const cv::Mat& Ly, cv::Mat& dst, const float& k);
|
void pm_g2(const cv::Mat& Lx, const cv::Mat& Ly, cv::Mat& dst, const float& k);
|
||||||
void weickert_diffusivity(const cv::Mat& Lx, const cv::Mat& Ly, cv::Mat& dst, const float& k);
|
void weickert_diffusivity(const cv::Mat& Lx, const cv::Mat& Ly, cv::Mat& dst, const float& k);
|
||||||
void charbonnier_diffusivity(const cv::Mat& Lx, const cv::Mat& Ly, cv::Mat& dst, const float& k);
|
void charbonnier_diffusivity(const cv::Mat& Lx, const cv::Mat& Ly, cv::Mat& dst, const float& k);
|
||||||
float compute_k_percentile(const cv::Mat& img, float perc, float gscale,
|
float compute_k_percentile(const cv::Mat& img, float perc, float gscale, int nbins, int ksize_x, int ksize_y);
|
||||||
size_t nbins, size_t ksize_x, size_t ksize_y);
|
|
||||||
void compute_scharr_derivatives(const cv::Mat& src, cv::Mat& dst, int xorder, int, int scale);
|
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 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 downsample_image(const cv::Mat& src, cv::Mat& dst);
|
||||||
void halfsample_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);
|
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,
|
bool check_maximum_neighbourhood(const cv::Mat& img, int dsize, float value, int row, int col, bool same_img);
|
||||||
int row, int col, bool same_img);
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
// Namespaces
|
// Namespaces
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace cv;
|
using namespace cv;
|
||||||
|
using namespace cv::details::kaze;
|
||||||
|
|
||||||
//*******************************************************************************
|
//*******************************************************************************
|
||||||
//*******************************************************************************
|
//*******************************************************************************
|
||||||
|
@ -28,10 +28,14 @@
|
|||||||
// Namespaces
|
// Namespaces
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace cv;
|
using namespace cv;
|
||||||
|
using namespace cv::details::kaze;
|
||||||
|
|
||||||
//*************************************************************************************
|
//*************************************************************************************
|
||||||
//*************************************************************************************
|
//*************************************************************************************
|
||||||
|
|
||||||
|
namespace cv {
|
||||||
|
namespace details {
|
||||||
|
namespace kaze {
|
||||||
/**
|
/**
|
||||||
* @brief This function smoothes an image with a Gaussian kernel
|
* @brief This function smoothes an image with a Gaussian kernel
|
||||||
* @param src Input image
|
* @param src Input image
|
||||||
@ -129,8 +133,7 @@ void weickert_diffusivity(const cv::Mat& Lx, const cv::Mat& Ly, cv::Mat& dst, fl
|
|||||||
* @param ksize_y Kernel size in Y-direction (vertical) for the Gaussian smoothing kernel
|
* @param ksize_y Kernel size in Y-direction (vertical) for the Gaussian smoothing kernel
|
||||||
* @return k contrast factor
|
* @return k contrast factor
|
||||||
*/
|
*/
|
||||||
float compute_k_percentile(const cv::Mat& img, float perc, float gscale,
|
float compute_k_percentile(const cv::Mat& img, float perc, float gscale, int nbins, int ksize_x, int ksize_y) {
|
||||||
int nbins, int ksize_x, int ksize_y) {
|
|
||||||
|
|
||||||
int nbin = 0, nelements = 0, nthreshold = 0, k = 0;
|
int nbin = 0, nelements = 0, nthreshold = 0, k = 0;
|
||||||
float kperc = 0.0, modg = 0.0, lx = 0.0, ly = 0.0;
|
float kperc = 0.0, modg = 0.0, lx = 0.0, ly = 0.0;
|
||||||
@ -374,3 +377,6 @@ bool check_maximum_neighbourhood(const cv::Mat& img, int dsize, float value,
|
|||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @file nldiffusion_functions.h
|
* @file nldiffusion_functions.h
|
||||||
* @brief Functions for non-linear diffusion applications:
|
* @brief Functions for non-linear diffusion applications:
|
||||||
@ -9,43 +8,40 @@
|
|||||||
* @author Pablo F. Alcantarilla
|
* @author Pablo F. Alcantarilla
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef NLDIFFUSION_FUNCTIONS_H_
|
#ifndef KAZE_NLDIFFUSION_FUNCTIONS_H
|
||||||
#define NLDIFFUSION_FUNCTIONS_H_
|
#define KAZE_NLDIFFUSION_FUNCTIONS_H
|
||||||
|
|
||||||
//******************************************************************************
|
|
||||||
//******************************************************************************
|
|
||||||
|
|
||||||
// Includes
|
// Includes
|
||||||
#include "config.h"
|
#include "precomp.hpp"
|
||||||
|
|
||||||
//*************************************************************************************
|
//*************************************************************************************
|
||||||
//*************************************************************************************
|
//*************************************************************************************
|
||||||
|
|
||||||
|
namespace cv {
|
||||||
|
namespace details {
|
||||||
|
namespace kaze {
|
||||||
|
|
||||||
// Gaussian 2D convolution
|
// Gaussian 2D convolution
|
||||||
void gaussian_2D_convolution(const cv::Mat& src, cv::Mat& dst,
|
void gaussian_2D_convolution(const cv::Mat& src, cv::Mat& dst, int ksize_x, int ksize_y, float sigma);
|
||||||
int ksize_x, int ksize_y, float sigma);
|
|
||||||
|
|
||||||
// Diffusivity functions
|
// Diffusivity functions
|
||||||
void pm_g1(const cv::Mat& Lx, const cv::Mat& Ly, cv::Mat& dst, float k);
|
void pm_g1(const cv::Mat& Lx, const cv::Mat& Ly, cv::Mat& dst, float k);
|
||||||
void pm_g2(const cv::Mat& Lx, const cv::Mat& Ly, cv::Mat& dst, float k);
|
void pm_g2(const cv::Mat& Lx, const cv::Mat& Ly, cv::Mat& dst, float k);
|
||||||
void weickert_diffusivity(const cv::Mat& Lx, const cv::Mat& Ly, cv::Mat& dst, float k);
|
void weickert_diffusivity(const cv::Mat& Lx, const cv::Mat& Ly, cv::Mat& dst, float k);
|
||||||
float compute_k_percentile(const cv::Mat& img, float perc, float gscale,
|
float compute_k_percentile(const cv::Mat& img, float perc, float gscale, int nbins, int ksize_x, int ksize_y);
|
||||||
int nbins, int ksize_x, int ksize_y);
|
|
||||||
|
|
||||||
// Image derivatives
|
// Image derivatives
|
||||||
void compute_scharr_derivatives(const cv::Mat& src, cv::Mat& dst,
|
void compute_scharr_derivatives(const cv::Mat& src, cv::Mat& dst, int xorder, int yorder, int scale);
|
||||||
int xorder, int yorder, int scale);
|
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);
|
|
||||||
|
|
||||||
// Nonlinear diffusion filtering scalar step
|
// Nonlinear diffusion filtering scalar step
|
||||||
void nld_step_scalar(cv::Mat& Ld, const cv::Mat& c, cv::Mat& Lstep, float stepsize);
|
void nld_step_scalar(cv::Mat& Ld, const cv::Mat& c, cv::Mat& Lstep, float stepsize);
|
||||||
|
|
||||||
// For non-maxima suppresion
|
// For non-maxima suppresion
|
||||||
bool check_maximum_neighbourhood(const cv::Mat& img, int dsize, float value,
|
bool check_maximum_neighbourhood(const cv::Mat& img, int dsize, float value, int row, int col, bool same_img);
|
||||||
int row, int col, bool same_img);
|
|
||||||
|
|
||||||
//*************************************************************************************
|
}
|
||||||
//*************************************************************************************
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // NLDIFFUSION_FUNCTIONS_H_
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user