00001 #ifndef AISAIBOYCRCBCOLORSEG_H_DEFINED 00002 #define AISAIBOYCRCBCOLORSEG_H_DEFINED 00003 00004 #include <unistd.h> 00005 00019 class AISAiboYCrCbColorSeg{ 00020 public: 00027 enum Colors 00028 { 00029 l0 =0x01, 00030 l1 =0x02, 00031 l2 =0x04, 00032 l3 =0x08, 00033 l4 =0x10, 00034 l5 =0x20, 00035 l6 =0x40, 00036 l7 =0x80, 00037 l8 =0x0100, 00038 l9 =0x0200, 00039 l10=0x0400, 00040 l11=0x0800, 00041 l12=0x1000, 00042 l13=0x2000, 00043 l14=0x4000, 00044 l15=0x8000, 00045 l16=0x010000, 00046 l17=0x020000, 00047 l18=0x040000, 00048 l19=0x080000, 00049 l20=0x100000, 00050 l21=0x200000, 00051 l22=0x400000, 00052 l23=0x800000, 00053 l24=0x01000000, 00054 l25=0x02000000, 00055 l26=0x04000000, 00056 l27=0x08000000, 00057 l28=0x10000000, 00058 l29=0x20000000, 00059 l30=0x40000000, 00060 l31=0x80000000 00061 }; 00062 public: 00071 AISAiboYCrCbColorSeg(int width, int height); 00072 00076 AISAiboYCrCbColorSeg() : mIAmValid(false), mProcessedImage(0) {}; 00077 00081 AISAiboYCrCbColorSeg(const AISAiboYCrCbColorSeg& other); 00082 00086 ~AISAiboYCrCbColorSeg(); 00087 00091 AISAiboYCrCbColorSeg& operator=(const AISAiboYCrCbColorSeg& other); 00092 00106 const unsigned int* processImage(unsigned char* pImage); 00107 00127 bool setColor(Colors selectedLayer, 00128 unsigned char y, 00129 unsigned char crMin, unsigned char crMax, 00130 unsigned char cbMin, unsigned char cbMax); 00131 00141 int getNumberOfRecognizedPixel(Colors selectedLayer){ 00142 return mIAmValid ? mNumberOfRecognizedPixel[ pseudoLog2(selectedLayer) ] : -1; 00143 } 00144 00151 inline bool isValid() { 00152 return mIAmValid; 00153 } 00154 protected: 00155 00165 inline unsigned int pseudoLog2(register unsigned int n) { 00166 register unsigned int k; 00167 for (k = 0; n != 1; n >>= 1) 00168 ++k; 00169 return k; 00170 }; 00171 00172 protected: 00177 bool mIAmValid; 00178 00182 int mWidth; 00186 int mHeight; 00187 00191 size_t mImageSize; 00192 00198 unsigned int mYValue[256]; 00204 unsigned int mCrValue[256]; 00210 unsigned int mCbValue[256]; 00211 00212 00216 int mNumberOfRecognizedPixel[32]; 00217 00221 unsigned int* mProcessedImage; 00222 00226 int mDoubleWidth; 00227 00231 int mSomeWidth; 00232 00233 }; 00234 00235 #endif