CVR-Lib last update 20 Sep 2009

cvrNearestNeighborInterpolation.h

Go to the documentation of this file.
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  * \file   cvrNearestNeighborInterpolation.h
00043  *         Contains the class cvr::nearestNeighborInterpolation.
00044  * \author Pablo Alvarado
00045  * \date   12.06.2001
00046  *
00047  * revisions ..: $Id: cvrNearestNeighborInterpolation.h,v 1.5 2005/05/06 15:43:35 arndh Exp $
00048  */
00049 
00050 
00051 #ifndef _CVR_NEAREST_NEIGHBOR_INTERPOLATION_H_
00052 #define _CVR_NEAREST_NEIGHBOR_INTERPOLATION_H_
00053 
00054 #include "cvrImage.h"
00055 #include "cvrVector.h"
00056 #include "cvrFixedGridInterpolation.h"
00057 #include "cvrRound.h"
00058 
00059 namespace cvr {
00060   /**
00061    * This functor use nearestNeighbor interpolation to approximate values
00062    * between the pixels or elements of vectors and matrices.
00063    *
00064    * The type T of the template is the type of the elements of the vector
00065    * or matrix used.
00066    */
00067   template <class T>
00068   class nearestNeighborInterpolation : public fixedGridInterpolation<T> {
00069   public:
00070     typedef typename fixedGridInterpolation<T>::parameters parameters;
00071 
00072     /**
00073      * default constructor
00074      */
00075     nearestNeighborInterpolation();
00076 
00077     /**
00078      * Construct an interpolator with the given boundary type.
00079      */
00080     nearestNeighborInterpolation(const eBoundaryType boundaryType);
00081 
00082     /**
00083      * copy constructor
00084      * @param other the object to be copied
00085      */
00086     nearestNeighborInterpolation(const nearestNeighborInterpolation<T>& other);
00087 
00088     /**
00089      * destructor
00090      */
00091     virtual ~nearestNeighborInterpolation();
00092 
00093 
00094     /**
00095      * This method returns which pixel range around the interpolated postition
00096      * is considered by the interpolation functor.
00097      *
00098      * This is very useful for other functors to decide whether they should
00099      * call the interpolate() methods or the faster interpolateUnchk() methods.
00100      *
00101      * If the returned value is \f$a\f$ and the interpolated position is
00102      * \f$(x,y)\f$ all pixels with coordinates in
00103      * \f$ [x-a .. x+a] \times [y-a .. y+a] \f$
00104      * may be considered by the interpolation functor.
00105      */
00106     int getRangeOfInfluence() const;
00107 
00108     /**
00109      * returns the name of this type ("nearestNeighborInterpolation")
00110      */
00111     virtual const std::string& name() const;
00112 
00113     /**
00114      * Returns the interpolated value of the vector at the real valued
00115      * position x.
00116      * @param src vector<T> with the source data.
00117      * @param x the real valued position to be interpolated.
00118      * @return the interpolated value of the vector.
00119      */
00120     T apply(const vector<T>& src,const float& x) const;
00121 
00122     /**
00123      * Returns the interpolated value of the vector specified with
00124      * use() at the real valued position x.
00125      * @param x the real valued position to be interpolated.
00126      * @return the interpolated value of the vector.  */
00127     T apply(const float& x) const;
00128 
00129     /**
00130      * Returns the interpolated value of the matrix at the real valued
00131      * position (row,col).
00132      *
00133      * @param src matrix<T> with the source data.
00134      * @param row which row
00135      * @param col which column
00136      * @return the interpolated value of the matrix.
00137      */
00138     T apply(const matrix<T>& src,
00139             const float& row,
00140             const float& col) const;
00141 
00142     /**
00143      * Returns the interpolated value of the matrix at the real valued
00144      * position p.
00145      *
00146      * @param src matrix<T> with the source data.
00147      * @param p the real valued position to be interpolated.
00148      * @return the interpolated value of the matrix.
00149      */
00150     T apply(const matrix<T>& src,const point<float>& p) const;
00151 
00152     /**
00153      * Returns the interpolated value of the matrix specified with
00154      * use() at the real valued position (row,col).
00155      *
00156      * @param row which row
00157      * @param col which column
00158      * @return the interpolated value of the matrix.  */
00159     T apply(const float& row, const float& col) const;
00160 
00161     /**
00162      * Returns the interpolated value of the matrix specified with
00163      * use() at the real valued position p.
00164      *
00165      * @param p the real valued position to be interpolated.
00166      * @return the interpolated value of the matrix.
00167      */
00168     T apply(const point<float>& p) const;
00169 
00170     /**
00171      * Returns the interpolated value of the matrix at the real valued
00172      * position (row,col).  This method is not virtual and can be used
00173      * if this interpolation type is used as template parameter in time
00174      * critical situations
00175      *
00176      * @param src matrix<T> with the source data.
00177      * @param row which row
00178      * @param col which column
00179      * @return the interpolated value of the matrix.
00180      */
00181     inline T interpolate(const matrix<T>& src,
00182                          const float row,
00183                          const float col) const;
00184 
00185     /**
00186      * Returns the interpolated value of the matrix at the real valued
00187      * position (row,col).
00188      *
00189      * This method does not check if the given coordinates and the rest of
00190      * used points in the src matrix lie within the valid range.  This is
00191      * left to you.
00192      *
00193      * This method is not virtual and can be used in time critical situations,
00194      * where you prefer to take the boundary control by yourself.
00195      *
00196      * @param src matrix<T> with the source data.
00197      * @param row which row
00198      * @param col which column
00199      * @return the interpolated value of the matrix.
00200      */
00201     inline T interpolateUnchk(const matrix<T>& src,
00202                               const float row,
00203                               const float col) const;
00204 
00205     /**
00206      * copy data of "other" functor.
00207      * @param other the functor to be copied
00208      * @return a reference to this functor object
00209      */
00210     nearestNeighborInterpolation& copy(const nearestNeighborInterpolation& other);
00211 
00212     /**
00213      * returns a pointer to a clone of this functor.
00214      */
00215     virtual nearestNeighborInterpolation<T>* clone() const;
00216 
00217     /**
00218      * returns a pointer to a clone of this functor.
00219      */
00220     virtual nearestNeighborInterpolation<T>* newInstance() const;
00221 
00222     /**
00223      * returns used parameters
00224      */
00225     const parameters& getParameters() const;
00226   };
00227 
00228 
00229 }
00230 
00231 #include "cvrNearestNeighborInterpolation_inline.h"
00232 
00233 #endif
00234 

Generated on Sun Sep 20 22:08:00 2009 for CVR-Lib by Doxygen 1.5.8