LTI-Lib latest version v1.9 - last update 10 Apr 2010

ltiRotation.h

00001 /*
00002  * Copyright (C) 2003, 2004, 2005, 2006
00003  * Vlad Popovici, EPFL STI-ITS, Switzerland
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  * file .......: ltiRotation.h
00026  * authors ....: Vlad Popovici
00027  * organization: EPFL STI-ITS/LTS1
00028  * creation ...: 18.6.2003
00029  * revisions ..: $Id: ltiRotation.h,v 1.8 2006/02/07 19:36:38 ltilib Exp $
00030  */
00031 
00032 #ifndef _LTI_ROTATION_H_
00033 #define _LTI_ROTATION_H_
00034 
00035 // For a description and a more pedagogical implementation of the
00036 // rotation algorithm, see http://www.leptonica.com/index.html
00037 
00038 #include "ltiModifier.h"
00039 
00040 namespace lti {
00041 
00042   /**
00043    * Rotation implements a rotation functor.
00044    *
00045    * The algorithm used is call Rotation by Shear, nicely
00046    * reviewed at http://www.leptonica.com/rotation.html#ROTATION-BY-SHEAR
00047    *
00048    * The size of the computed image will always be enhanced to contain
00049    * the whole (rotated) image.  In other words, you will get the same
00050    * result as using lti::geometricTransform using the parameter
00051    * \c keepDimensions set to false. 
00052    *
00053    * This functor does always a bilinear interpolation, but supports only the
00054    * boundary type "Zero", to avoid some comparisons and increase efficiency.
00055    *
00056    * \warning The speed gains of this functor compared with
00057    * lti::geometricTransform are marginal or non-existent, i.e. this functor
00058    * algorithm can be even slower.  The functor exists to provide an
00059    * interface, that can wrap a more efficient algorithm in the future.
00060    *
00061    * For more complex operations you can still use the lti::geometricTransform 
00062    * functor.
00063    *
00064    * @see lti::geometricTransform
00065    *
00066    * @ingroup gGeometry
00067    */
00068   class rotation : public modifier {
00069   public:
00070     /**
00071      * the parameters for the class rotation
00072      */
00073     class parameters : public modifier::parameters {
00074     public:
00075       /**
00076        * default constructor
00077        */
00078       parameters();
00079 
00080       /**
00081        * copy constructor
00082        * @param other the parameters object to be copied
00083        */
00084       parameters(const parameters& other);
00085 
00086       /**
00087        * destructor
00088        */
00089       ~parameters();
00090 
00091       /**
00092        * returns name of this type
00093        */
00094       const char* getTypeName() const;
00095 
00096       /**
00097        * copy the contents of a parameters object
00098        * @param other the parameters object to be copied
00099        * @return a reference to this parameters object
00100        */
00101       parameters& copy(const parameters& other);
00102 
00103       /**
00104        * copy the contents of a parameters object
00105        * @param other the parameters object to be copied
00106        * @return a reference to this parameters object
00107        */
00108       parameters& operator=(const parameters& other);
00109 
00110 
00111       /**
00112        * returns a pointer to a clone of the parameters
00113        */
00114       virtual functor::parameters* clone() const;
00115 
00116       /**
00117        * write the parameters in the given ioHandler
00118        * @param handler the ioHandler to be used
00119        * @param complete if true (the default) the enclosing begin/end will
00120        *        be also written, otherwise only the data block will be written.
00121        * @return true if write was successful
00122        */
00123       virtual bool write(ioHandler& handler,const bool complete=true) const;
00124 
00125       /**
00126        * read the parameters from the given ioHandler
00127        * @param handler the ioHandler to be used
00128        * @param complete if true (the default) the enclosing begin/end will
00129        *        be also written, otherwise only the data block will be written.
00130        * @return true if write was successful
00131        */
00132       virtual bool read(ioHandler& handler,const bool complete=true);
00133 
00134 #     ifdef _LTI_MSC_6
00135       /**
00136        * this function is required by MSVC only, as a workaround for a
00137        * very awful bug, which exists since MSVC V.4.0, and still by
00138        * V.6.0 with all bugfixes (so called "service packs") remains
00139        * there...  This method is also public due to another bug, so please
00140        * NEVER EVER call this method directly: use read() instead
00141        */
00142       bool readMS(ioHandler& handler,const bool complete=true);
00143 
00144       /**
00145        * this function is required by MSVC only, as a workaround for a
00146        * very awful bug, which exists since MSVC V.4.0, and still by
00147        * V.6.0 with all bugfixes (so called "service packs") remains
00148        * there...  This method is also public due to another bug, so please
00149        * NEVER EVER call this method directly: use write() instead
00150        */
00151       bool writeMS(ioHandler& handler,const bool complete=true) const;
00152 #     endif
00153 
00154       // ------------------------------------------------
00155       // the parameters
00156       // ------------------------------------------------
00157 
00158       /**
00159        * Rotation angle.  
00160        *
00161        * In radians.  You can use the global function lti::degToRad() to
00162        * convert a degrees value to radians.
00163        *
00164        * As usual in the LTI-Lib, the coordinate system of image is
00165        * left-handed, (y=0 means the top of the image, y>0 goes down).  An
00166        * increasing positive angle denotes in such a coordinate system a
00167        * clockwise rotation.
00168        *
00169        * Default value: 0
00170        */
00171       double angle;
00172 
00173     };
00174 
00175     /**
00176      * default constructor
00177      */
00178     rotation();
00179 
00180     /**
00181      * Construct a functor using the given parameters
00182      */
00183     rotation(const parameters& par);
00184 
00185     /**
00186      * copy constructor
00187      * @param other the object to be copied
00188      */
00189     rotation(const rotation& other);
00190 
00191     /**
00192      * destructor
00193      */
00194     virtual ~rotation();
00195 
00196     /**
00197      * returns the name of this type ("rotation")
00198      */
00199     virtual const char* getTypeName() const;
00200     
00201     /**
00202      * Operates on the given %parameter.
00203      * @param srcdest image with the source data.  The result
00204      *                 will be left here too.
00205      * @return true if apply successful or false otherwise.
00206      */
00207     bool apply(image& srcdest) const;
00208 
00209     /**
00210      * Operates on a copy of the given %parameters.
00211      * @param src image with the source data.
00212      * @param dest image where the result will be left.
00213      * @return true if apply successful or false otherwise.
00214      */
00215     bool apply(const image& src,image& dest) const;
00216 
00217 
00218     /**
00219      * Operates on the given %parameter.
00220      * @param srcdest matrix<ubyte> with the source data.  The result
00221      *                 will be left here too.
00222      * @return true if apply successful or false otherwise.
00223      */
00224     bool apply(matrix<ubyte>& srcdest) const;
00225 
00226     /**
00227      * Operates on a copy of the given %parameters.
00228      * @param src matrix<ubyte> with the source data.
00229      * @param dest matrix<ubyte> where the result will be left.
00230      * @return true if apply successful or false otherwise.
00231      */
00232     bool apply(const matrix<ubyte>& src,matrix<ubyte>& dest) const;
00233 
00234     /**
00235      * Operates on the given %parameter.
00236      * @param srcdest matrix<float> with the source data.  The result
00237      *                 will be left here too.
00238      * @return true if apply successful or false otherwise.
00239      */
00240     bool apply(matrix<float>& srcdest) const;
00241 
00242     /**
00243      * Operates on a copy of the given %parameters.
00244      * @param src matrix<float> with the source data.
00245      * @param dest matrix<float> where the result will be left.
00246      * @return true if apply successful or false otherwise.
00247      */
00248     bool apply(const matrix<float>& src,matrix<float>& dest) const;
00249 
00250     /**
00251      * Operates on the given %parameter.
00252      * @param angle rotation angle used instead of the value in the parameters
00253      *              object, which is ignored.
00254      * @param srcdest image with the source data.  The result
00255      *                 will be left here too.
00256      * @return true if apply successful or false otherwise.
00257      */
00258     bool apply(const double& angle,image& srcdest) const;
00259 
00260     /**
00261      * Operates on a copy of the given %parameters.
00262      * @param angle rotation angle used instead of the value in the parameters
00263      *              object, which is ignored.
00264      * @param src image with the source data.
00265      * @param dest image where the result will be left.
00266      * @return true if apply successful or false otherwise.
00267      */
00268     bool apply(const double& angle,const image& src,image& dest) const;
00269 
00270 
00271     /**
00272      * Operates on the given %parameter.
00273      * @param angle rotation angle used instead of the value in the parameters
00274      *              object, which is ignored.
00275      * @param srcdest matrix<ubyte> with the source data.  The result
00276      *                 will be left here too.
00277      * @return true if apply successful or false otherwise.
00278      */
00279     bool apply(const double& angle,matrix<ubyte>& srcdest) const;
00280 
00281     /**
00282      * Operates on a copy of the given %parameters.
00283      * @param angle rotation angle used instead of the value in the parameters
00284      *              object, which is ignored.
00285      * @param src matrix<ubyte> with the source data.
00286      * @param dest matrix<ubyte> where the result will be left.
00287      * @return true if apply successful or false otherwise.
00288      */
00289     bool apply(const double& angle,
00290                const matrix<ubyte>& src,
00291                matrix<ubyte>& dest) const;
00292 
00293     /**
00294      * Operates on the given %parameter.
00295      * @param angle rotation angle used instead of the value in the parameters
00296      *              object, which is ignored.
00297      * @param srcdest matrix<float> with the source data.  The result
00298      *                 will be left here too.
00299      * @return true if apply successful or false otherwise.
00300      */
00301     bool apply(const double& angle,
00302                matrix<float>& srcdest) const;
00303 
00304     /**
00305      * Operates on a copy of the given %parameters.
00306      * @param angle rotation angle used instead of the value in the parameters
00307      *              object, which is ignored.
00308      * @param src matrix<float> with the source data.
00309      * @param dest matrix<float> where the result will be left.
00310      * @return true if apply successful or false otherwise.
00311      */
00312     bool apply(const double& angle,
00313                const matrix<float>& src,matrix<float>& dest) const;
00314 
00315     /**
00316      * copy data of "other" functor.
00317      * @param other the functor to be copied
00318      * @return a reference to this functor object
00319      */
00320     rotation& copy(const rotation& other);
00321 
00322     /**
00323      * alias for copy member
00324      * @param other the functor to be copied
00325      * @return a reference to this functor object
00326      */
00327     rotation& operator=(const rotation& other);
00328 
00329     /**
00330      * returns a pointer to a clone of this functor.
00331      */
00332     virtual functor* clone() const;
00333 
00334     /**
00335      * returns used parameters
00336      */
00337     const rotation::parameters& getParameters() const;
00338   };
00339 }
00340 
00341 #endif

Generated on Sat Apr 10 15:26:05 2010 for LTI-Lib by Doxygen 1.6.1