Commit d92cf103 authored by Julien Osman's avatar Julien Osman
Browse files

ENH: Implement common_lowest and common_highest

parent d3222cab
#ifndef OtbNumericTraits_h
#define OtbNumericTraits_h
namespace otb
{
template <typename I, typename O>
constexpr auto common_lowest() {
using C = std::common_type_t<I,O>;
return
std::is_unsigned<I>::value ? I{}
: std::is_unsigned<O>::value ? O{}
: std::max<C>(std::numeric_limits<I>::lowest(), std::numeric_limits<O>::lowest());
}
template <typename I, typename O>
constexpr auto common_highest() {
using C = std::common_type_t<I,O>;
return std::min<C>(std::numeric_limits<I>::max(), std::numeric_limits<O>::max());
}
} // Namespace otb
#endif // OtbNumericTraits_h
......@@ -28,9 +28,11 @@
#include <boost/type_traits/is_complex.hpp>
#include <limits>
#include <type_traits>
#include "otbNumericTraits.h"
namespace otb
{
namespace Functor
{
......@@ -148,8 +150,8 @@ private:
ConvertTypeFunctor(const Self&) = delete;
void operator=(const Self&) = delete;
ThresholdPixelValueType m_LowestB = std::numeric_limits<OutputPixelValueType>::lowest();
ThresholdPixelValueType m_HighestB = std::numeric_limits<OutputPixelValueType>::max();
ThresholdPixelValueType m_LowestB = common_lowest<InputPixelValueType, OutputPixelValueType>();
ThresholdPixelValueType m_HighestB = common_highest<InputPixelValueType, OutputPixelValueType>();
OutputPixelValueType m_Zero {}; // initialized to zero!
unsigned int m_CompIn, m_CompOut, m_Scal;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment