last update 20 Sep 2009 |
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 cvrSplitImageToRGB.h 00044 * Definition of cvr::splitImageToRGB which splits an image into three 00045 * different color channels red, green, and blue (RGB). 00046 * \author Pablo Alvarado 00047 * \author Stefan Syberichs 00048 * \author Thomas Rusert 00049 * \date 19.04.1999 00050 * 00051 * $Id: cvrSplitImageToRGB.h,v 1.5 2005/04/28 15:34:00 doerfler Exp $ 00052 */ 00053 00054 #ifndef _CVR_SPLIT_IMAGE_RGB_H_ 00055 #define _CVR_SPLIT_IMAGE_RGB_H_ 00056 00057 #include "cvrSplitImage.h" 00058 00059 namespace cvr { 00060 00061 /** 00062 * Split image into its Red - Green - Blue channels. 00063 * You can split all the channels at the same time (with apply) or 00064 * get just one channel using the shortcut functions getRed(), getGreen() 00065 * or getBlue(). 00066 * 00067 * @see cvr::mergeRGBToImage 00068 * 00069 * @ingroup gColor 00070 */ 00071 class splitImageToRGB : public splitImage { 00072 public: 00073 00074 /** 00075 * default constructor 00076 */ 00077 splitImageToRGB(); 00078 00079 /** 00080 * copy constructor 00081 */ 00082 splitImageToRGB(const splitImageToRGB& other); 00083 00084 /** 00085 * destructor 00086 */ 00087 virtual ~splitImageToRGB(); 00088 00089 /** 00090 * Copy data of "other" functor. 00091 * @param other the functor to be copied 00092 * @return a reference to this functor object 00093 */ 00094 splitImageToRGB& copy(const splitImageToRGB& other); 00095 00096 /** 00097 * Alias for copy member 00098 * @param other the functor to be copied 00099 * @return a reference to this functor object 00100 */ 00101 splitImageToRGB& operator=(const splitImageToRGB& other); 00102 00103 /** 00104 * Returns the name of this class 00105 */ 00106 virtual const std::string& name() const; 00107 00108 /** 00109 * Returns a pointer to a clone of this functor. 00110 */ 00111 virtual splitImageToRGB* clone() const; 00112 00113 /** 00114 * Returns a pointer to a new instance of this functor. 00115 */ 00116 virtual splitImageToRGB* newInstance() const; 00117 00118 /** 00119 * Returns used parameters 00120 */ 00121 const parameters& getParameters() const; 00122 00123 /** 00124 * Split the image in red green and blue channels. 00125 * The values of each pixel will be between 0.0f and 1.0f 00126 * @param img the image to be splitted 00127 * @param red the red channel 00128 * @param green the green channel 00129 * @param blue the blue channel 00130 * @return true if successful, false otherwise. 00131 */ 00132 virtual bool apply(const matrix<image::value_type>& img, 00133 matrix<channel::value_type>& red, 00134 matrix<channel::value_type>& green, 00135 matrix<channel::value_type>& blue) const; 00136 00137 /** 00138 * split the image in red green and blue channels. 00139 * The values of each pixel will be between 0.0f and 1.0f 00140 * @param img the image to be splitted 00141 * @param red the red channel 00142 * @param green the green channel 00143 * @param blue the blue channel 00144 * @param alpha or dummy channel 00145 * @return true if successful, false otherwise. 00146 */ 00147 virtual bool apply(const matrix<image::value_type>& img, 00148 matrix<channel::value_type>& red, 00149 matrix<channel::value_type>& green, 00150 matrix<channel::value_type>& blue, 00151 matrix<channel::value_type>& alpha) const; 00152 00153 /** 00154 * split the image in red green and blue channels. The values of 00155 * each pixel will be between 0 and 255 00156 * @param img the image to be splitted 00157 * @param red the red channel 00158 * @param green the green channel 00159 * @param blue the blue channel 00160 * @return true if successful, false otherwise. 00161 */ 00162 virtual bool apply(const matrix<image::value_type>& img, 00163 matrix<channel8::value_type>& red, 00164 matrix<channel8::value_type>& green, 00165 matrix<channel8::value_type>& blue) const; 00166 00167 /** 00168 * split the image in red green and blue channels. The values of 00169 * each pixel will be between 0 and 255 00170 * @param img the image to be splitted 00171 * @param red the red channel 00172 * @param green the green channel 00173 * @param blue the blue channel 00174 * @param alpha or dummy channel 00175 * @return true if successful, false otherwise. 00176 */ 00177 virtual bool apply(const matrix<image::value_type>& img, 00178 matrix<channel8::value_type>& red, 00179 matrix<channel8::value_type>& green, 00180 matrix<channel8::value_type>& blue, 00181 matrix<channel8::value_type>& alpha) const; 00182 00183 /** 00184 * split the pixel in red green and blue values. 00185 * The values of each pixel will be between 0.0f and 1.0f 00186 * @param pixel the pixel to be splitted 00187 * @param red the red value 00188 * @param green the green value 00189 * @param blue the blue value 00190 * @return true if successful, false otherwise. 00191 */ 00192 virtual bool apply(const rgbaPixel& pixel, 00193 float& red, 00194 float& green, 00195 float& blue) const; 00196 00197 /** 00198 * split the pixel in red green and blue values. The values of 00199 * each pixel will be between 0 and 255 00200 * @param pixel the pixel to be splitted 00201 * @param red the red value 00202 * @param green the green value 00203 * @param blue the blue value 00204 */ 00205 virtual bool apply(const rgbaPixel& pixel, 00206 ubyte& red, 00207 ubyte& green, 00208 ubyte& blue) const; 00209 00210 /** 00211 * shortcut to get the red channel only 00212 * The values of each pixel will be between 0.0f and 1.0f 00213 * @param img the image to be splitted 00214 * @param red the red channel 00215 */ 00216 bool extractRed(const matrix<image::value_type>& img, 00217 matrix<channel::value_type>& red) const; 00218 00219 00220 /** 00221 * shortcut to extract the red channel only 00222 * The values of each pixel will be between 0 and 255 00223 * @param img the image to be splitted 00224 * @param red the red channel 00225 */ 00226 bool extractRed(const matrix<image::value_type>& img, 00227 matrix<channel8::value_type>& red) const; 00228 00229 /** 00230 * shortcut to extract the red channel only 00231 * The values of each pixel will be between 0.0f and 1.0f 00232 * @param img the image to be splitted 00233 * @param green the green channel 00234 */ 00235 bool extractGreen(const matrix<image::value_type>& img, 00236 matrix<channel::value_type>& green) const; 00237 00238 00239 /** 00240 * shortcut to extract the green channel only 00241 * The values of each pixel will be between 0 and 255 00242 * @param img the image to be splitted 00243 * @param green the green channel 00244 */ 00245 bool extractGreen(const matrix<image::value_type>& img, 00246 matrix<channel8::value_type>& green) const; 00247 00248 /** 00249 * shortcut to extract the red channel only 00250 * The values of each pixel will be between 0.0f and 1.0f 00251 * @param img the image to be splitted 00252 * @param blue the blue channel 00253 */ 00254 bool extractBlue(const matrix<image::value_type>& img, 00255 matrix<channel::value_type>& blue) const; 00256 00257 00258 /** 00259 * shortcut to extract the red channel only 00260 * The values of each pixel will be between 0 and 255 00261 * @param img the image to be splitted 00262 * @param blue the blue channel 00263 */ 00264 bool extractBlue(const matrix<image::value_type>& img, 00265 matrix<channel8::value_type>& blue) const; 00266 00267 /** 00268 * Returns the first of the three channels into which the image is split. 00269 * If you need only one channel, this might be faster than calling apply(). 00270 * @param img the source image 00271 * @param c1 the extracted channel 00272 */ 00273 virtual bool extractFirst(const matrix<image::value_type>& img, 00274 matrix<channel::value_type>& c1) const; 00275 00276 /** 00277 * Returns the first of the three channels into which the image is split. 00278 * If you need only one channel, this might be faster than calling apply(). 00279 * @param img the source image 00280 * @param c1 the extracted channel 00281 */ 00282 virtual bool extractFirst(const matrix<image::value_type>& img, 00283 matrix<channel8::value_type>& c1) const; 00284 00285 /** 00286 * Returns the second of the three channels into which the image is split. 00287 * If you need only one channel, this might be faster than calling apply(). 00288 * @param img the source image 00289 * @param c2 the extracted channel 00290 */ 00291 virtual bool extractSecond(const matrix<image::value_type>& img, 00292 matrix<channel::value_type>& c2) const; 00293 00294 /** 00295 * Returns the second of the three channels into which the image is split. 00296 * If you need only one channel, this might be faster than calling apply(). 00297 * @param img the source image 00298 * @param c2 the extracted channel 00299 */ 00300 virtual bool extractSecond(const matrix<image::value_type>& img, 00301 matrix<channel8::value_type>& c2) const; 00302 00303 /** 00304 * Returns the third of the three channels into which the image is split. 00305 * If you need only one channel, this might be faster than calling apply(). 00306 * @param img the source image 00307 * @param c3 the extracted channel 00308 */ 00309 virtual bool extractThird(const matrix<image::value_type>& img, 00310 matrix<channel::value_type>& c3) const; 00311 00312 /** 00313 * Returns the third of the three channels into which the image is split. 00314 * If you need only one channel, this might be faster than calling apply(). 00315 * @param img the source image 00316 * @param c3 the extracted channel 00317 */ 00318 virtual bool extractThird(const matrix<image::value_type>& img, 00319 matrix<channel8::value_type>& c3) const; 00320 00321 }; 00322 00323 } // namespace cvr 00324 #endif 00325