/vol/vipdata/irtk/image++/include/irtkVoxel.h

00001 #ifndef IRTKVOXEL_H_
00002 
00003 #define IRTKVOXEL_H_
00004 
00005 typedef unsigned char  irtkBytePixel;
00006 typedef short          irtkGreyPixel;
00007 typedef float          irtkRealPixel;
00008 
00009 #define MIN_GREY std::numeric_limits<short>::min()
00010 #define MAX_GREY std::numeric_limits<short>::max()
00011 
00012 #define IRTK_VOXEL_UNKNOWN             0
00013 #define IRTK_VOXEL_CHAR                1
00014 #define IRTK_VOXEL_UNSIGNED_CHAR    2
00015 #define IRTK_VOXEL_SHORT               3
00016 #define IRTK_VOXEL_UNSIGNED_SHORT   4
00017 #define IRTK_VOXEL_INT                 5
00018 #define IRTK_VOXEL_UNSIGNED_INT     6
00019 #define IRTK_VOXEL_FLOAT               7
00020 #define IRTK_VOXEL_DOUBLE              8
00021 #define IRTK_VOXEL_RGB                 9
00022 
00023 template <typename T> struct voxel_limits {
00024 
00025 public:
00026    
00027   static T min() throw();
00028   static T max() throw();
00029 };
00030 
00031 template <> struct voxel_limits<char> {
00032 
00033    static double min() throw() { return static_cast<char>(0x80); }
00034    static double max() throw() { return static_cast<char>(0x7f); }
00035    
00036 };
00037 
00038 template <> struct voxel_limits<unsigned char> {
00039 
00040    static double min() throw() { return static_cast<unsigned char>(0x80); }
00041    static double max() throw() { return static_cast<unsigned char>(0xffu); }
00042    
00043 };
00044 
00045 template <> struct voxel_limits<short> {
00046 
00047    static double min() throw() { return static_cast<short>(0x8000); }
00048    static double max() throw() { return static_cast<short>(0x7fff); }
00049    
00050 };
00051 
00052 template <> struct voxel_limits<unsigned short> {
00053 
00054    static double min() throw() { return static_cast<unsigned short>(0u); }
00055    static double max() throw() { return static_cast<unsigned short>(0xffffu); }
00056    
00057 };
00058 
00059 template <> struct voxel_limits<float> {
00060 
00061    static double min() throw() { return static_cast<float>(-1.0e+38f); }
00062    static double max() throw() { return static_cast<float>( 1.0e+38f); }
00063    
00064 };
00065 
00066 template <> struct voxel_limits<double> {
00067 
00068    static double min() throw() { return static_cast<double>(-1.0e+299); }
00069    static double max() throw() { return static_cast<double>( 1.0e+299); }
00070    
00071 };
00072 
00073 #include <irtkVector3D.h>
00074 
00075 #endif /*IRTKVOXEL_H_*/