latest version v1.9 - last update 10 Apr 2010 |
00001 /* 00002 * Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 00003 * Lehrstuhl fuer Technische Informatik, RWTH-Aachen, Germany 00004 * 00005 * This file is part of the LTI-Computer Vision Library (LTI-Lib) 00006 * 00007 * The LTI-Lib is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public License (LGPL) 00009 * as published by the Free Software Foundation; either version 2.1 of 00010 * the License, or (at your option) any later version. 00011 * 00012 * The LTI-Lib is distributed in the hope that it will be 00013 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty 00014 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with the LTI-Lib; see the file LICENSE. If 00019 * not, write to the Free Software Foundation, Inc., 59 Temple Place - 00020 * Suite 330, Boston, MA 02111-1307, USA. 00021 */ 00022 00023 00024 /*---------------------------------------------------------------- 00025 * project ....: LTI Digital Image/Signal Processing Library 00026 * file .......: ltiLinearSatMapperFunctor.h 00027 * authors ....: Pablo Alvarado 00028 * organization: LTI, RWTH Aachen 00029 * creation ...: 10.7.2000 00030 * revisions ..: $Id: ltiLinearSatMapperFunctor.h,v 1.8 2006/02/08 12:31:59 ltilib Exp $ 00031 */ 00032 00033 #ifndef _LTI_LINEAR_SAT_MAPPER_FUNCTOR_H_ 00034 #define _LTI_LINEAR_SAT_MAPPER_FUNCTOR_H_ 00035 00036 #include "ltiObject.h" 00037 #include "ltiMapperFunctor.h" 00038 00039 namespace lti { 00040 00041 /** 00042 * This %functor maps a %vector space of type Tin into another %vector 00043 * space of type Tout. The dimensionality and boundaries of both spaces 00044 * can be specified through the lti::mapperFunctor::parameters 00045 * class. 00046 * 00047 * The mapping-function is linear. If an input %point is outer bounds, the 00048 * output %point will be corrected to the next valid dimension. 00049 * 00050 * For the following example a chromaticity %histogram will be created with 00051 * 10 cells for the red and 16 cells for the green channel 00052 * 00053 * \code 00054 * lti::image img; // the image to be analysed 00055 * // ... // load or create the image to be analysed 00056 * lti::splitImageTorgI splitter; 00057 * lti::channel r,g,I; 00058 * 00059 * splitter.apply(r,g,I); // get chromaticity channels 00060 * 00061 * lti::histogram2D histo(10,16); // a two dimensional histogram 00062 * // the mapper functor 00063 * lti::linearSatMapperFunctor<float> mapper; 00064 * lti::linearSatMapperFunctor<float>::parameters mapParam; 00065 * 00066 * mapParam.generateFrom(histo); 00067 * mapParam.lowerLimitsInput.fill(0.0f); 00068 * mapParam.upperLimitsInput.fill(1.0f); 00069 * 00070 * histo.setParameters(mapParam); 00071 * 00072 * lti::point p,q; 00073 * 00074 * // for each pixel in the channels 00075 * for (p.y=0;p.y<r.rows();p.y++) { 00076 * for (p.x=0;p.x<g.rows();p.x++) { 00077 * histo.put(mapper(r.at(p),g.at(p),q)); 00078 * } 00079 * } 00080 * \endcode 00081 */ 00082 template <class Tin, class Tout=int> 00083 class linearSatMapperFunctor : public mapperFunctor<Tin,Tout> { 00084 public: 00085 /** 00086 * the parameters for the class linearSatMapperFunctor 00087 */ 00088 class parameters : public mapperFunctor<Tin,Tout>::parameters { 00089 public: 00090 /** 00091 * default constructor 00092 */ 00093 parameters() : mapperFunctor<Tin,Tout>::parameters() { 00094 }; 00095 00096 /** 00097 * copy constructor 00098 * @param other the parameters object to be copied 00099 */ 00100 parameters(const parameters& other){ 00101 copy(other); 00102 }; 00103 00104 /** 00105 * destructor 00106 */ 00107 ~parameters() {}; 00108 00109 /** 00110 * returns name of this type 00111 */ 00112 const char* getTypeName() const { 00113 return "linearSatMapperFunctor::parameters"; 00114 }; 00115 00116 /** 00117 * copy the contents of a parameters object 00118 * @param other the parameters object to be copied 00119 * @return a reference to this parameters object 00120 */ 00121 parameters& copy(const parameters& other) { 00122 # ifndef _LTI_MSC_6 00123 // MS Visual C++ 6 is not able to compile this... 00124 mapperFunctor<Tin,Tout>::parameters::copy(other); 00125 # else 00126 // ...so we have to use this workaround. 00127 // Conditional on that, copy may not be virtual. 00128 mapperFunctor<Tin,Tout>::parameters& 00129 (mapperFunctor<Tin,Tout>::parameters::* p_copy) 00130 (const mapperFunctor<Tin,Tout>::parameters&) = 00131 mapperFunctor<Tin,Tout>::parameters::copy; 00132 (this->*p_copy)(other); 00133 # endif 00134 00135 return *this; 00136 }; 00137 00138 /** 00139 * returns a pointer to a clone of the parameters 00140 */ 00141 virtual functor::parameters* clone() const { 00142 return new parameters(*this); 00143 }; 00144 00145 }; 00146 00147 /** 00148 * default constructor 00149 */ 00150 linearSatMapperFunctor(); 00151 00152 /** 00153 * copy constructor 00154 * @param other the object to be copied 00155 */ 00156 linearSatMapperFunctor(const linearSatMapperFunctor& other); 00157 00158 /** 00159 * destructor 00160 */ 00161 virtual ~linearSatMapperFunctor(); 00162 00163 /** 00164 * returns the name of this type ("linearSatMapperFunctor") 00165 */ 00166 virtual const char* getTypeName() const; 00167 00168 /** 00169 * Map the input vector src in the output vector dest. 00170 * @param src vector<Tin> with the source data. 00171 * @param dest vector<Tout> where the result will be left. 00172 * @result a reference to the <code>dest</code>. 00173 */ 00174 virtual vector<Tout>& apply(const vector<Tin>& src, 00175 vector<Tout>& dest) const; 00176 00177 /** 00178 * For the two dimensional case, maps a two dimensional vector in a 00179 * integer vector coded as a point 00180 * @param src ivector with the source data. 00181 * @param dest point where the result will be left. 00182 * @result a reference to the <code>dest</code>. 00183 */ 00184 point& apply(const vector<Tin>& src,point& dest) const; 00185 00186 /** 00187 * For the two dimensional case, maps a two dimensional vector in a 00188 * integer vector coded as a point 00189 * @param src0 the first element of the input vector 00190 * @param src1 the second element of the input vector 00191 * @param dest point where the result will be left. 00192 * @result a reference to the <code>dest</code>. 00193 */ 00194 point& apply(const Tin& src0,const Tin& src1, 00195 point& dest) const; 00196 00197 /** 00198 * For the two dimensional case, maps a two dimensional integer vector in 00199 * another integer vector, both coded as points. 00200 * @param src the source point. 00201 * @param dest point where the result will be left. 00202 * @result a reference to the <code>dest</code>. 00203 */ 00204 point& apply(const point& src,point& dest) const; 00205 00206 /** 00207 * For the one dimensional case, maps the input vector into a one 00208 * dimensional vector of type Tout. 00209 * @param src int with the source data. 00210 * @param dest int where the result will be left. 00211 * @result a reference to the <code>dest</code>. 00212 */ 00213 Tout& apply(const vector<Tin>& src,Tout& dest) const; 00214 00215 /** 00216 * For the one dimensional case, maps a one dimensional vector in a 00217 * output vector 00218 * @param src one-dimensional vector with the source data. 00219 * @param dest one-dimensional vector where the result will be left. 00220 * @result a reference to the <code>dest</code>. 00221 */ 00222 Tout& apply(const Tin& src,Tout& dest) const; 00223 00224 /** 00225 * copy data of "other" functor. 00226 * @param other the functor to be copied 00227 * @return a reference to this functor object 00228 */ 00229 linearSatMapperFunctor& copy(const linearSatMapperFunctor& other); 00230 00231 /** 00232 * returns a pointer to a clone of this functor. 00233 */ 00234 virtual functor* clone() const; 00235 00236 /** 00237 * returns used parameters 00238 */ 00239 const parameters& getParameters() const; 00240 00241 /** 00242 * set the parameters and check them for correctness 00243 */ 00244 virtual bool updateParameters(); 00245 00246 protected: 00247 /** 00248 * slopes of the mapping lines. 00249 * 00250 * These are calculated when setParameters 00251 * is called 00252 */ 00253 fvector slope; 00254 00255 /** 00256 * offset of the mapping lines. 00257 * 00258 * These are calculated when setParameters 00259 * is called 00260 */ 00261 fvector b; 00262 00263 }; 00264 } 00265 00266 #include "ltiLinearSatMapperFunctor_template.h" 00267 00268 #endif