last update 20 Sep 2009 |
00001 /* 00002 * Copyright (C) 2007 00003 * Pablo Alvarado 00004 * 00005 * This file is part of the Computer Vision and Robotics Library (CVR-Lib) 00006 * 00007 * The CVR-Lib is free software; you can redistribute it and/or 00008 * modify it under the terms of the BSD License. 00009 * 00010 * All rights reserved. 00011 * 00012 * Redistribution and use in source and binary forms, with or without 00013 * modification, are permitted provided that the following conditions are met: 00014 * 00015 * 1. Redistributions of source code must retain the above copyright notice, 00016 * this list of conditions and the following disclaimer. 00017 * 00018 * 2. Redistributions in binary form must reproduce the above copyright notice, 00019 * this list of conditions and the following disclaimer in the documentation 00020 * and/or other materials provided with the distribution. 00021 * 00022 * 3. Neither the name of the authors nor the names of its contributors may be 00023 * used to endorse or promote products derived from this software without 00024 * specific prior written permission. 00025 * 00026 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00027 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00028 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00029 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00030 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00031 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00032 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00033 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00034 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00035 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00036 * POSSIBILITY OF SUCH DAMAGE. 00037 */ 00038 00039 /** 00040 * \file cvrContrastEnhancement.h 00041 * Contains the abstract class cvr::contrastEnhancement, 00042 * from which all contrast enhancement classes are derived. 00043 * 00044 * \author Pablo Alvarado 00045 * \date 18.10.2007 00046 * 00047 * revisions ..: $Id: cvrContrastEnhancement.h,v 1.1 2007/10/18 17:28:55 alvarado Exp $ 00048 */ 00049 00050 #ifndef _CVR_CONTRAST_ENHANCEMENT_H_ 00051 #define _CVR_CONTRAST_ENHANCEMENT_H_ 00052 00053 #include "cvrBoundaryType.h" 00054 #include "cvrChannelProcessingInterface.h" 00055 #include "cvrFunctor.h" 00056 00057 namespace cvr { 00058 00059 /** 00060 * Class contrastEnhancement. 00061 * 00062 * This is an abstract class used to define the common interface for 00063 * all functors that achieve contrast enhancement (e.g. histogram 00064 * equalization). 00065 * 00066 * @see contrastEnhancement::parameters. 00067 * 00068 * @ingroup gContrastEnhancement 00069 */ 00070 class contrastEnhancement : public functor, 00071 public channelProcessingInterface<float>, 00072 public channelProcessingInterface<ubyte> { 00073 public: 00074 /** 00075 * The parameters for the class contrastEnhancement 00076 */ 00077 class parameters : public functor::parameters { 00078 public: 00079 /** 00080 * Default constructor 00081 */ 00082 parameters(); 00083 00084 /** 00085 * Copy constructor 00086 * @param other the parameters object to be copied 00087 */ 00088 parameters(const parameters& other); 00089 00090 /** 00091 * Destructor 00092 */ 00093 ~parameters(); 00094 00095 /** 00096 * Copy the contents of a parameters object 00097 * @param other the parameters object to be copied 00098 * @return a reference to this parameters object 00099 */ 00100 parameters& copy(const parameters& other); 00101 00102 /** 00103 * Copy the contents of a parameters object 00104 * @param other the parameters object to be copied 00105 * @return a reference to this parameters object 00106 */ 00107 parameters& operator=(const parameters& other); 00108 00109 /** 00110 * Returns the complete name of the parameters class. 00111 */ 00112 virtual const std::string& name() const; 00113 00114 /** 00115 * Returns a pointer to a clone of the parameters. 00116 */ 00117 virtual parameters* clone() const; 00118 00119 /** 00120 * Returns a pointer to a new instance of the parameters. 00121 */ 00122 virtual parameters* newInstance() const; 00123 00124 /** 00125 * Write the parameters in the given ioHandler 00126 * @param handler the ioHandler to be used 00127 * @param complete if true (the default) the enclosing begin/end will 00128 * be also written, otherwise only the data block will be written. 00129 * @return true if write was successful 00130 */ 00131 virtual bool write(ioHandler& handler,const bool complete=true) const; 00132 00133 /** 00134 * Read the parameters from the given ioHandler 00135 * @param handler the ioHandler to be used 00136 * @param complete if true (the default) the enclosing begin/end will 00137 * be also written, otherwise only the data block will be written. 00138 * @return true if write was successful 00139 */ 00140 virtual bool read(ioHandler& handler,const bool complete=true); 00141 00142 // ------------------------------------------------ 00143 // the parameters 00144 // ------------------------------------------------ 00145 00146 00147 /** 00148 * Boundary type. 00149 * 00150 * Refers to how the regions outside the image should be considered. 00151 * 00152 * Default value: Zero. 00153 */ 00154 eBoundaryType boundaryType; 00155 00156 }; 00157 00158 /** 00159 * Default constructor 00160 */ 00161 contrastEnhancement(); 00162 00163 00164 /** 00165 * Copy constructor 00166 * @param other the object to be copied 00167 */ 00168 contrastEnhancement(const contrastEnhancement& other); 00169 00170 /** 00171 * Destructor 00172 */ 00173 virtual ~contrastEnhancement(); 00174 00175 /** 00176 * Operates on the given argument. 00177 * 00178 * @param srcdest channel with the source data. The result 00179 * will be left here too. 00180 * @return true if apply successful or false otherwise. 00181 */ 00182 virtual bool apply(channel& srcdest) const = 0; 00183 00184 /** 00185 * Operates on the given argument. 00186 * 00187 * @param srcdest channel8 with the source data. The result 00188 * will be left here too. 00189 * @return true if apply successful or false otherwise. 00190 */ 00191 virtual bool apply(channel8& srcdest) const = 0; 00192 00193 /** 00194 * Operates on a copy of the given arguments. 00195 * 00196 * @param src channel with the source data. 00197 * @param dest channel where the result will be left. 00198 * @return true if apply successful or false otherwise. 00199 */ 00200 virtual bool apply(const channel& src, channel& dest) const = 0; 00201 00202 /** 00203 * Operates on a copy of the given arguments. 00204 * 00205 * @param src channel8 with the source data. 00206 * @param dest channel8 where the result will be left. 00207 * @return true if apply successful or false otherwise. 00208 */ 00209 virtual bool apply(const channel8& src, channel8& dest) const = 0; 00210 00211 00212 /** 00213 * Copy data of "other" functor. 00214 * @param other the functor to be copied 00215 * @return a reference to this functor object 00216 */ 00217 contrastEnhancement& copy(const contrastEnhancement& other); 00218 00219 /** 00220 * Alias for copy member 00221 * @param other the functor to be copied 00222 * @return a reference to this functor object 00223 */ 00224 contrastEnhancement& operator=(const contrastEnhancement& other); 00225 00226 /** 00227 * Returns the complete name of the functor class 00228 */ 00229 virtual const std::string& name() const; 00230 00231 /** 00232 * Returns a pointer to a clone of this functor. 00233 */ 00234 virtual contrastEnhancement* clone() const = 0; 00235 00236 /** 00237 * Returns a pointer to a new instance of this functor. 00238 */ 00239 virtual contrastEnhancement* newInstance() const = 0; 00240 00241 /** 00242 * Returns used parameters 00243 */ 00244 const parameters& getParameters() const; 00245 00246 }; 00247 } 00248 00249 #endif 00250