00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef __GT2005ColorCorrector_h_
00010 #define __GT2005ColorCorrector_h_
00011
00012 #include "Representations/Perception/Image.h"
00013
00014
00015
00016
00017
00018
00019 class GT2005ColorCorrector
00020 {
00021 public:
00022
00023
00024
00025
00026
00027
00028
00029
00030 unsigned char correctY(int x, int y, int c) const
00031 {
00032 return correctionTable[radiusTable[x][y]][c][0];
00033 }
00034
00035
00036
00037
00038
00039
00040
00041
00042 unsigned char correctU(int x, int y, int c) const
00043 {
00044 return correctionTable[radiusTable[x][y]][c][1];
00045 }
00046
00047
00048
00049
00050
00051
00052
00053
00054 unsigned char correctV(int x, int y, int c) const
00055 {
00056 return correctionTable[radiusTable[x][y]][c][2];
00057 }
00058
00059
00060
00061
00062 GT2005ColorCorrector();
00063
00064
00065
00066
00067
00068 void init();
00069
00070
00071
00072
00073
00074 void disable();
00075
00076
00077
00078
00079
00080
00081
00082 void generateCorrectedImage(
00083 const Image& image,
00084 Image& correctedImage) const
00085 {
00086 correctedImage.cameraInfo = image.cameraInfo;
00087 correctedImage.colorTable = image.colorTable;
00088 for (int x=0; x<image.cameraInfo.resolutionWidth; x++)
00089 for (int y=0; y<image.cameraInfo.resolutionHeight; y++)
00090 {
00091 correctedImage.setHighResY (x, y,
00092 correctY(x, y, image.getHighResY(x * 2, y * 2)),
00093 correctY(x, y, image.getHighResY(x * 2, y * 2 + 1)),
00094 correctY(x, y, image.getHighResY(x * 2 + 1, y * 2)),
00095 correctY(x, y, image.getHighResY(x * 2 + 1, y * 2 + 1)));
00096
00097 correctedImage.image[y][1][x] = correctU(x, y, image.image[y][1][x]);
00098 correctedImage.image[y][2][x] = correctV(x, y, image.image[y][2][x]);
00099 }
00100 }
00101 private:
00102
00103
00104
00105
00106 int getRadius(int x, int y) const
00107 {
00108 int r = (int)sqrt( (double)
00109 (x - cameraResolutionWidth_ERS7 / 2) * (x - cameraResolutionWidth_ERS7 / 2) +
00110 (y - cameraResolutionHeight_ERS7 / 2) * (y - cameraResolutionHeight_ERS7 / 2)) - 10;
00111 if (r < 0) r = 0;
00112 return r;
00113 }
00114
00115
00116 int radiusTable[cameraResolutionWidth_ERS7][cameraResolutionHeight_ERS7];
00117
00118 unsigned char correctionTable[cameraResolutionWidth_ERS7][256][3];
00119 };
00120
00121 #endif // __GT2005ColorCorrector_h_