Start median rework (#3346)
- Added basic algorithms to `rtengine/median.h` - Converted first occurrences
This commit is contained in:
@@ -11,10 +11,10 @@ static const float MAXVALF = float(MAXVAL); // float version of MAXVAL
|
||||
static const double MAXVALD = double(MAXVAL); // double version of MAXVAL
|
||||
|
||||
template <typename _Tp>
|
||||
inline const _Tp SQR (_Tp x)
|
||||
inline _Tp SQR (_Tp x)
|
||||
{
|
||||
// return std::pow(x,2); Slower than:
|
||||
return (x * x);
|
||||
return x * x;
|
||||
}
|
||||
|
||||
template<typename _Tp>
|
||||
@@ -31,13 +31,13 @@ inline const _Tp& max(const _Tp& a, const _Tp& b)
|
||||
|
||||
|
||||
template<typename _Tp>
|
||||
inline const _Tp LIM(const _Tp& a, const _Tp& b, const _Tp& c)
|
||||
inline const _Tp& LIM(const _Tp& a, const _Tp& b, const _Tp& c)
|
||||
{
|
||||
return std::max(b, std::min(a, c));
|
||||
}
|
||||
|
||||
template<typename _Tp>
|
||||
inline const _Tp LIM01(const _Tp& a)
|
||||
inline _Tp LIM01(const _Tp& a)
|
||||
{
|
||||
return std::max(_Tp(0), std::min(a, _Tp(1)));
|
||||
}
|
||||
@@ -49,7 +49,7 @@ inline const _Tp ULIM(const _Tp& a, const _Tp& b, const _Tp& c)
|
||||
}
|
||||
|
||||
template<typename _Tp>
|
||||
inline const _Tp CLIP(const _Tp& a)
|
||||
inline _Tp CLIP(const _Tp& a)
|
||||
{
|
||||
return LIM(a, static_cast<_Tp>(0), static_cast<_Tp>(MAXVAL));
|
||||
}
|
||||
@@ -80,7 +80,7 @@ inline const _Tp& max(const _Tp& a, const _Tp& b, const _Tp& c, const _Tp& d)
|
||||
}
|
||||
|
||||
template<typename _Tp>
|
||||
inline const _Tp intp(const _Tp a, const _Tp b, const _Tp c)
|
||||
inline _Tp intp(_Tp a, _Tp b, _Tp c)
|
||||
{
|
||||
// calculate a * b + (1 - a) * c
|
||||
// following is valid:
|
||||
@@ -90,19 +90,19 @@ inline const _Tp intp(const _Tp a, const _Tp b, const _Tp c)
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T norm1(const T& x, const T& y)
|
||||
inline T norm1(const T& x, const T& y)
|
||||
{
|
||||
return std::abs(x) + std::abs(y);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T norm2(const T& x, const T& y)
|
||||
inline T norm2(const T& x, const T& y)
|
||||
{
|
||||
return std::sqrt(x * x + y * y);
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
T norminf(const T& x, const T& y)
|
||||
inline T norminf(const T& x, const T& y)
|
||||
{
|
||||
return std::max(std::abs(x), std::abs(y));
|
||||
}
|
||||
|
Reference in New Issue
Block a user