Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

recursive convolution for Gaussian smoothing and derivative kernels #341

Open
wants to merge 17 commits into
base: version-1-11-rc
Choose a base branch
from
Open
100 changes: 100 additions & 0 deletions include/vigra/kerneltraits.hxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
//-- -*- c++ -*-
/************************************************************************/
/* */
/* Copyright 2016 by Sven Peter and Ullrich Koethe */
/* */
/* This file is part of the VIGRA computer vision library. */
/* The VIGRA Website is */
/* http://hci.iwr.uni-heidelberg.de/vigra/ */
/* Please direct questions, bug reports, and contributions to */
/* [email protected] or */
/* [email protected] */
/* */
/* Permission is hereby granted, free of charge, to any person */
/* obtaining a copy of this software and associated documentation */
/* files (the "Software"), to deal in the Software without */
/* restriction, including without limitation the rights to use, */
/* copy, modify, merge, publish, distribute, sublicense, and/or */
/* sell copies of the Software, and to permit persons to whom the */
/* Software is furnished to do so, subject to the following */
/* conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the */
/* Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES */
/* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND */
/* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT */
/* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, */
/* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING */
/* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR */
/* OTHER DEALINGS IN THE SOFTWARE. */
/* */
/************************************************************************/

#ifndef VIGRA_KERNEL_H
#define VIGRA_KERNEL_H

#include <type_traits>

namespace vigra {
namespace detail {

struct fir_kernel1d_tag {};
struct fir_kernel2d_tag {};
struct iir_kernel1d_tag {};
struct gaussian_kernel1d_tag {};

template<typename X>
struct is_kernel
{
template <typename Y>
static char test(int, typename Y::vigra_kernel_category*);

template <typename Y>
static int test(int, ...);

static const bool value = (sizeof(char) == sizeof(test<X>(0,0)));
};

template<typename X, bool = is_kernel<X>::value >
struct is_fir_kernel1d : public std::is_same<typename X::vigra_kernel_category, fir_kernel1d_tag>
{
};

template<typename X, bool = is_kernel<X>::value >
struct is_iir_kernel1d : public std::is_same<typename X::vigra_kernel_category, iir_kernel1d_tag>
{
};

template<typename X, bool = is_kernel<X>::value >
struct is_gaussian_kernel1d : public std::is_same<typename X::vigra_kernel_category, gaussian_kernel1d_tag>
{
};

template<typename X>
struct is_fir_kernel1d<X, false>
{
static const bool value = false;
};

template<typename X>
struct is_iir_kernel1d<X, false>
{
static const bool value = false;
};

template<typename X>
struct is_gaussian_kernel1d<X, false>
{
static const bool value = false;
};


} // namespace detail

} // namespace vigra

#endif
8 changes: 8 additions & 0 deletions include/vigra/mathutil.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@
#ifndef M_EULER_GAMMA
# define M_EULER_GAMMA 0.5772156649015329
#endif

#ifndef M_SQRT2PI
# define M_SQRT2PI 2.50662827463100050241576528481104525
#endif
\endcode
*/
#ifndef M_PI
Expand Down Expand Up @@ -114,6 +118,10 @@
# define M_EULER_GAMMA 0.5772156649015329
#endif

#ifndef M_SQRT2PI
# define M_SQRT2PI 2.50662827463100050241576528481104525
#endif

namespace vigra {

/** \addtogroup MathFunctions Mathematical Functions
Expand Down
Loading