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

Modules/ImageProcessor/ImageProcessorTools/MSH2004ColorCorrector.h

Go to the documentation of this file.
00001 /**
00002 * @file Modules/ImageProcessor/ImageProcessorTools/MSH2004ColorCorrector.h
00003 * 
00004 * This file contains a class that represents a table used for color correction.
00005 *
00006 * @author <A href="mailto:walter.nistico@uni-dortmund.de">Walter Nistico</A>
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 * @class MSH2004ColorCorrector
00019 * The class represents a table for color correction.
00020 */
00021 class MSH2004ColorCorrector
00022 {
00023 private:
00024 
00025   /** 
00026   * radialOrder is the polinomial power (+1) of the radial factor of the color correction.
00027   * colorOrder is the polinomial power (+1) of the brighness factor of the color correction.
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]; /** Radius look up table, used to index the correction table. */
00034   unsigned char colorCorrectionLUT[max_radius][256][3]; /** Correction table. */
00035   bool active; /** Flag which keeps the corrector status. */
00036 
00037   double radialP[3*maxRadialOrder];
00038   double colorP[3*maxColorOrder];
00039 
00040   /** The following functions are called by the constructor to build the LookUpTables*/
00041   void setupRadiusLUT();
00042   void setupCorrectionLUT();
00043   
00044   /** Corrects the radiometric distortion of a single channel of a given pixel, based on the distance from the image center.
00045   * @param radius_i The distance of the given pixel from the image center.
00046   * @param color The brightness value of the given channel
00047   * @param channel Selects the channel to which the color distortion is to be applied (Y=0, U=1, V=2).
00048   * @return The corrected value.
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   * Default constructor.
00056   */
00057   MSH2004ColorCorrector();
00058 
00059   /**
00060   * This functions returns a radiometric distortion corrected pixel.
00061   * @param x The x coordinate of the pixel.
00062   * @param y The y coordinate of the pixel.
00063   * @param Y The Y (brightness) color channel (to be) corrected.
00064   * @param U The U (crominance) color channel (to be) corrected.
00065   * @param V The V (crominance) color channel (to be) corrected.
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   * This functions corercts the radiometric distortion of a chosen pixel in an image.
00083   * @param source The source image
00084   * @param x The x coordinate of the pixel.
00085   * @param y The y coordinate of the pixel.
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   * The function returns whether the corrector is active.
00101   * @return Is it active?
00102   */
00103   inline bool isActive() const {return active;}
00104 };
00105 
00106 #endif// __MSH2004ColorCorrector_h_

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