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