00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef __MSH2004ColorCorrector_h_
00010 #define __MSH2004ColorCorrector_h_
00011
00012 #include "Representations/Perception/Image.h"
00013
00014
00015 const double centralPointX = 107.5;
00016 const double centralPointY = 79.5;
00017
00018
00019
00020
00021 class MSH2004ColorCorrector
00022 {
00023 private:
00024
00025
00026
00027
00028
00029 enum {maxRadialOrder=10, maxColorOrder=10, max_radius=140};
00030 int radialOrder;
00031 int colorOrder;
00032
00033 unsigned char radiusLUT[cameraResolutionHeight_ERS7][cameraResolutionWidth_ERS7];
00034 unsigned char colorCorrectionLUT[max_radius][256][3];
00035 bool active;
00036
00037 double radialP[3*maxRadialOrder];
00038 double colorP[3*maxColorOrder];
00039
00040
00041 void setupRadiusLUT();
00042 void setupCorrectionLUT();
00043
00044
00045
00046
00047
00048
00049
00050 unsigned char colorDistortionCorrection(const unsigned char radius_i,
00051 const unsigned char color, const unsigned char channel) const;
00052
00053 public:
00054
00055
00056
00057 MSH2004ColorCorrector();
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067 inline void getCorrectedPixel(const int x, const int y, unsigned char& Y, unsigned char& U, unsigned char& V) const
00068 {
00069 unsigned char radius = radiusLUT[y][x];
00070 Y = colorCorrectionLUT[radius][Y][0];
00071 U = colorCorrectionLUT[radius][U][1];
00072 V = colorCorrectionLUT[radius][V][2];
00073 }
00074
00075 inline void getCorrectedColor(const int x, const int y, unsigned char& color, unsigned char spectrum) const
00076 {
00077 unsigned char radius = radiusLUT[y][x];
00078 color = colorCorrectionLUT[radius][color][spectrum];
00079 }
00080
00081
00082
00083
00084
00085
00086
00087 inline void correctPixel(Image& source, const int x, const int y) const
00088 {
00089 unsigned char radius = radiusLUT[y][x];
00090 unsigned char Y, U, V;
00091 Y = source.image[y][0][x];
00092 U = source.image[y][1][x];
00093 V = source.image[y][2][x];
00094 source.image[y][0][x] = colorCorrectionLUT[radius][Y][0];
00095 source.image[y][1][x] = colorCorrectionLUT[radius][U][1];
00096 source.image[y][2][x] = colorCorrectionLUT[radius][V][2];
00097 }
00098
00099
00100
00101
00102
00103 inline bool isActive() const {return active;}
00104 };
00105
00106 #endif// __MSH2004ColorCorrector_h_