TPixelConversion.h
Go to the documentation of this file.
1 #ifndef iimg_TPixelConversion_included
2 #define iimg_TPixelConversion_included
3 
4 
5 // ACF includes
6 #include <iimg/iimg.h>
7 
8 
9 namespace iimg
10 {
11 
12 
20 template <typename SourcePixel, typename DestPixel, typename CalcPixel = DestPixel>
22 {
23 public:
24  typedef SourcePixel SourcePixelType;
25  typedef DestPixel DestPixelType;
26  typedef CalcPixel CalcPixelType;
27 
28 
33 
39  DestPixel operator()(const SourcePixel& pixel) const;
40 
41  CalcPixel GetCalc(const SourcePixel& pixel) const;
42  DestPixel GetDest(const CalcPixel& pixel) const;
43 
51  double GetWeight(const CalcPixel& pixel) const;
52 
57  double GetIntensity(const CalcPixel& pixel) const;
58 
60 };
61 
62 
63 // inline methods
64 
65 template <typename SourcePixel, typename DestPixel, typename CalcPixel>
67 : whiteIntensity(1)
68 {
69 }
70 
71 
72 template <typename SourcePixel, typename DestPixel, typename CalcPixel>
73 inline DestPixel TPixelConversion<SourcePixel, DestPixel, CalcPixel>::operator()(const SourcePixel& pixel) const
74 {
75  return DestPixel(pixel);
76 }
77 
78 
79 template <typename SourcePixel, typename DestPixel, typename CalcPixel>
80 inline CalcPixel TPixelConversion<SourcePixel, DestPixel, CalcPixel>::GetCalc(const SourcePixel& pixel) const
81 {
82  return CalcPixel(pixel);
83 }
84 
85 
86 template <typename SourcePixel, typename DestPixel, typename CalcPixel>
87 inline DestPixel TPixelConversion<SourcePixel, DestPixel, CalcPixel>::GetDest(const CalcPixel& pixel) const
88 {
89  return DestPixel(pixel);
90 }
91 
92 
93 template <typename SourcePixel, typename DestPixel, typename CalcPixel>
94 inline double TPixelConversion<SourcePixel, DestPixel, CalcPixel>::GetWeight(const CalcPixel& /*pixel*/) const
95 {
96  return 1.0;
97 }
98 
99 
100 template <typename SourcePixel, typename DestPixel, typename CalcPixel>
101 inline double TPixelConversion<SourcePixel, DestPixel, CalcPixel>::GetIntensity(const CalcPixel& pixel) const
102 {
103  return double(pixel);
104 }
105 
106 
107 template <>
109 : whiteIntensity(255)
110 {
111 }
112 
113 
114 template <>
115 inline float TPixelConversion<quint8, float, float>::operator()(const quint8& pixel) const
116 {
117  return pixel / 255.0f;
118 }
119 
120 
121 template <>
122 inline float TPixelConversion<quint8, float, float>::GetCalc(const quint8& pixel) const
123 {
124  return pixel / 255.0f;
125 }
126 
127 
128 template <>
129 inline quint8 TPixelConversion<float, quint8, float>::operator()(const float& pixel) const
130 {
131  return quint8(pixel * 255);
132 }
133 
134 
135 template <>
136 inline quint8 TPixelConversion<float, quint8, float>::GetDest(const float& pixel) const
137 {
138  return quint8(pixel * 255);
139 }
140 
141 
146 
147 
148 } // namespace iimg
149 
150 
151 #endif // !iimg_TPixelConversion_included
152 
153 
DestPixel GetDest(const CalcPixel &pixel) const
DestPixel operator()(const SourcePixel &pixel) const
Casting operator.
TPixelConversion< float, quint8, float > CFloatGrayPixelConversion
TPixelConversion< float, float > CFloatFloatPixelConversion
TPixelConversion< quint8, quint8 > CGrayGrayPixelConversion
double GetWeight(const CalcPixel &pixel) const
Get weight of pixel value.
CalcPixel GetCalc(const SourcePixel &pixel) const
double GetIntensity(const CalcPixel &pixel) const
Get intensity of pixel value.
TPixelConversion()
Default constructor.
A generic pixel conversion.
TPixelConversion< quint8, float, float > CGrayFloatPixelConversion

© 2007-2017 Witold Gantzke and Kirill Lepskiy