CVR-Lib last update 20 Sep 2009

cvrSplitImage.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 1998 - 2005
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   cvrSplitImage.h
00044  *         Definition of cvr::splitImage which is the base class of
00045  *         all functors that split an image into three different color
00046  *         channels of some color space.
00047  * \author Pablo Alvarado
00048  * \author Stefan Syberichs
00049  * \author Thomas Rusert
00050  * \date   19.04.1999
00051  *
00052  * $Id: cvrSplitImage.h,v 1.7 2006/06/07 13:02:42 doerfler Exp $
00053  */
00054 
00055 #ifndef _CVR_SPLIT_IMAGE_H_
00056 #define _CVR_SPLIT_IMAGE_H_
00057 
00058 #include "cvrFunctor.h"
00059 #include "cvrImage.h"
00060 #include "cvrChannel.h"
00061 #include "cvrChannel8.h"
00062 
00063 namespace cvr {
00064 
00065   /**
00066    * Abstract parent class for all classes that split an image into
00067    * different color spaces components (color channels).
00068    *
00069    * @ingroup gColor
00070    */
00071   class splitImage : public functor {
00072   public:
00073     /**
00074      * default constructor
00075      */
00076     splitImage();
00077 
00078     /**
00079      * copy constructor
00080      */
00081     splitImage(const splitImage& other);
00082 
00083     /**
00084      * destructor
00085      */
00086     virtual ~splitImage();
00087 
00088     /**
00089      * returns a pointer to a clone of the functor.
00090      */
00091     virtual splitImage* clone() const = 0;
00092 
00093     /**
00094      * returns a pointer to a new instance of the functor.
00095      */
00096     virtual splitImage* newInstance() const = 0;
00097 
00098     /**
00099      * Copy data of "other" functor.
00100      * @param other the functor to be copied
00101      * @return a reference to this functor object
00102      */
00103     splitImage& copy(const splitImage& other);
00104 
00105     /**
00106      * Alias for copy member
00107      * @param other the functor to be copied
00108      * @return a reference to this functor object
00109      */
00110     splitImage& operator=(const splitImage& other);
00111 
00112     /**
00113      * Returns used parameters
00114      */
00115     const parameters& getParameters() const;
00116 
00117     /**
00118      * Splits the image \c img into three color channels \c c1, \c c2,
00119      * and \c c3
00120      */
00121     virtual bool apply(const matrix<image::value_type>& img,
00122                        matrix<channel::value_type>& c1,
00123                        matrix<channel::value_type>& c2,
00124                        matrix<channel::value_type>& c3) const = 0;
00125     /**
00126      * Splits the image \c img into three color channel8s \c c1, \c c2,
00127      * and \c c3
00128      */
00129     virtual bool apply(const matrix<image::value_type>& img,
00130                        matrix<channel8::value_type>& c1,
00131                        matrix<channel8::value_type>& c2,
00132                        matrix<channel8::value_type>& c3) const = 0;
00133 
00134     /**
00135      * Splits the rgbPixel \c pixel into three color values \c c1, \c c2,
00136      * and \c c3
00137      */
00138     virtual bool apply(const rgbaPixel& pixel,
00139                        float& c1,
00140                        float& c2,
00141                        float& c3) const = 0;
00142 
00143     /**
00144      * Splits the rgbPixel \c pixel into three color values \c c1, \c c2,
00145      * and \c c3
00146      */
00147     virtual bool apply(const rgbaPixel& pixel,
00148                        ubyte& c1,
00149                        ubyte& c2,
00150                        ubyte& c3) const = 0;
00151 
00152     /**
00153      * Returns the first of the three channels into which the image is split.
00154      * If you need only one channel, this might be faster than calling apply().
00155      * @param img the source image
00156      * @param c1 the extracted channel
00157      */
00158     virtual bool extractFirst(const matrix<image::value_type>& img,
00159                               matrix<channel::value_type>& c1) const;
00160 
00161     /**
00162      * Returns the first of the three channels into which the image is split.
00163      * If you need only one channel, this might be faster than calling apply().
00164      * @param img the source image
00165      * @param c1 the extracted channel
00166      */
00167     virtual bool extractFirst(const matrix<image::value_type>& img,
00168                               matrix<channel8::value_type>& c1) const;
00169 
00170     /**
00171      * Returns the second of the three channels into which the image is split.
00172      * If you need only one channel, this might be faster than calling apply().
00173      * @param img the source image
00174      * @param c2 the extracted channel
00175      */
00176     virtual bool extractSecond(const matrix<image::value_type>& img,
00177                                matrix<channel::value_type>& c2) const;
00178 
00179     /**
00180      * Returns the second of the three channels into which the image is split.
00181      * If you need only one channel, this might be faster than calling apply().
00182      * @param img the source image
00183      * @param c2 the extracted channel
00184      */
00185     virtual bool extractSecond(const matrix<image::value_type>& img,
00186                                matrix<channel8::value_type>& c2) const;
00187 
00188     /**
00189      * Returns the third of the three channels into which the image is split.
00190      * If you need only one channel, this might be faster than calling apply().
00191      * @param img the source image
00192      * @param c3 the extracted channel
00193      */
00194     virtual bool extractThird(const matrix<image::value_type>& img,
00195                               matrix<channel::value_type>& c3) const;
00196 
00197     /**
00198      * Returns the third of the three channels into which the image is split.
00199      * If you need only one channel, this might be faster than calling apply().
00200      * @param img the source image
00201      * @param c3 the extracted channel
00202      */
00203     virtual bool extractThird(const matrix<image::value_type>& img,
00204                               matrix<channel8::value_type>& c3) const;
00205 
00206   protected:
00207 
00208     /**
00209      * return the minimum of three values
00210      */
00211     template <typename T>
00212     inline T maximum(const T a, const T b, const T c) const;
00213 
00214     /**
00215      * return the maximum of three value
00216      */
00217     template <typename T>
00218     inline T minimum(const T a, const T b, const T c) const;
00219 
00220   };
00221 
00222 } // namespace cvr
00223 
00224 #include "cvrSplitImage_inline.h"
00225 
00226 #endif
00227 

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