CVD 0.8
|
00001 /* 00002 This file is part of the CVD Library. 00003 00004 Copyright (C) 2005 The Authors 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Lesser General Public 00008 License as published by the Free Software Foundation; either 00009 version 2.1 of the License, or (at your option) any later version. 00010 00011 This library is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Lesser General Public License for more details. 00015 00016 You should have received a copy of the GNU Lesser General Public 00017 License along with this library; if not, write to the Free Software 00018 Foundation, Inc., 00019 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00020 */ 00021 #ifndef CVD_COLOURSPACES_H 00022 #define CVD_COLOURSPACES_H 00023 00024 #include <cvd/internal/is_pod.h> 00025 #include <cvd/internal/builtin_components.h> 00026 #include <cvd/internal/pixel_traits.h> 00027 #include <cvd/internal/name_builtin_types.h> 00028 00029 namespace CVD 00030 { 00031 00034 struct bayer_bggr 00035 { 00036 unsigned char val; 00037 operator unsigned char() const { return val; } 00038 bayer_bggr() {} 00039 bayer_bggr(unsigned char v) : val(v) {} 00040 }; 00041 00044 struct bayer_gbrg 00045 { 00046 unsigned char val; 00047 operator unsigned char() const { return val; } 00048 bayer_gbrg() {} 00049 bayer_gbrg(unsigned char v) : val(v) {} 00050 }; 00051 00054 struct bayer_grbg 00055 { 00056 unsigned char val; 00057 operator unsigned char() const { return val; } 00058 bayer_grbg() {} 00059 bayer_grbg(unsigned char v) : val(v) {} 00060 }; 00061 00064 struct bayer_rggb 00065 { 00066 unsigned char val; 00067 operator unsigned char() const { return val; } 00068 bayer_rggb() {} 00069 bayer_rggb(unsigned char v) : val(v) {} 00070 }; 00071 00074 struct bayer_bggr16 00075 { 00076 unsigned short val; 00077 operator unsigned short() const { return val; } 00078 bayer_bggr16() {} 00079 bayer_bggr16(unsigned short v) : val(v) {} 00080 }; 00081 00084 struct bayer_gbrg16 00085 { 00086 unsigned short val; 00087 operator unsigned short() const { return val; } 00088 bayer_gbrg16() {} 00089 bayer_gbrg16(unsigned short v) : val(v) {} 00090 }; 00091 00094 struct bayer_grbg16 00095 { 00096 unsigned short val; 00097 operator unsigned short() const { return val; } 00098 bayer_grbg16() {} 00099 bayer_grbg16(unsigned short v) : val(v) {} 00100 }; 00101 00104 struct bayer_rggb16 00105 { 00106 unsigned short val; 00107 operator unsigned short() const { return val; } 00108 bayer_rggb16() {} 00109 bayer_rggb16(unsigned char v) : val(v) {} 00110 }; 00111 00114 struct bayer_bggr16be 00115 { 00116 unsigned short val; 00117 operator unsigned short() const { return val; } 00118 bayer_bggr16be() {} 00119 bayer_bggr16be(unsigned short v) : val(v) {} 00120 }; 00121 00124 struct bayer_gbrg16be 00125 { 00126 unsigned short val; 00127 operator unsigned short() const { return val; } 00128 bayer_gbrg16be() {} 00129 bayer_gbrg16be(unsigned short v) : val(v) {} 00130 }; 00131 00134 struct bayer_grbg16be 00135 { 00136 unsigned short val; 00137 operator unsigned short() const { return val; } 00138 bayer_grbg16be() {} 00139 bayer_grbg16be(unsigned short v) : val(v) {} 00140 }; 00141 00144 struct bayer_rggb16be 00145 { 00146 unsigned short val; 00147 operator unsigned short() const { return val; } 00148 bayer_rggb16be() {} 00149 bayer_rggb16be(unsigned char v) : val(v) {} 00150 }; 00151 00155 typedef bayer_bggr bayer; 00156 00160 struct yuv411 00161 { 00162 unsigned char val; 00163 }; 00164 00167 struct yuv422 00168 { 00169 unsigned short val; 00170 }; 00171 00174 struct yuv420p 00175 { 00176 unsigned short val; 00177 }; 00178 00183 struct vuy422 00184 { 00185 unsigned short val; 00186 }; 00187 00188 namespace PNM{ 00189 template<> struct type_name<bayer_bggr> { static std::string name(){return "bayer_bggr" ;}}; 00190 template<> struct type_name<bayer_gbrg> { static std::string name(){return "bayer_gbrg" ;}}; 00191 template<> struct type_name<bayer_grbg> { static std::string name(){return "bayer_grbg" ;}}; 00192 template<> struct type_name<bayer_rggb> { static std::string name(){return "bayer_rggb" ;}}; 00193 00194 template<> struct type_name<bayer_bggr16> { static std::string name(){return "bayer_bggr16" ;}}; 00195 template<> struct type_name<bayer_gbrg16> { static std::string name(){return "bayer_gbrg16" ;}}; 00196 template<> struct type_name<bayer_grbg16> { static std::string name(){return "bayer_grbg16" ;}}; 00197 template<> struct type_name<bayer_rggb16> { static std::string name(){return "bayer_rggb16" ;}}; 00198 00199 template<> struct type_name<bayer_bggr16be> { static std::string name(){return "bayer_bggr16be" ;}}; 00200 template<> struct type_name<bayer_gbrg16be> { static std::string name(){return "bayer_gbrg16be" ;}}; 00201 template<> struct type_name<bayer_grbg16be> { static std::string name(){return "bayer_grbg16be" ;}}; 00202 template<> struct type_name<bayer_rggb16be> { static std::string name(){return "bayer_rggb16be" ;}}; 00203 00204 template<> struct type_name<yuv411> { static std::string name(){return "yuv411" ;}}; 00205 template<> struct type_name<yuv422> { static std::string name(){return "yuv422" ;}}; 00206 template<> struct type_name<yuv420p>{ static std::string name(){return "yuv420p";}}; 00207 template<> struct type_name<vuy422> { static std::string name(){return "vuy422" ;}}; 00208 } 00209 00210 namespace Pixel { 00211 template<int LIFT> struct traits<bayer_bggr, LIFT> 00212 { 00213 typedef int wider_type; 00214 typedef float float_type; 00215 static const bool integral = true; 00216 static const bool is_signed = false; 00217 static const int bits_used = 8; 00218 static const unsigned char max_intensity=(1 << bits_used) - 1; 00219 }; 00220 00221 template<int LIFT> struct traits<bayer_rggb, LIFT> 00222 { 00223 typedef int wider_type; 00224 typedef float float_type; 00225 static const bool integral = true; 00226 static const bool is_signed = false; 00227 static const int bits_used = 8; 00228 static const unsigned char max_intensity=(1 << bits_used) - 1; 00229 }; 00230 00231 template<int LIFT> struct traits<bayer_gbrg, LIFT> 00232 { 00233 typedef int wider_type; 00234 typedef float float_type; 00235 static const bool integral = true; 00236 static const bool is_signed = false; 00237 static const int bits_used = 8; 00238 static const unsigned char max_intensity=(1 << bits_used) - 1; 00239 }; 00240 00241 template<int LIFT> struct traits<bayer_grbg, LIFT> 00242 { 00243 typedef int wider_type; 00244 typedef float float_type; 00245 static const bool integral = true; 00246 static const bool is_signed = false; 00247 static const int bits_used = 8; 00248 static const unsigned char max_intensity=(1 << bits_used) - 1; 00249 }; 00250 00251 template<int LIFT> struct traits<bayer_bggr16, LIFT> 00252 { 00253 typedef int wider_type; 00254 typedef float float_type; 00255 static const bool integral = true; 00256 static const bool is_signed = false; 00257 static const int bits_used = 16; 00258 static const unsigned short max_intensity=(1 << bits_used) - 1; 00259 }; 00260 00261 template<int LIFT> struct traits<bayer_rggb16, LIFT> 00262 { 00263 typedef int wider_type; 00264 typedef float float_type; 00265 static const bool integral = true; 00266 static const bool is_signed = false; 00267 static const int bits_used = 16; 00268 static const unsigned short max_intensity=(1 << bits_used) - 1; 00269 }; 00270 00271 template<int LIFT> struct traits<bayer_gbrg16, LIFT> 00272 { 00273 typedef int wider_type; 00274 typedef float float_type; 00275 static const bool integral = true; 00276 static const bool is_signed = false; 00277 static const int bits_used = 16; 00278 static const unsigned short max_intensity=(1 << bits_used) - 1; 00279 }; 00280 00281 template<int LIFT> struct traits<bayer_grbg16, LIFT> 00282 { 00283 typedef int wider_type; 00284 typedef float float_type; 00285 static const bool integral = true; 00286 static const bool is_signed = false; 00287 static const int bits_used = 16; 00288 static const unsigned short max_intensity=(1 << bits_used) - 1; 00289 }; 00290 00291 template<int LIFT> struct traits<bayer_bggr16be, LIFT> 00292 { 00293 typedef int wider_type; 00294 typedef float float_type; 00295 static const bool integral = true; 00296 static const bool is_signed = false; 00297 static const int bits_used = 16; 00298 static const unsigned short max_intensity=(1 << bits_used) - 1; 00299 }; 00300 00301 template<int LIFT> struct traits<bayer_rggb16be, LIFT> 00302 { 00303 typedef int wider_type; 00304 typedef float float_type; 00305 static const bool integral = true; 00306 static const bool is_signed = false; 00307 static const int bits_used = 16; 00308 static const unsigned short max_intensity=(1 << bits_used) - 1; 00309 }; 00310 00311 template<int LIFT> struct traits<bayer_gbrg16be, LIFT> 00312 { 00313 typedef int wider_type; 00314 typedef float float_type; 00315 static const bool integral = true; 00316 static const bool is_signed = false; 00317 static const int bits_used = 16; 00318 static const unsigned short max_intensity=(1 << bits_used) - 1; 00319 }; 00320 00321 template<int LIFT> struct traits<bayer_grbg16be, LIFT> 00322 { 00323 typedef int wider_type; 00324 typedef float float_type; 00325 static const bool integral = true; 00326 static const bool is_signed = false; 00327 static const int bits_used = 16; 00328 static const unsigned short max_intensity=(1 << bits_used) - 1; 00329 }; 00330 } 00331 00332 00333 #ifndef DOXYGEN_IGNORE_INTERNAL 00334 namespace Internal 00335 { 00336 template<> struct is_POD<bayer_bggr> 00337 { 00338 enum { is_pod = 1 }; 00339 }; 00340 template<> struct is_POD<bayer_gbrg> 00341 { 00342 enum { is_pod = 1 }; 00343 }; 00344 template<> struct is_POD<bayer_grbg> 00345 { 00346 enum { is_pod = 1 }; 00347 }; 00348 template<> struct is_POD<bayer_rggb> 00349 { 00350 enum { is_pod = 1 }; 00351 }; 00352 template<> struct is_POD<bayer_bggr16> 00353 { 00354 enum { is_pod = 1 }; 00355 }; 00356 template<> struct is_POD<bayer_gbrg16> 00357 { 00358 enum { is_pod = 1 }; 00359 }; 00360 template<> struct is_POD<bayer_grbg16> 00361 { 00362 enum { is_pod = 1 }; 00363 }; 00364 template<> struct is_POD<bayer_rggb16> 00365 { 00366 enum { is_pod = 1 }; 00367 }; 00368 template<> struct is_POD<bayer_bggr16be> 00369 { 00370 enum { is_pod = 1 }; 00371 }; 00372 template<> struct is_POD<bayer_gbrg16be> 00373 { 00374 enum { is_pod = 1 }; 00375 }; 00376 template<> struct is_POD<bayer_grbg16be> 00377 { 00378 enum { is_pod = 1 }; 00379 }; 00380 template<> struct is_POD<bayer_rggb16be> 00381 { 00382 enum { is_pod = 1 }; 00383 }; 00384 template<> struct is_POD<yuv411> 00385 { 00386 enum { is_pod = 1 }; 00387 }; 00388 } 00389 #endif 00390 } 00391 00392 #endif