Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

Modules/ImageProcessor/GT2005ImageProcessor/GT2005ColorCorrector.h

Go to the documentation of this file.
00001 /**
00002 * @file GT2005ColorCorrector.h
00003 *
00004 * Definition of class GT2005ColorCorrector
00005 *
00006 * @author Max Risler
00007 */
00008 
00009 #ifndef __GT2005ColorCorrector_h_
00010 #define __GT2005ColorCorrector_h_
00011 
00012 #include "Representations/Perception/Image.h"
00013 
00014 /**
00015 * @class GT2005ColorCorrector
00016 * This class provides a table to do a radial color correction to compensate 
00017 * for the ERS7 camera image error.
00018 */
00019 class GT2005ColorCorrector
00020 {
00021 public:
00022 
00023   /**
00024   * correct an Y pixel value
00025   * @param x x-coordinate
00026   * @param y y-coordinate
00027   * @param c old y value
00028   * @return corrected y value
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   * correct an U pixel value
00037   * @param x x-coordinate
00038   * @param y y-coordinate
00039   * @param c old u value
00040   * @return corrected u value
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   * correct an V pixel value
00049   * @param x x-coordinate
00050   * @param y y-coordinate
00051   * @param c old v value
00052   * @return corrected v value
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   * Constructor
00061   */
00062   GT2005ColorCorrector();
00063 
00064   /**
00065   * Initializes the correction table.
00066   * Table is created from images in whiteImage.log.
00067   */
00068   void init();
00069 
00070   /**
00071   * Disable the color correction.
00072   * Table is cleared.
00073   */
00074   void disable();
00075    
00076   /**
00077   * Creates a color corrected image.
00078   *
00079   * @param image A reference to the image to be corrected
00080   * @param correctedImage A reference to the image to be created
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   * Calculates the corresponding radius to an image coordinate
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   /** the redius table */
00116   int radiusTable[cameraResolutionWidth_ERS7][cameraResolutionHeight_ERS7];
00117   /** the correction table */
00118   unsigned char correctionTable[cameraResolutionWidth_ERS7][256][3];
00119 };
00120 
00121 #endif // __GT2005ColorCorrector_h_

Generated on Mon Mar 20 21:59:46 2006 for GT2005 by doxygen 1.3.6