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

ltiSusanCorners.h

00001 /*
00002  * Copyright (C) 1998, 1999, 2000, 2001
00003  * Lehrstuhl fuer Technische Informatik, RWTH-Aachen, Germany
00004  *
00005  * This file can be used with the LTI-Computer Vision Library (LTI-Lib)
00006  * (please note this file is NOT part of the LTI-Lib)
00007  * This code is based on the original C code by S. Smith, which contains
00008  * following header:
00009  *
00010  **********************************************************************
00011  *
00012  * SUSAN Version 2l by Stephen Smith
00013  *
00014  * Oxford Centre for Functional Magnetic Resonance Imaging of the
00015  * Brain, Department of Clinical Neurology, Oxford University, Oxford,
00016  * UK (Previously in Computer Vision and Image Processing Group - now
00017  * Computer Vision and Electro Optics Group - DERA Chertsey, UK)
00018  *
00019  * Email:    steve@fmrib.ox.ac.uk
00020  * WWW:      http://www.fmrib.ox.ac.uk/~steve
00021  *
00022  * (C) Crown Copyright (1995-1999), Defence Evaluation and Research Agency,
00023  * Farnborough, Hampshire, GU14 6TD, UK
00024  * DERA WWW site:
00025  * http://www.dera.gov.uk/
00026  * DERA Computer Vision and Electro Optics Group WWW site:
00027  * http://www.dera.gov.uk/imageprocessing/dera/group_home.html
00028  * DERA Computer Vision and Electro Optics Group point of contact:
00029  * Dr. John Savage, jtsavage@dera.gov.uk, +44 1344 633203
00030  *
00031  * A UK patent has been granted: "Method for digitally processing
00032  * images to determine the position of edges and/or corners therein for
00033  * guidance of unmanned vehicle", UK Patent 2272285. Proprietor:
00034  * Secretary of State for Defence, UK. 15 January 1997
00035  *
00036  * This code is issued for research purposes only and remains the
00037  * property of the UK Secretary of State for Defence. This code must
00038  * not be passed on without this header information being kept
00039  * intact. This code must not be sold.
00040  **********************************************************************
00041  *
00042  *
00043  *
00044  * The LTI-Lib is free software; you can redistribute it and/or
00045  * modify it under the terms of the GNU Lesser General Public License (LGPL)
00046  * as published by the Free Software Foundation; either version 2.1 of
00047  * the License, or (at your option) any later version.
00048  *
00049  * The LTI-Lib is distributed in the hope that it will be
00050  * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
00051  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00052  * GNU Lesser General Public License for more details.
00053  *
00054  * You should have received a copy of the GNU Lesser General Public
00055  * License along with the LTI-Lib; see the file LICENSE.  If
00056  * not, write to the Free Software Foundation, Inc., 59 Temple Place -
00057  * Suite 330, Boston, MA 02111-1307, USA.
00058  *
00059  */
00060 
00061 /*----------------------------------------------------------------
00062  * project ....: LTI Digital Image/Signal Processing Library
00063  * file .......: ltiSusanCorners.h
00064  * authors ....: Frederik Lange
00065  * organization: LTI, RWTH Aachen
00066  * creation ...: 27.3.2001
00067  * revisions ..: $Id: ltiSusanCorners.h,v 1.19 2005/06/16 12:35:44 doerfler Exp $
00068  */
00069 
00070 #include "ltiConfig.h"
00071 
00072 #ifndef HAVE_SUSAN
00073 #ifdef _LTI_MSC_VER
00074 #pragma message("Configuration Error:")
00075 #pragma message("Change in src/basics/ltiWinConfig.h HAVE_SUSAN to 1")
00076 #else
00077 #warning "Configuration Error:"
00078 #warning "Change in src/basics/config.h HAVE_SUSAN to 1"
00079 #endif
00080 #endif
00081 
00082 #ifndef _LTI_SUSAN_CORNERS_H_
00083 #define _LTI_SUSAN_CORNERS_H_
00084 
00085 #include "ltiImage.h"
00086 #include "ltiCornerDetector.h"
00087 #include "ltiPointList.h"
00088 #include "ltiMath.h"
00089 
00090 #include <cstdlib>
00091 #include <cstdio>
00092 #include <cstring>
00093 
00094 namespace lti {
00095   /**
00096    *  Corner finder with the Susan low level image processing algorithm
00097    */
00098   class susanCorners : public cornerDetector {
00099   public:
00100     /**
00101      * the parameters for the class susanCorners
00102      */
00103     class parameters : public cornerDetector::parameters {
00104     public:
00105       /**
00106        * default constructor
00107        */
00108       parameters();
00109 
00110       /**
00111        * copy constructor
00112        * @param other the parameters object to be copied
00113        */
00114       parameters(const parameters& other);
00115 
00116       /**
00117        * destructor
00118        */
00119       ~parameters();
00120 
00121       /**
00122        * returns name of this type
00123        */
00124       const char* getTypeName() const;
00125 
00126       /**
00127        * copy the contents of a parameters object
00128        * @param other the parameters object to be copied
00129        * @return a reference to this parameters object
00130        */
00131       parameters& copy(const parameters& other);
00132 
00133       /**
00134        * copy the contents of a parameters object
00135        * @param other the parameters object to be copied
00136        * @return a reference to this parameters object
00137        */
00138       parameters& operator=(const parameters& other);
00139 
00140 
00141       /**
00142        * returns a pointer to a clone of the parameters
00143        */
00144       virtual functor::parameters* clone() const;
00145 
00146       /**
00147        * write the parameters in the given ioHandler
00148        * @param handler the ioHandler to be used
00149        * @param complete if true (the default) the enclosing begin/end will
00150        *        be also written, otherwise only the data block will be written.
00151        * @return true if write was successful
00152        */
00153       virtual bool write(ioHandler& handler,const bool complete=true) const;
00154 
00155       /**
00156        * write the parameters in the given ioHandler
00157        * @param handler the ioHandler to be used
00158        * @param complete if true (the default) the enclosing begin/end will
00159        *        be also written, otherwise only the data block will be written.
00160        * @return true if write was successful
00161        */
00162       virtual bool read(ioHandler& handler,const bool complete=true);
00163 
00164 #     ifdef _LTI_MSC_6
00165       /**
00166        * this function is required by MSVC only, as a workaround for a
00167        * very awful bug, which exists since MSVC V.4.0, and still by
00168        * V.6.0 with all bugfixes (so called "service packs") remains
00169        * there...  This method is also public due to another bug, so please
00170        * NEVER EVER call this method directly: use read() instead
00171        */
00172       bool readMS(ioHandler& handler,const bool complete=true);
00173 
00174       /**
00175        * this function is required by MSVC only, as a workaround for a
00176        * very awful bug, which exists since MSVC V.4.0, and still by
00177        * V.6.0 with all bugfixes (so called "service packs") remains
00178        * there...  This method is also public due to another bug, so please
00179        * NEVER EVER call this method directly: use write() instead
00180        */
00181       bool writeMS(ioHandler& handler,const bool complete=true) const;
00182 #     endif
00183 
00184       // ------------------------------------------------
00185       // the parameters
00186       // ------------------------------------------------
00187 
00188       //TODO: comment the parameters of your functor
00189       // If you add more parameters manually, do not forget to do following:
00190       // 1. indicate in the default constructor the default values
00191       // 2. make sure that the copy member also copy your new parameters
00192       // 3. make sure that the read and write members also read and
00193       //    write your parameters
00194 
00195       /**
00196        * size of the circular kernel, unused at the moment, default is 5
00197        */
00198       int kernelSize;
00199 
00200       /**
00201        * threshold for similarity criteria, for difference in
00202        * brightness (default 20)
00203        */
00204       int threshold;
00205 
00206       /**
00207        * threshold for the form of the corner (default 290)
00208        */
00209       int geometricThreshold;
00210     };
00211 
00212     /**
00213      * default constructor
00214      */
00215     susanCorners();
00216 
00217     /**
00218      * constructor with parameters
00219      */
00220     susanCorners(const parameters& par);
00221 
00222     /**
00223      * copy constructor
00224      * @param other the object to be copied
00225      */
00226     susanCorners(const susanCorners& other);
00227 
00228     /**
00229      * destructor
00230      */
00231     virtual ~susanCorners();
00232 
00233     /**
00234      * returns the name of this type ("susanCorners")
00235      */
00236     virtual const char* getTypeName() const;
00237 
00238     /**
00239      * operates on the given %parameter.
00240      * @param srcdest channel8 with the source data.  The result
00241      *                 will be left here too.  An image with the corners only
00242      *                 will be returned.  If you want to overlay the corners
00243      *                 with the input image use apply(chnl,chnl)
00244      * @return true if ok, false otherwise.
00245      */
00246     virtual bool apply(channel8& srcdest) const;
00247 
00248     /**
00249      * operates on the given %parameter.
00250      * @param srcdest channel with the source data.  The result
00251      *                 will be left here too.  An image with the corners only
00252      *                 will be returned.  If you want to overlay the corners
00253      *                 with the input image use apply(chnl,chnl)
00254      * @return true if ok, false otherwise.
00255      */
00256     virtual bool apply(channel& srcdest) const;
00257 
00258     /**
00259      * operates on a copy of the given %parameters.
00260      * @param src channel8 with the source data.
00261      * @param dest channel where the result will be left.  If this
00262      *             channel is the same input channel or its size is the same of
00263      *             the src channel, the corners will be "overlayed" in the
00264      *             channel without cleaning it.  If this channel has another
00265      *             size than the dest, it will be resized and only the corners
00266      *             will be seen. The value of a corner will be always 1.0f.
00267      * @return true if ok, false otherwise.
00268      */
00269     virtual bool apply(const channel8& src,channel8& dest) const;
00270 
00271     /**
00272      * operates on a copy of the given %parameters.
00273      * @param src channel with the source data.
00274      * @param dest channel where the result will be left.  If this
00275      *             channel is the same input channel or its size is the same of
00276      *             the src channel, the corners will be "overlayed" in the
00277      *             channel without cleaning it.  If this channel has another
00278      *             size than the dest, it will be resized and only the corners
00279      *             will be seen. The value of a corner will be always 1.0f.
00280      * @return true if ok, false otherwise.
00281      */
00282     virtual bool apply(const channel& src,channel& dest) const;
00283 
00284     /**
00285      * result is given back as a list of points
00286      * @return true if ok, false otherwise.
00287      */
00288     virtual bool apply(const channel& src, pointList& dest) const;
00289 
00290     /**
00291      * result is given back as a list of points
00292      * @return true if ok, false otherwise.
00293      */
00294     virtual bool apply(const channel8& src, pointList& dest) const;
00295 
00296     /**
00297      * copy data of "other" functor.
00298      * @param other the functor to be copied
00299      * @return a reference to this functor object
00300      */
00301     susanCorners& copy(const susanCorners& other);
00302 
00303     /**
00304      * copy data of "other" functor.
00305      * @param other the functor to be copied
00306      * @return a reference to this functor object
00307      */
00308     susanCorners& operator=(const susanCorners& other);
00309 
00310     /**
00311      * returns a pointer to a clone of this functor.
00312      */
00313     virtual functor* clone() const;
00314 
00315     /**
00316      * returns used parameters
00317      */
00318     const parameters& getParameters() const;
00319 
00320     /**
00321      * set the parameters
00322      * This member makes a copy of <em>theParam</em>: the functor
00323      * will keep its own copy of the parameters!
00324      * @return true if successful, false otherwise
00325      */
00326     virtual bool updateParameters();
00327 
00328   private:
00329 
00330     /**
00331      * brightness LUT
00332      */
00333     ubyte* brightnessLUT;
00334 
00335     /**
00336      * sets up an LUT for faster processing
00337      */
00338     void setupBrightnessLUT(ubyte*& bp,const int& thresh,const int& form);
00339 
00340     /**
00341      * delete the LUT
00342      */
00343     void deleteBrightnessLUT(ubyte*& bp);
00344 
00345     /**
00346      * detects the corners in the image
00347      */
00348     void detect(const ubyte* in,
00349                 const ubyte* bp,
00350                 const int& max_no,
00351                 const int& geometricThreshold,
00352                 const int& x_size,
00353                 const int& y_size,
00354                 pointList& corners) const;
00355 
00356     /**
00357      * internal round returns integers and not floats
00358      */
00359     inline int round(const float x) const;
00360   };
00361 }
00362 
00363 #endif
00364 

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