00001
00052 #ifndef __CHANNEL_IMAGE__
00053 #define __CHANNEL_IMAGE__
00054
00055 #include "array.h"
00056
00057 enum channel_meaning_type {RGB,NOT_DEFINED};
00058
00060 template <unsigned int N,typename Real,channel_meaning_type Channel_meaning>
00061 class Channel_image{
00062
00063 public:
00064
00065 typedef Real real_type;
00066 typedef unsigned int size_type;
00067
00068 typedef Array_2D<real_type> channel_type;
00069
00070
00071 Channel_image();
00072 Channel_image(const Channel_image<N,Real,Channel_meaning>& c);
00073 Channel_image(const size_type x,const size_type y);
00074
00075 void resize(const size_type x,const size_type y);
00076
00077 size_type x_size() const;
00078 size_type y_size() const;
00079 size_type channel_size() const;
00080 channel_meaning_type channel_meaning() const;
00081
00082 channel_type& operator[](const size_type c);
00083 const channel_type& operator[](const size_type c) const;
00084
00085 private:
00086 Array_2D<real_type> channel[N];
00087
00088 };
00089
00090
00091 template<typename Real>
00092 class RGB_channel_image:public Channel_image<3,Real,RGB>{
00093
00094 public:
00095
00096 typedef Real real_type;
00097 typedef typename Channel_image<3,Real,RGB>::size_type size_type;
00098
00099 static const size_type red = 0;
00100 static const size_type green = 1;
00101 static const size_type blue = 2;
00102
00103 RGB_channel_image()
00104 :Channel_image<3,Real,RGB>(){};
00105
00106 RGB_channel_image(const RGB_channel_image<Real>& c)
00107 :Channel_image<3,Real,RGB>(c){}
00108
00109 RGB_channel_image(const size_type x,const size_type y)
00110 :Channel_image<3,Real,RGB>(x,y){}
00111 };
00112
00113
00114 typedef RGB_channel_image<float> RGB_f_channel_image;
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132 template <unsigned int N,typename Real,channel_meaning_type Channel_meaning>
00133 Channel_image<N,Real,Channel_meaning>::Channel_image(){}
00134
00135
00136
00137 template <unsigned int N,typename Real,channel_meaning_type Channel_meaning>
00138 Channel_image<N,Real,Channel_meaning>::Channel_image(const Channel_image<N,Real,Channel_meaning>& c){
00139
00140 for(size_type i=0;i<N;i++){
00141 channel[i] = c[i];
00142 }
00143 }
00144
00145
00146 template <unsigned int N,typename Real,channel_meaning_type Channel_meaning>
00147 Channel_image<N,Real,Channel_meaning>::Channel_image(const size_type x,const size_type y){
00148
00149 for(size_type i=0;i<N;i++){
00150 channel[i].resize(x,y);
00151 }
00152 }
00153
00154
00155 template <unsigned int N,typename Real,channel_meaning_type Channel_meaning>
00156 void Channel_image<N,Real,Channel_meaning>::resize(const size_type x,const size_type y){
00157
00158 for(size_type i=0;i<N;i++){
00159 channel[i].resize(x,y);
00160 }
00161 }
00162
00163
00164 template <unsigned int N,typename Real,channel_meaning_type Channel_meaning>
00165 typename Channel_image<N,Real,Channel_meaning>::size_type
00166 Channel_image<N,Real,Channel_meaning>::x_size() const{
00167
00168 return channel[0].x_size();
00169 }
00170
00171
00172 template <unsigned int N,typename Real,channel_meaning_type Channel_meaning>
00173 typename Channel_image<N,Real,Channel_meaning>::size_type
00174 Channel_image<N,Real,Channel_meaning>::y_size() const{
00175
00176 return channel[0].y_size();
00177 }
00178
00179
00180 template <unsigned int N,typename Real,channel_meaning_type Channel_meaning>
00181 typename Channel_image<N,Real,Channel_meaning>::size_type
00182 Channel_image<N,Real,Channel_meaning>::channel_size() const{
00183
00184 return N;
00185 }
00186
00187
00188 template <unsigned int N,typename Real,channel_meaning_type Channel_meaning>
00189 channel_meaning_type
00190 Channel_image<N,Real,Channel_meaning>::channel_meaning() const{
00191
00192 return Channel_meaning;
00193 }
00194
00195
00196 template <unsigned int N,typename Real,channel_meaning_type Channel_meaning>
00197 typename Channel_image<N,Real,Channel_meaning>::channel_type&
00198 Channel_image<N,Real,Channel_meaning>::operator[](const size_type c){
00199
00200 return channel[c];
00201 }
00202
00203
00204 template <unsigned int N,typename Real,channel_meaning_type Channel_meaning>
00205 const typename Channel_image<N,Real,Channel_meaning>::channel_type&
00206 Channel_image<N,Real,Channel_meaning>::operator[](const size_type c) const{
00207
00208 return channel[c];
00209 }
00210
00211 #endif