CVR-Lib last update 20 Sep 2009

cvrSplitImageToHSI.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 1998 - 2006
00003  * Lehrstuhl fuer Technische Informatik, RWTH-Aachen, Germany
00004  *
00005  *
00006  * This file is part of the Computer Vision and Robotics Library (CVR-Lib)
00007  *
00008  * The CVR-Lib is free software; you can redistribute it and/or
00009  * modify it under the terms of the BSD License.
00010  *
00011  * All rights reserved.
00012  *
00013  * Redistribution and use in source and binary forms, with or without
00014  * modification, are permitted provided that the following conditions are met:
00015  *
00016  * 1. Redistributions of source code must retain the above copyright notice,
00017  *    this list of conditions and the following disclaimer.
00018  *
00019  * 2. Redistributions in binary form must reproduce the above copyright notice,
00020  *    this list of conditions and the following disclaimer in the documentation
00021  *    and/or other materials provided with the distribution.
00022  *
00023  * 3. Neither the name of the authors nor the names of its contributors may be
00024  *    used to endorse or promote products derived from this software without
00025  *    specific prior written permission.
00026  *
00027  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00028  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00029  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00030  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00031  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00032  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00033  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00034  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00035  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00036  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00037  * POSSIBILITY OF SUCH DAMAGE.
00038  */
00039 
00040 
00041 
00042 /**
00043  * \file   cvrSplitImageToHSI.h
00044  *         Contains the functor splitImageToHSI which splits images into hue
00045  *         saturation and intensity.
00046  * \author Pablo Alvarado
00047  * \author Stefan Syberichs
00048  * \author Thomas Rusert
00049  * \date   19.04.1999
00050  *
00051  * $Id: cvrSplitImageToHSI.h,v 1.4 2006/01/06 05:02:10 alvarado Exp $
00052  */
00053 
00054 #ifndef _CVR_SPLIT_IMAGE_TO_HSI_H_
00055 #define _CVR_SPLIT_IMAGE_TO_HSI_H_
00056 
00057 #include "cvrSplitImage.h"
00058 #include "cvrHueLUT.h"
00059 
00060 namespace cvr {
00061 
00062   /**
00063    * Split image into its Hue - Saturation - Intensity channels.
00064    *
00065    * The HSI color space is obtained by a rotation of the RGB color cube in a
00066    * way that the gray-value axis is oriented with the intensity (I) axis, the
00067    * hue (H) is the angle and the saturation (S) the distance from the I
00068    * axis.
00069    *
00070    * The transformation as defined by
00071    *
00072    * Gonzalez and Woods.  "Digital Image Processing". Addison Wesley. 1992
00073    *
00074    * is obtained with
00075    * \f[
00076    * \begin{aligned}
00077    *   I &= \frac{R+G+B}{3} \\
00078    *   S &= 1- \frac{\min(R,G,B)}{I} \\
00079    *   H &= \arccos\left(\frac{\frac{1}{2}\left[(R-G) + (R-B)\right]}
00080    *                          {\sqrt{(R-G)^2+(R-B)(G-B))}}\right)
00081    * \end{aligned}
00082    * \f]
00083    *
00084    * For the backtransformation see cvr::mergeHSIToImage
00085    *
00086    * @ingroup gColor
00087    */
00088   class splitImageToHSI : public splitImage {
00089   public:
00090     /**
00091      * Constructor
00092      */
00093     splitImageToHSI();
00094 
00095     /**
00096      * Copy Constructor
00097      */
00098     splitImageToHSI(const splitImageToHSI& other);
00099 
00100     /**
00101      * Destructor
00102      */
00103     virtual ~splitImageToHSI();
00104 
00105     /**
00106      * Copy data of "other" functor.
00107      * @param other the functor to be copied
00108      * @return a reference to this functor object
00109      */
00110     splitImageToHSI& copy(const splitImageToHSI& other);
00111 
00112     /**
00113      * Alias for copy member
00114      * @param other the functor to be copied
00115      * @return a reference to this functor object
00116      */
00117     splitImageToHSI& operator=(const splitImageToHSI& other);
00118 
00119     /**
00120      * Returns the name of this class
00121      */
00122     virtual const std::string& name() const;
00123 
00124     /**
00125      * returns a pointer to a clone of the functor.
00126      */
00127     virtual splitImageToHSI* clone() const;
00128 
00129     /**
00130      * returns a pointer to a new instance of the functor.
00131      */
00132     virtual splitImageToHSI* newInstance() const;
00133 
00134     /**
00135      * split the image in hue channel H, saturation S and intensity
00136      * channel I.
00137      * The values of each image will be between 0.0f and 1.0f
00138      * @param img the image to be splitted
00139      * @param H the hue channel
00140      * @param S the saturation channel
00141      * @param I the intensity channel
00142      */
00143     virtual bool apply(const matrix<image::value_type>& img,
00144                        matrix<channel::value_type>& H,
00145                        matrix<channel::value_type>& S,
00146                        matrix<channel::value_type>& I) const;
00147 
00148     /**
00149      * split the image in hue channel H, saturation S and intensity
00150      * channel I.
00151      * The values of each image will be between 0 and 255
00152      * @param img the image to be splitted
00153      * @param H the hue channel
00154      * @param S the saturation channel
00155      * @param I the intensity channel
00156      */
00157     virtual bool apply(const matrix<image::value_type>& img,
00158                        matrix<channel8::value_type>& H,
00159                        matrix<channel8::value_type>& S,
00160                        matrix<channel8::value_type>& I) const;
00161 
00162     /**
00163      * split the pixel in hue value H, saturation S and intensity
00164      * value I.
00165      * The values of each pixel will be between 0.0f and 1.0f
00166      * @param pixel the pixel to be splitted
00167      * @param H the hue value
00168      * @param S the saturation value
00169      * @param I the intensity value
00170      */
00171     virtual bool apply(const rgbaPixel& pixel,
00172                        float& H,
00173                        float& S,
00174                        float& I) const;
00175 
00176     /**
00177      * split the pixel in hue value H, saturation S and intensity
00178      * value I.
00179      * The values of each pixel will be between 0 and 255
00180      * @param pixel the pixel to be splitted
00181      * @param H the hue value
00182      * @param S the saturation value
00183      * @param I the intensity value
00184      */
00185     virtual bool apply(const rgbaPixel& pixel,
00186                        ubyte& H,
00187                        ubyte& S,
00188                        ubyte& I) const;
00189 
00190     /**
00191      * return the hue of the image.  If you need also the saturation and
00192      * the intensity please use the apply methods, which are much faster!
00193      */
00194     bool extractHue(const matrix<image::value_type>& img,
00195                     matrix<channel::value_type>& hue) const;
00196 
00197     /**
00198      * return the hue of the image.  If you need also the saturation and
00199      * the intensity please use the apply methods, which are much faster!
00200      */
00201     bool extractHue(const matrix<image::value_type>& img,
00202                     matrix<channel8::value_type>& hue) const;
00203 
00204     /**
00205      * return the saturation of the image.  If you need also the hue and
00206      * the intensity please use the apply methods, which are much faster!
00207      */
00208     bool extractSaturation(const matrix<image::value_type>& img,
00209                            matrix<channel::value_type>& saturation) const;
00210 
00211     /**
00212      * return the saturation of the image.  If you need also the hue and
00213      * the saturation please use the apply methods, which are much faster!
00214      */
00215     bool extractSaturation(const matrix<image::value_type>& img,
00216                            matrix<channel8::value_type>& saturation) const;
00217 
00218     /**
00219      * return the intensity of the image.  If you need also the hue and
00220      * the intensity please use the apply methods, which are much faster!
00221      */
00222     bool extractIntensity(const matrix<image::value_type>& img,
00223                           matrix<channel::value_type>& intensity) const;
00224 
00225     /**
00226      * return the intensity of the image.  If you need also the hue and
00227      * the intensity please use the apply methods, which are much faster!
00228      */
00229     bool extractIntensity(const matrix<image::value_type>& img,
00230                           matrix<channel8::value_type>& intensity) const;
00231 
00232 
00233     /**
00234      * Returns the first of the three channels into which the image is split.
00235      * If you need only one channel, this might be faster than calling apply().
00236      * @param img the source image
00237      * @param c1 the extracted channel
00238      */
00239     virtual bool extractFirst(const matrix<image::value_type>& img,
00240                               matrix<channel::value_type>& c1) const;
00241 
00242     /**
00243      * Returns the first of the three channels into which the image is split.
00244      * If you need only one channel, this might be faster than calling apply().
00245      * @param img the source image
00246      * @param c1 the extracted channel
00247      */
00248     virtual bool extractFirst(const matrix<image::value_type>& img,
00249                               matrix<channel8::value_type>& c1) const;
00250 
00251     /**
00252      * Returns the second of the three channels into which the image is split.
00253      * If you need only one channel, this might be faster than calling apply().
00254      * @param img the source image
00255      * @param c2 the extracted channel
00256      */
00257     virtual bool extractSecond(const matrix<image::value_type>& img,
00258                                matrix<channel::value_type>& c2) const;
00259 
00260     /**
00261      * Returns the second of the three channels into which the image is split.
00262      * If you need only one channel, this might be faster than calling apply().
00263      * @param img the source image
00264      * @param c2 the extracted channel
00265      */
00266     virtual bool extractSecond(const matrix<image::value_type>& img,
00267                                matrix<channel8::value_type>& c2) const;
00268 
00269     /**
00270      * Returns the third of the three channels into which the image is split.
00271      * If you need only one channel, this might be faster than calling apply().
00272      * @param img the source image
00273      * @param c3 the extracted channel
00274      */
00275     virtual bool extractThird(const matrix<image::value_type>& img,
00276                               matrix<channel::value_type>& c3) const;
00277 
00278     /**
00279      * Returns the third of the three channels into which the image is split.
00280      * If you need only one channel, this might be faster than calling apply().
00281      * @param img the source image
00282      * @param c3 the extracted channel
00283      */
00284     virtual bool extractThird(const matrix<image::value_type>& img,
00285                               matrix<channel8::value_type>& c3) const;
00286 
00287   private:
00288 
00289     hueLUT hueLUT_;
00290   };
00291 
00292 } // namespace cvr
00293 #endif
00294 

Generated on Sun Sep 20 22:08:00 2009 for CVR-Lib by Doxygen 1.5.8