Pixels.h

Go to the documentation of this file.
00001 #ifndef __PIXELS_H__ 
00002 #define __PIXELS_H__ 
00003 
00004 #include "libBaseTypes.h"
00005 #include "Promotion.h"
00006 #include "Point.h"
00007 
00008 typedef byte Pixel8BitGrey;
00009 typedef short Pixel12BitGrey;
00010 typedef Real PixelRealGrey;
00011 
00012 // TODO: convert pixels to points?
00013 //typedef PointOf<1,byte> Pixel8BitGrey;
00014 //typedef PointOf<1,Real> PixelRealGrey;
00015 //typedef PointOf<1,int> Pixel32BitGrey;
00016 //DEFINE_SYMMETRICPROMOTION(Pixel8BitGrey,Real,PixelRealGrey);
00017 //DEFINE_SYMMETRICPROMOTION(Pixel8BitGrey,int,Pixel32BitGrey);
00018 //DEFINE_RANGEPROMOTION(Pixel8BitGrey,Pixel32BitGrey);
00019 
00020 DEFINE_RANGEPROMOTION(Pixel12BitGrey,int);
00021 
00022 template<class T>
00023 class PixelInfoOf
00024 {
00025 };
00026 
00027 #define _PIXEL_MMMFunctions(_type,_min,_mid,_max,_range)    \
00028     template<>                                                                                          \
00029     class PixelInfoOf<_type>                                                                \
00030     {                                                                                                               \
00031     public:                                                                                                 \
00032         static const _type min = _min;                                              \
00033         static const _type mid = _mid;                                              \
00034         static const _type max = _max;                                              \
00035         static const RangePromotionOf<_type>::type range = _range;  \
00036     };                                                                                                          
00037 
00038 #define MinValue(_type) PixelInfoOf<_type>::min
00039 #define MidValue(_type) PixelInfoOf<_type>::mid
00040 #define MaxValue(_type) PixelInfoOf<_type>::max
00041 #define Range(_type) PixelInfoOf<_type>::range
00042 
00043 _PIXEL_MMMFunctions(Pixel8BitGrey,0,127,255,256)
00044 ;
00045 _PIXEL_MMMFunctions(Pixel12BitGrey,0,2047,4095,4096)
00046 ;
00047 
00048 template<class T>
00049 int SignOfDiff(const T& t1, const T& t2)
00050 {
00051   return t1 > t2 ? 1 : -1;
00052 }
00053 
00054 template<class T>
00055 int AbsDiff(const T& t1, const T& t2)
00056 {
00057   return (t1 < t2) ? t2 - t1 : t1 - t2;
00058 }
00059 
00060 inline void Serialize(Stream& st, const Pixel8BitGrey& t)
00061 {
00062   return st.Append(t);
00063 }
00064 
00065 inline void Deserialize(Stream& st, Pixel8BitGrey& t)
00066 {
00067   t = st.Read();
00068 }
00069 
00070 #endif //__PIXELS_H__ 

Generated on 6 Apr 2011 for Slicer3 by  doxygen 1.6.1