24 #include <type_traits> 41 typedef std::vector<std::pair<int, unsigned long>>
Compressed;
52 template <
typename InIterator>
53 size_t operator ()(InIterator begin, InIterator end);
55 template <
typename Image>
56 size_t operator ()(
const Image& image) {
57 return (*
this)(image.begin(), image.end());
63 Compressed get_compressed_histogram()
const;
65 std::vector<uint64_t> m_histogram;
70 EXPORT_CORE std::ostream& operator << (std::ostream& os, const std::pair<short, uint64_t>& pair);
76 template <
typename InIterator,
bool sig>
77 struct dispatch_by_pixeltype {
78 static size_t apply(InIterator MIA_PARAM_UNUSED(begin), InIterator MIA_PARAM_UNUSED(end),
79 std::vector<uint64_t>& MIA_PARAM_UNUSED(histogram)){
80 throw std::invalid_argument(
"Input pixel type not supported");
84 template <
typename InIterator>
85 struct dispatch_by_pixeltype<InIterator, false> {
86 static size_t apply(InIterator begin, InIterator end, std::vector<uint64_t>& histogram){
88 while ( begin != end) {
97 template <
typename InIterator>
98 struct dispatch_by_pixeltype<InIterator, true> {
99 static size_t apply(InIterator begin, InIterator end, std::vector<uint64_t>& histogram){
100 typedef typename InIterator::value_type in_pixels;
101 int64_t shift = -std::numeric_limits<in_pixels>::min();
103 while ( begin != end) {
104 ++histogram[*begin + shift];
113 template <
typename InIterator>
116 typedef typename InIterator::value_type in_pixeltype;
118 m_pixeltype = pixel_type<in_pixeltype>::value;
119 m_shift = -std::numeric_limits<in_pixeltype>::min();
120 switch (m_pixeltype) {
123 m_histogram.resize(256);
127 m_histogram.resize(65536);
130 throw create_exception<std::invalid_argument>(
"Input pixel type '",
135 }
else if (m_pixeltype != pixel_type<in_pixeltype>::value){
136 throw create_exception<std::invalid_argument>(
"Input pixels not of consisted type, started with ",
141 const bool is_signed = std::is_signed<in_pixeltype>::value;
144 n += dispatch_by_pixeltype<InIterator, is_signed>::apply(begin, end, m_histogram);
base class for all filer type functors.
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
EXPORT_CORE const TDictMap< EPixelType > CPixelTypeDict
dictionary for the pixel types
std::vector< std::pair< int, unsigned long > > Compressed
size_t operator()(InIterator begin, InIterator end)
#define EXPORT_CORE
Macro to manage Visual C++ style dllimport/dllexport.
#define NS_MIA_END
conveniance define to end the mia namespace