00001 #ifndef AISYCRCBCOLORSEG_H_DEFINED 00002 #define AISYCRCBCOLORSEG_H_DEFINED 00003 00004 #include <unistd.h> 00005 00013 class AISYCrCbColorSeg{ 00014 public: 00021 enum Colors 00022 { 00023 l0 =0x01, 00024 l1 =0x02, 00025 l2 =0x04, 00026 l3 =0x08, 00027 l4 =0x10, 00028 l5 =0x20, 00029 l6 =0x40, 00030 l7 =0x80, 00031 l8 =0x0100, 00032 l9 =0x0200, 00033 l10=0x0400, 00034 l11=0x0800, 00035 l12=0x1000, 00036 l13=0x2000, 00037 l14=0x4000, 00038 l15=0x8000, 00039 l16=0x010000, 00040 l17=0x020000, 00041 l18=0x040000, 00042 l19=0x080000, 00043 l20=0x100000, 00044 l21=0x200000, 00045 l22=0x400000, 00046 l23=0x800000, 00047 l24=0x01000000, 00048 l25=0x02000000, 00049 l26=0x04000000, 00050 l27=0x08000000, 00051 l28=0x10000000, 00052 l29=0x20000000, 00053 l30=0x40000000, 00054 l31=0x80000000 00055 }; 00056 public: 00065 AISYCrCbColorSeg(int width, int height); 00066 00070 AISYCrCbColorSeg() : mIAmValid(false), mProcessedImage(0) {}; 00071 00075 AISYCrCbColorSeg(const AISYCrCbColorSeg& other); 00076 00080 ~AISYCrCbColorSeg(); 00081 00085 AISYCrCbColorSeg& operator=(const AISYCrCbColorSeg& other); 00086 00099 const unsigned int* processImage(unsigned char* pImage); 00100 00120 bool setColor(Colors selectedLayer, 00121 unsigned char y, 00122 unsigned char crMin, unsigned char crMax, 00123 unsigned char cbMin, unsigned char cbMax); 00124 00134 int getNumberOfRecognizedPixel(Colors selectedLayer){ 00135 return mIAmValid ? mNumberOfRecognizedPixel[ pseudoLog2(selectedLayer) ] : -1; 00136 } 00137 00144 inline bool isValid() { 00145 return mIAmValid; 00146 } 00147 protected: 00148 00158 inline unsigned int pseudoLog2(unsigned int n) { 00159 register unsigned int k; 00160 for (k = 0; n != 1; n >>= 1) 00161 ++k; 00162 return k; 00163 }; 00164 00165 protected: 00170 bool mIAmValid; 00171 00175 int mWidth; 00179 int mHeight; 00180 00184 size_t mImageSize; 00185 00191 unsigned int mYValue[256]; 00197 unsigned int mCrValue[256]; 00203 unsigned int mCbValue[256]; 00204 00208 int mNumberOfRecognizedPixel[32]; 00209 00213 unsigned int* mProcessedImage; 00214 }; 00215 00216 #endif