24 #include <type_traits>
42 typedef std::vector<std::pair<int, unsigned long>>
Compressed;
53 template <
typename InIterator>
54 size_t operator ()(InIterator begin, InIterator end);
56 template <
typename Image>
57 size_t operator ()(
const Image& image)
59 return (*
this)(image.begin(), image.end());
67 std::vector<uint64_t> m_histogram;
78 template <
typename InIterator,
bool sig>
79 struct dispatch_by_pixeltype {
80 static size_t apply(InIterator MIA_PARAM_UNUSED(begin), InIterator MIA_PARAM_UNUSED(end),
81 std::vector<uint64_t>& MIA_PARAM_UNUSED(histogram))
83 throw std::invalid_argument(
"Input pixel type not supported");
87 template <
typename InIterator>
88 struct dispatch_by_pixeltype<InIterator, false> {
89 static size_t apply(InIterator begin, InIterator end, std::vector<uint64_t>& histogram)
93 while ( begin != end) {
103 template <
typename InIterator>
104 struct dispatch_by_pixeltype<InIterator, true> {
105 static size_t apply(InIterator begin, InIterator end, std::vector<uint64_t>& histogram)
107 typedef typename InIterator::value_type in_pixels;
108 int64_t shift = -std::numeric_limits<in_pixels>::min();
111 while ( begin != end) {
112 ++histogram[*begin + shift];
122 template <
typename InIterator>
125 typedef typename InIterator::value_type in_pixeltype;
128 m_pixeltype = pixel_type<in_pixeltype>::value;
129 m_shift = -std::numeric_limits<in_pixeltype>::min();
131 switch (m_pixeltype) {
134 m_histogram.resize(256);
139 m_histogram.resize(65536);
143 throw create_exception<std::invalid_argument>(
"Input pixel type '",
147 }
else if (m_pixeltype != pixel_type<in_pixeltype>::value) {
148 throw create_exception<std::invalid_argument>(
"Input pixels not of consisted type, started with ",
153 const bool is_signed = std::is_signed<in_pixeltype>::value;
155 n += dispatch_by_pixeltype<InIterator, is_signed>::apply(begin, end, m_histogram);
size_t operator()(InIterator begin, InIterator end)
std::vector< std::pair< int, unsigned long > > Compressed
Compressed get_compressed_histogram() const
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
#define EXPORT_CORE
Macro to manage Visual C++ style dllimport/dllexport.
#define NS_MIA_END
conveniance define to end the mia namespace
EXPORT_CORE const TDictMap< EPixelType > CPixelTypeDict
dictionary for the pixel types
EXPORT_CORE std::ostream & operator<<(std::ostream &os, const std::pair< short, uint64_t > &pair)
base class for all filer type functors.