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

Representations/Perception/ColorTable64.h

Go to the documentation of this file.
00001 /** 
00002 * @file ColorTable64.h
00003 * Declaration of class ColorTable64.
00004 *
00005 * @author <A href=mailto:juengel@informatik.hu-berlin.de>Matthias Jüngel</A>
00006 * @author <A href=mailto:martin@martin-loetzsch.de>Martin Lötzsch</A>
00007 */
00008 
00009 #ifndef _ColorTable64_h_
00010 #define _ColorTable64_h_
00011 
00012 // forward declaration
00013 class ColorTable64;
00014 
00015 #include "ColorTable.h"
00016 #include "Tools/Streams/InOut.h"
00017 #include "Tools/Math/Vector3.h"
00018 #include "ColorClassImage.h"
00019 #include "Image.h"
00020 
00021 /**
00022 * @class ColorTable64
00023 *
00024 * Contains a ColorTable64 which can decode the color for
00025 * every 4 * 4 * 4 cube in the 255 * 255 * 255 YUV color space.
00026 *
00027 * @author <A href=mailto:juengel@informatik.hu-berlin.de>Matthias Jüngel</A>
00028 * @author <A href=mailto:martin@martin-loetzsch.de>Martin Lötzsch</A>
00029 */
00030 class ColorTable64 : public ColorTable
00031 {
00032 public:
00033   /** Constructor */
00034   ColorTable64();
00035 
00036   /** Destructor */
00037   ~ColorTable64();
00038 
00039   enum Format {CT32K, CT64};
00040 
00041   /** 
00042   * Calculates the color class of a pixel.
00043   * @param y the y value of the pixel
00044   * @param u the u value of the pixel
00045   * @param v the v value of the pixel
00046   * @return the color class
00047   */
00048   virtual colorClass getColorClass (const unsigned char y, 
00049     const unsigned char u, 
00050     const unsigned char v) const
00051   {
00052     return (colorClass) colorClasses[y/4][u/4][v/4];
00053   }
00054 
00055   /**
00056   * Computes an axis aligned box around all positions of a specified color
00057   * in YUV space
00058   * @param color The color
00059   * @param pNear The corner of the box nearest to the origin
00060   * @param pFar The corner of the box farthest to the origin
00061   */
00062   void getBoxAroundColorClass(colorClass color, 
00063                               Vector3<int>& pNear, Vector3<int>& pFar);
00064   /**
00065   * Segments an image to an color class image.
00066   * 
00067   * This doesn't need to used in the image processor, but is needed for visualisation
00068   * of color tables.
00069   * @param image A reference to the image to be segmented
00070   * @param colorClassImage A reference to the color class image to be created
00071   */
00072   virtual void generateColorClassImage(const Image& image, 
00073     ColorClassImage& colorClassImage) const;
00074 
00075   /**
00076   * Generates an image that contains all pixels that have the specified color class.
00077   * 
00078   * @param image A reference to the image to be segmented
00079   * @param colorClassImage A reference to the color class image to be created
00080   * @param colorClass The color class. 
00081   */
00082   virtual void generateColorClassImage(const Image& image, 
00083     ColorClassImage& colorClassImage,
00084     colorClass colorClass
00085     ) const;
00086 
00087   /**
00088   * Segments an image to an color class image.
00089   * 
00090   * This doesn't need to used in the image processor, but is needed for visualisation
00091   * of color tables.
00092   * @param image A reference to the image to be segmented
00093   * @param colorClassImage A reference to the color class image to be created
00094   */
00095   virtual void generateHighResColorClassImage(const Image& image, 
00096     ColorClassImage& colorClassImage) const;
00097 
00098   /**
00099   * Generates an image that contains all pixels that have the specified color class.
00100   * 
00101   * @param image A reference to the image to be segmented
00102   * @param colorClassImage A reference to the color class image to be created
00103   * @param colorClass The color class. 
00104   */
00105   virtual void generateHighResColorClassImage(const Image& image, 
00106     ColorClassImage& colorClassImage,
00107     colorClass colorClass
00108     ) const;
00109 
00110   /** 
00111   * The color table.
00112   * Each element in the array contains the color class of a 4x4x4 cube in the color space.
00113   */
00114   unsigned char colorClasses[64][64][64];
00115 
00116   //!@name Members to be used by the ColorTable64 dialog
00117   //!@{
00118 
00119   /** Sets the color class of every 4x4x4 to noColor */
00120   void clear();
00121   
00122   /** Sets all cubes that have the given color class to noColor */
00123   void clearChannel(colorClass colorClass);
00124   
00125   /** 
00126   * Sets the color class for a pixel in the color space given by y, u, v
00127   * to the given color class.
00128   */
00129   void addColorClass(
00130     colorClass colorClass,
00131     unsigned char y,
00132     unsigned char u,
00133     unsigned char v
00134     );
00135 
00136   /** 
00137   * Sets the color class for a cube with the size "range" around a pixel
00138   * given by y,u,v to the given color class.
00139   */
00140   void addColorClass(
00141     colorClass colorClass,
00142     unsigned char y, 
00143     unsigned char u, 
00144     unsigned char v, 
00145     unsigned char range
00146     );
00147 
00148   /**
00149   * Sets the color class for all sub cubes within the specified cuboid to the given color class.
00150   */
00151   void addCuboidToColorClass(
00152     colorClass colorClass,
00153     unsigned char yMin, 
00154     unsigned char uMin, 
00155     unsigned char vMin, 
00156     unsigned char yMax, 
00157     unsigned char uMax, 
00158     unsigned char vMax
00159     );
00160   
00161   /**
00162   * Sets the color class for a cube with the size "range" around a pixel
00163   * given by y,u,v to noColor.
00164   */
00165   void removeColorClass(
00166     unsigned char y, 
00167     unsigned char u, 
00168     unsigned char v, 
00169     unsigned char range
00170     );
00171 
00172   void setFormat(Format form)
00173   {
00174     format = form;
00175   }
00176   
00177   enum {CT32K_SIZE = 8*64*64, CT64_SIZE = 64*64*64};
00178 
00179   /**
00180    * Streaming operator that reads a ColorTable64 from a stream.
00181    * @param stream The stream from which is read.
00182    * @param colorTable64 The ColorTable64 object.
00183    * @return The stream.
00184    */ 
00185   friend In& operator>>(In& stream,ColorTable64& colorTable64);
00186   //!@}
00187 
00188 private:   
00189   
00190   Format format;
00191 
00192   static void convert32Kto64(const unsigned char* c32k, unsigned char c64[64][64][64]);
00193 
00194 };
00195 
00196 /**
00197  * Streaming operator that writes a ColorTable64 to a stream.
00198  * @param stream The stream to write on.
00199  * @param colorTable64 The ColorTable64 object.
00200  * @return The stream.
00201  */ 
00202 Out& operator<<(Out& stream, const ColorTable64& colorTable64);
00203 
00204 #endif   //  _ColorTable64_h_
00205 
00206 /*
00207  * Change log :
00208  * 
00209  * $Log: ColorTable64.h,v $
00210  * Revision 1.2  2004/06/27 17:04:42  nistico
00211  * ColorTableMod works again, now ColorTable32K are converted when selected
00212  * into ColorTable64 format, and can be selected at runtime what to use.
00213  *
00214  * Revision 1.1.1.1  2004/05/22 17:25:48  cvsadm
00215  * created new repository GT2004_WM
00216  *
00217  * Revision 1.5  2004/04/07 13:00:44  risler
00218  * ddd checkin after go04 - second part
00219  *
00220  * Revision 1.2  2004/04/02 14:46:18  risler
00221  * added segmented high resolution image
00222  * colortable dialog supports high resolution images
00223  *
00224  * Revision 1.1.1.1  2004/03/29 08:28:45  Administrator
00225  * initial transfer from tamara
00226  *
00227  * Revision 1.4  2004/03/05 17:56:39  tim
00228  * corrected doxygen comments
00229  *
00230  * Revision 1.3  2004/02/16 18:23:47  tim
00231  * Added getBoxAroundColorClass
00232  *
00233  * Revision 1.2  2003/10/29 13:24:42  juengel
00234  * Added addCuboidToColorClass to ColorTable64
00235  *
00236  * Revision 1.1  2003/10/07 10:09:36  cvsadm
00237  * Created GT2004 (M.J.)
00238  *
00239  * Revision 1.3  2003/09/25 11:23:52  juengel
00240  * Removed BlobCollection.
00241  *
00242  * Revision 1.2  2003/07/21 13:43:51  juengel
00243  * generateColorClassImage returns void
00244  *
00245  * Revision 1.1.1.1  2003/07/02 09:40:22  cvsadm
00246  * created new repository for the competitions in Padova from the 
00247  * tamara CVS (Tuesday 2:00 pm)
00248  *
00249  * removed unused solutions
00250  *
00251  * Revision 1.4  2003/04/14 16:12:09  loetzsch
00252  * ATH after GermanOpen CVS merge
00253  * improved color table dialog bar
00254  *
00255  * Revision 1.2  2003/04/10 08:29:19  juengel
00256  * no message
00257  *
00258  * Revision 1.3  2003/02/18 21:29:17  osterhues
00259  * Changed all instances of ColorTable64 to new base class ColorTable
00260  *
00261  * Revision 1.2  2003/01/09 14:11:31  jhoffman
00262  * added some stuff needed for ISL
00263  *
00264  * Revision 1.1  2002/09/10 15:26:40  cvsadm
00265  * Created new project GT2003 (M.L.)
00266  * - Cleaned up the /Src/DataTypes directory
00267  * - Removed Challenge Code
00268  * - Removed processing of incoming audio data
00269  * - Renamed AcousticMessage to SoundRequest
00270  *
00271  * Revision 1.2  2002/07/23 13:29:28  loetzsch
00272  * removed base class of ColorTable
00273  *
00274  * new streaming classes
00275  *
00276  * Revision 1.1.1.1  2002/05/10 12:40:13  cvsadm
00277  * Moved GT2002 Project from ute to tamara.
00278  *
00279  * Revision 1.7  2001/12/22 20:35:35  loetzsch
00280  * removed ColorTable::segmentImage, replaced by
00281  * ColorTable64::generateColorClassImage
00282  *
00283  * Revision 1.6  2001/12/21 14:22:41  roefer
00284  * warnings fixed: inline/eof
00285  *
00286  * Revision 1.5  2001/12/21 00:49:48  loetzsch
00287  * segmentImage in die Basisklasse verschoben
00288  *
00289  * Revision 1.4  2001/12/20 16:01:37  loetzsch
00290  * Streaming operators added
00291  *
00292  * Revision 1.3  2001/12/19 14:04:47  loetzsch
00293  * In ColorTables Pointer gegen Referenzen ausgetauscht,
00294  * Funktion segmentImage hinzugefügt und implementiert
00295  *
00296  * Revision 1.2  2001/12/17 19:24:42  juengel
00297  * no message
00298  *
00299  */

Generated on Thu Sep 23 19:57:36 2004 for GT2004 by doxygen 1.3.6