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 cvrChannel32.h 00044 * Contains the data structure to represent gray valued images 00045 * with four bytes per pixel. 00046 * \author Pablo Alvarado 00047 * \date 09.04.1999 00048 * 00049 * $Id: cvrChannel32.h,v 1.7 2006/01/20 03:16:08 alvarado Exp $ 00050 */ 00051 00052 #ifndef _CVR_CHANNEL32_H_ 00053 #define _CVR_CHANNEL32_H_ 00054 00055 #include "cvrMatrix.h" 00056 #include "cvrTypes.h" 00057 00058 namespace cvr { 00059 00060 class channel; 00061 class image; 00062 00063 /** 00064 * A format for 32-bit channels. 00065 * 00066 * This class is identical to a matrix of int32 except for the method 00067 * castFrom(channel) 00068 * 00069 * The value range is between -(2^31) and (2^31-1) (see 00070 * cvr::image for more information). 00071 * 00072 * @see cvr::image, cvr::channel, cvr::channel8 00073 * 00074 * @ingroup gAggregate 00075 * @ingroup gImageProcessing 00076 */ 00077 class channel32 : public matrix<int32> { 00078 public: 00079 /** 00080 * Default constructor creates an empty channel32 00081 */ 00082 channel32(); 00083 00084 /** 00085 * Create a connected \c rows x \c cols channel32 and leave all 00086 * elements uninitialized. 00087 * 00088 * @param rows number of rows of the channel32 00089 * @param cols number of columns of the channel32 00090 */ 00091 channel32(const int rows,const int cols); 00092 00093 /** 00094 * Create a connected \c size.y x \c size.x 00095 * channel32 and leave all elements uninitialized. 00096 * 00097 * @param size cvr::point with the size of the channel32 00098 * (size.x is the number of columns and 00099 * size.y the number of rows) 00100 */ 00101 channel32(const ipoint& size); 00102 00103 /** 00104 * Create a connected \c rows x \c cols channel32 and initializes 00105 * all elements with \a iniValue. 00106 * 00107 * @param rows number of rows of the channel32 00108 * @param cols number of columns of the channel32 00109 * @param iniValue all elements will be initialized with this value 00110 */ 00111 channel32(const int rows,const int cols,const int32& iniValue); 00112 00113 /** 00114 * Create a connected \c size.y x \c size.x 00115 * Channel32 and initializes all elements with \a iniValue 00116 * @param size cvr::point with the size of the channel32 00117 * (size.x is the number of columns and 00118 * size.y the number of rows) 00119 * @param iniValue all elements will be initialized with this value 00120 */ 00121 channel32(const ipoint& size,const int32& iniValue); 00122 00123 /** 00124 * Create a connected \c rows x \c cols Channel32 and initializes 00125 * all elements with the data pointed by \a data. The first 00126 * \a cols-elements of the data will be copied on the first row, 00127 * the next ones on the second row and so on. 00128 * 00129 * @param rows number of rows of the channel32 00130 * @param cols number of columns of the channel32 00131 * @param data pointer to the memory block with the data to be initialized 00132 * with. 00133 */ 00134 channel32(const int rows,const int cols,const int32 data[]); 00135 00136 00137 /** 00138 * Copy constructor. 00139 * 00140 * Create this channel32 as a connected copy of another channel32 00141 * for this const version, the data will be always copied! 00142 * It is also possible to create a copy of a subchannel of another 00143 * channel. 00144 * 00145 * @param other the channel32 to be copied. 00146 * @param fromRow initial row of the other channel32 to be copied 00147 * @param fromCol initial column of the other channel32 to be copied 00148 * @param toRow last row to be copied of the other channel32 00149 * @param toCol last column to be copied of the other channel32 00150 * 00151 * Example: 00152 * \code 00153 * cvr::channel32 m(4,6,0); // channel32 with 24 elements 00154 * // ... 00155 * // initialize channel32 with: 00156 * // 0 1 2 3 4 5 00157 * // 2 1 5 4 0 3 00158 * // 1 2 1 2 3 2 00159 * // 3 3 2 1 2 3 00160 * 00161 * cvr::channel32 sm(m,1,3,0,2) // last line will leat to 00162 * // following contents in sm: 00163 * // 1 2 3 00164 * // 1 5 4 00165 * // 2 1 2 00166 * \endcode 00167 * 00168 */ 00169 channel32(const channel32& other, 00170 const int fromRow, 00171 const int fromCol=0, 00172 const int toRow=MaxIndex, 00173 const int toCol=MaxIndex); 00174 00175 00176 /** 00177 * Copy constructor. 00178 * 00179 * @param other the channel32 to be copied. 00180 */ 00181 channel32(const channel32& other); 00182 00183 /** 00184 * Copy constructor. 00185 * 00186 * Copy a submatrix of another channel32 00187 * 00188 * @param other the channel32 to be copied. 00189 * @param from initial point of the window to be copied 00190 * @param to final point (included) of the window to be copied. 00191 */ 00192 channel32(const channel32& other, 00193 const ipoint& from, 00194 const ipoint& to); 00195 00196 /** 00197 * Returns the name of this type. 00198 */ 00199 virtual const std::string& name() const; 00200 00201 /** 00202 * Create a clone of this channel32 00203 * @return a pointer to a copy of this matrix 00204 */ 00205 virtual channel32* clone() const; 00206 00207 /** 00208 * Create a new empty channel32 00209 * @return a pointer to a copy of this matrix 00210 */ 00211 virtual channel32* newInstance() const; 00212 00213 /** 00214 * Compute the sum of all elements in the channel 00215 */ 00216 int computeSumOfElements() const; 00217 00218 /** 00219 * Copy the \a other channel by casting each of its elements. 00220 * 00221 * The elements of the channel will be multiplied by 255 if no 00222 * other %parameter but the channel is given.. 00223 * 00224 * @param other the channel to be cast from 00225 * 00226 * @param minToBlack if minToBlack is true, a linear gray-valued 00227 * tranformation will be applied, which maps the minimal value in 00228 * the channel to zero. If false, the value zero will be mapped 00229 * to zero. 00230 * 00231 * @param maxToWhite if maxToWhite is true, a linear gray-valued 00232 * transformation will be applied, which maps the maximal value in 00233 * the channel to 255. If false, the value 1.0f will be mapped to 00234 * 255. 00235 * 00236 * @return a reference to this channel 00237 * Example: 00238 * \code 00239 * cvr::channel matA(10,10,1); // a channel 00240 * cvr::channel32 matB; // a channel32 00241 * 00242 * matB.castFrom(matA); // this will copy matA in matB!! 00243 * // and all elements will have 255 00244 * \endcode */ 00245 channel32& castFrom(const channel& other, 00246 const bool minToBlack = false, 00247 const bool maxToWhite = false); 00248 00249 /** 00250 * Copy the \a other matrix by casting each of its elements 00251 * 00252 * @param other The matrix to be cast 00253 * @return a reference to this channel 00254 */ 00255 template<class U> 00256 inline channel32& castFrom(const matrix<U>& other); 00257 }; 00258 00259 template<class U> 00260 inline channel32& channel32::castFrom(const matrix<U>& other) { 00261 matrix<value_type>::castFrom(other); 00262 return *this; 00263 } 00264 00265 } 00266 00267 00268 #endif 00269