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

# Representations/Perception/ColorTableTSL.h

Go to the documentation of this file.

    00001 /**
    00002 * @file ColorTableTSL.h
    00003 * Declaration of class ColorTableTSL.
    00004 *
    00005 * @author <A href=mailto:robocup@andreosterhues.de>André Osterhues</A>
    00006 */
    00007
    00008 #ifndef _ColorTableTSL_h_
    00009 #define _ColorTableTSL_h_
    00010
    00011 // forward declaration
    00012 class ColorTableTSL;
    00013
    00014 #include "ColorTable.h"
    00015 #include "Tools/Streams/InOut.h"
    00016 #include "Tools/ColorClasses.h"
    00017 #include "ColorClassImage.h"
    00018 #include "Image.h"
    00019 #include "Modules/ImageProcessor/ImageProcessorTools/MSH2004ColorCorrector.h"
    00020
    00021 /**
    00022 * @class ColorTableTSL
    00023 *
    00024 * Contains a ColorTableTSL which can decode the color for
    00025 * every 8 * 4 * 4 cube in the 255 * 255 * 255 YUV color space.
    00026 *
    00027 * @author <A href=mailto:robocup@andreosterhues.de>André Osterhues</A>
    00028 */
    00029 class ColorTableTSL : public ColorTable
    00030 {
    00031 public:
    00032   /** Constructor */
    00033   ColorTableTSL();
    00034
    00035   /** Destructor */
    00036   ~ColorTableTSL();
    00037
    00038   /**
    00039   * Clear color tables
    00040   */
    00041   void clear();
    00042
    00043   /**
    00044   * Reset to default TSL values
    00045   */
    00046   void reset();
    00047
    00048   /** Generates the Image for the TSL-Dialog-Bar */
    00049   void generateTSLDialogImage(const Image &image,ColorClassImage &colorClassImage);
    00050
    00051   /**
    00052   * Add a TSL range color class to the color table
    00053   * @param colorClass the color class
    00054   * @param t_min the min t value
    00055   * @param t_max the max t value
    00056   * @param s_min the min s value
    00057   * @param s_max the max s value
    00058   * @param l_min the min l value
    00059   * @param l_max the max l value
    00060   */
    00061   void addColorClass(
    00062     colorClass colorClass,
    00063     unsigned char t_min,
    00064     unsigned char t_max,
    00065     unsigned char s_min,
    00066     unsigned char s_max,
    00067     unsigned char l_min,
    00068     unsigned char l_max
    00069     );
    00070
    00071   /**
    00072   * Calculates the lookup table
    00073   */
    00074   void calculateLUT();
    00075
    00076   /**
    00077   * Returns the color class of a pixel.
    00078   * @param y the y value of the pixel
    00079   * @param u the u value of the pixel
    00080   * @param v the v value of the pixel
    00081   * @return the color class
    00082   */
    00083   virtual colorClass getColorClass(
    00084     const unsigned char y,
    00085     const unsigned char u,
    00086     const unsigned char v
    00087     ) const;
    00088
    00089   /**
    00090   * Segments an image to an color class image.
    00091   *
    00092   * This doesn't need to used in the image processor, but is needed for visualisation
    00093   * of color tables.
    00094   * @param image A reference to the image to be segmented
    00095   * @param colorClassImage A reference to the color class image to be created
    00096   */
    00097   virtual void generateColorClassImage(
    00098     const Image& image,
    00099     ColorClassImage& colorClassImage
    00100     ) const;
    00101
    00102   //!@name Members to be used by the ColorTableTSL dialog
    00103   //!@{
    00104
    00105   /**
    00106   * YUV->TSL conversion
    00107   */
    00108   void convertYUVToTSL(
    00109     unsigned char y,
    00110     unsigned char u,
    00111     unsigned char v,
    00112     unsigned char *t,
    00113     unsigned char *s,
    00114     unsigned char *l
    00115     ) const;
    00116
    00117   /**
    00118   * TSL->colorClass classification
    00119   */
    00120   colorClass classifyTSL(
    00121     unsigned char t,
    00122     unsigned char s,
    00123     unsigned char l
    00124     ) const;
    00125
    00126   /**
    00127   * The color table.
    00128   * Each entry contains both the color class A (lower 4 bits) and the color class B
    00129   * (higher 4 bits) values.
    00130   * As Y information is less relevant, only 5 bits are used for Y; U and V use 6 bits.
    00131   */
    00132   unsigned char colorClasses[32][64][64];
    00133
    00134   /**
    00135   * The TSL threshold table.
    00136   * This table stores the TSL thresholds as given by addColorClass() and
    00137   * updateColorClass().
    00138   * The first index selects the color class.
    00139   * The second index selects min (0) or max (1).
    00140   * The third index selects t (0), s (1) or l (2).
    00141   */
    00142   unsigned char tsl_threshold[numOfColors][2][3];
    00143
    00144   /**
    00145   * The TSL threshold index.
    00146   */
    00147   unsigned char tsl_index;
    00148
    00149   /**
    00150   * The TSL order table.
    00151   * It contains a permutation of colorClass.
    00152   */
    00153   colorClass tsl_order[numOfColors];
    00154
    00155   //!@}
    00156
    00157   private:
    00158
    00159   MSH2004ColorCorrector corrector;
    00160
    00161 };
    00162
    00163 /**
    00164  * Streaming operator that reads a ColorTableTSL from a stream.
    00165  * @param stream The stream from which is read.
    00166  * @param colorTableTSL The ColorTableTSL object.
    00167  * @return The stream.
    00168  */
    00169 In& operator>>(In& stream, ColorTableTSL& colorTableTSL);
    00170
    00171 /**
    00172  * Streaming operator that writes a ColorTableTSL to a stream.
    00173  * @param stream The stream to write on.
    00174  * @param colorTableTSL The ColorTableTSL object.
    00175  * @return The stream.
    00176  */
    00177 Out& operator<<(Out& stream, const ColorTableTSL& colorTableTSL);
    00178
    00179 #endif   //  _ColorTableTSL_h_