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

ltiDrawFlowField.h

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 .......: ltiDrawFlowField.h
00027  * authors ....: Bernd Mussmann, Suat Akyol
00028  * organization: LTI, RWTH Aachen
00029  * creation ...: 16.8.2000
00030  * revisions ..: $Id: ltiDrawFlowField.h,v 1.7 2006/02/07 18:48:08 ltilib Exp $
00031  */
00032 
00033 #ifndef _LTI_DRAW_FLOW_FIELD_H_
00034 #define _LTI_DRAW_FLOW_FIELD_H_
00035 
00036 // include files which are needed in this header!!
00037 #include "ltiGaussKernels.h"
00038 #include "ltiDownsampling.h"
00039 #include "ltiDraw.h"
00040 #include "ltiImage.h"
00041 #include "ltiFilledUpsampling.h"
00042 
00043 // include parent class:
00044 #include "ltiFunctor.h"
00045 
00046 namespace lti {
00047   /**
00048    * Draws the visualization of a two dimensional flowfield.
00049    * The channels of the x and y component are the input %parameters,
00050    * a picture of the flowfield is the output. The input channels must
00051    * have the same dimensions.
00052    */
00053   class drawFlowField : public functor {
00054   public:
00055     /**
00056      * the parameters for the class drawFlowField
00057      */
00058     class parameters : public functor::parameters {
00059     public:
00060       /**
00061        * Type for choosing overlayMode
00062        */
00063       enum eOverlayMode {
00064         NoOverlay,  /*!< draws flow field on black background */
00065         OnFlowfield,/*!< draws flow field on channel, which is
00066                          given for output                     */
00067         OnValue,    /*!< draws flow field on internally computed
00068                          value of itself                      */
00069         OnPhase     /*!< draws flow field on internally computed
00070                          phase of itself                      */
00071       };
00072 
00073       /**
00074        * Type for choosing vectorMode
00075        */
00076       enum eVectorMode {
00077         Arrows,  /*!< draws flow vectors as arrows*/
00078         Lines    /*!< draws flow vectors as lines */
00079       };
00080 
00081       /**
00082        * Type for choosing ScalingMode
00083        */
00084       enum eScalingMode {
00085         GridWidth,  /*!< longest vector will be scaled to gridWidth*/
00086         NoScaling   /*!< vectors will not be scaled in any way     */
00087       };
00088 
00089       /**
00090        * default constructor
00091        */
00092       parameters();
00093 
00094       /**
00095        * copy constructor
00096        * @param other the parameters object to be copied
00097        */
00098       parameters(const parameters& other);
00099 
00100       /**
00101        * destructor
00102        */
00103       ~parameters();
00104 
00105       /**
00106        * returns name of this type
00107        */
00108       const char* getTypeName() const;
00109 
00110       /**
00111        * copy the contents of a parameters object
00112        * @param other the parameters object to be copied
00113        * @return a reference to this parameters object
00114        */
00115       parameters& copy(const parameters& other);
00116 
00117       /**
00118        * returns a pointer to a clone of the parameters
00119        */
00120       virtual functor::parameters* clone() const;
00121 
00122       /**
00123        * write the parameters in the given ioHandler
00124        * @param handler the ioHandler to be used
00125        * @param complete if true (the default) the enclosing begin/end will
00126        *        be also written, otherwise only the data block will be written.
00127        * @return true if write was successful
00128        */
00129       virtual bool write(ioHandler& handler,const bool complete=true) const;
00130 
00131       /**
00132        * write the parameters in the given ioHandler
00133        * @param handler the ioHandler to be used
00134        * @param complete if true (the default) the enclosing begin/end will
00135        *        be also written, otherwise only the data block will be written.
00136        * @return true if write was successful
00137        */
00138       virtual bool read(ioHandler& handler,const bool complete=true);
00139 
00140 #     ifdef _LTI_MSC_6
00141       /**
00142        * this function is required by MSVC only, as a workaround for a
00143        * very awful bug, which exists since MSVC V.4.0, and still by
00144        * V.6.0 with all bugfixes (so called "service packs") remains
00145        * there...  This method is public due to another bug, so please
00146        * NEVER EVER call this method directly: use read() instead!
00147        */
00148       bool readMS(ioHandler& handler,const bool complete=true);
00149 
00150       /**
00151        * this function is required by MSVC only, as a workaround for a
00152        * very awful bug, which exists since MSVC V.4.0, and still by
00153        * V.6.0 with all bugfixes (so called "service packs") remains
00154        * there...  This method is public due to another bug, so please
00155        * NEVER EVER call this method directly: use write() instead!
00156        */
00157       bool writeMS(ioHandler& handler,const bool complete=true) const;
00158 #     endif
00159 
00160       // ------------------------------------------------
00161       // the parameters of functor
00162       // ------------------------------------------------
00163 
00164       /**
00165        * Tells, how much larger the output flow field channel should
00166        * be compared to the the input channel(s).
00167        * zoomfactor = 1,2,... (default=1)
00168        */
00169       int zoomfactor;
00170 
00171       /**
00172        * Input channels are sampled by this factor.
00173        * samplerate = 1,2,... (default=5)
00174        */
00175       int samplerate;
00176 
00177       /**
00178        * If value of current samplingpoint is smaller than the percentage
00179        * (given by threshold) of maximum value, flow line will not be drawn.
00180        * threshold = 0.0 ... 1.0 (default=0.1)
00181        */
00182       float threshold;
00183 
00184       /**
00185        * overlayMode can be one of: noOverlay (default), onFlowfield, onValue,
00186        * onPhase.
00187        *
00188        * noOverlay = draws flow field on black background
00189        *
00190        * onFlowfield = draws flow field on channel, which is handed over
00191        *               for output
00192        *
00193        * onValue/onPhase = draws flow field on internally computed value/phase
00194        */
00195       eOverlayMode overlayMode;
00196 
00197       /**
00198        * vectorMode can be one of: arrows(default), lines.
00199        *
00200        * arrows = draws flow vectors as lines
00201        *
00202        * lines = draws flow vectors as arrows
00203        *
00204        */
00205       eVectorMode vectorMode;
00206 
00207       /**
00208        * scalingMode can be one of: NoScaling, GridWidth(default).
00209        *
00210        * NoScaling = vectors will not be scaled
00211        *
00212        * GridWidth = vectors will be scaled, so that the longest one
00213        * becomes as long as grid width(=samplerate*zoomfactor)
00214        */
00215       eScalingMode scalingMode;
00216 
00217       /**
00218        * Color of flow line.
00219        * linecolor = 0.0 ... 1.0 (default=0.3)
00220        */
00221       float linecolor;
00222 
00223       /**
00224        * Color of flow line tip.
00225        * tipcolor = 0.0 ... 1.0 (default=1.0)
00226        */
00227       float tipcolor;
00228     };
00229 
00230 
00231     /**
00232      * default constructor
00233      */
00234     drawFlowField();
00235 
00236     /**
00237      * copy constructor
00238      * @param other the object to be copied
00239      */
00240     drawFlowField(const drawFlowField& other);
00241 
00242     /**
00243      * destructor
00244      */
00245     virtual ~drawFlowField();
00246 
00247     /**
00248      * returns the name of this type ("drawFlowField")
00249      */
00250     virtual const char* getTypeName() const;
00251 
00252     /**
00253      * operates on the given %parameters.
00254      * @param x_component channel must be the flow component in x-direction.
00255      * @param y_component channel must be the flow component in y-direction.
00256      * @return true if successful, false otherwise
00257      */
00258     bool apply(channel& x_component,channel& y_component) const;
00259 
00260     /**
00261      * operates on a copy of the given %parameters.
00262      * @param x_component channel must be the flow component in x-direction.
00263      * @param y_component channel must be the flow component in y-direction.
00264      * @param flowfield contains the resulting visualization.
00265      * @return true if successful, false otherwise
00266      */
00267     bool apply(const channel& x_component,
00268                const channel& y_component,
00269                      channel& flowfield) const;
00270 
00271     /**
00272      * copy data of "other" functor.
00273      * @param other the functor to be copied
00274      * @return a reference to this functor object
00275      */
00276     drawFlowField& copy(const drawFlowField& other);
00277 
00278     /**
00279      * returns a pointer to a clone of this functor.
00280      */
00281     virtual functor* clone() const;
00282 
00283     /**
00284      * returns used parameters
00285      */
00286     const parameters& getParameters() const;
00287   };
00288 }
00289 
00290 #endif

Generated on Sat Apr 10 15:25:23 2010 for LTI-Lib by Doxygen 1.6.1