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

ltiSusanEdges.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 .......: ltiSusanEdges.h
00064  * authors ....: Stefan Syberichs
00065  * organization: LTI, RWTH Aachen
00066  * creation ...: 30.03.2000
00067  * revisions ..: $Id: ltiSusanEdges.h,v 1.22 2005/07/22 08:19:05 libuda 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_SUSANEDGES_H_
00083 #define _LTI_SUSANEDGES_H_
00084 
00085 #include "ltiEdgeDetector.h"
00086 
00087 namespace lti {
00088 
00089   /**
00090    * The Susan Edge Detector.  susanEdges is a modifier-frontend for
00091    * the susan-class for edge detection.  The susan-principle is a
00092    * fast method for finding <b> binary edges </b> in images and
00093    * channels. The result is a black-and-white map (image or channel
00094    * format), where white pixels (255) mark an edge and black pixels
00095    * (0) are background area.  in General, the sensitivity es
00096    * controlled by the parameter <code> threshold</code>, which is an
00097    * unsigned integer between 1 and 255, where small thresholds
00098    * produce many edges and high thresholds detect only rough
00099    * edges. The default is 20.
00100    *
00101    * Example:
00102    * \code
00103    *
00104    *  lti::image theimage;
00105    *  lti::channel8 RED, GREEN, BLUE;
00106    *
00107    *  // to store the results:
00108    *  lti::image edgeImage;
00109    *  lti::chanel8 edgeChannel;
00110    *
00111    *  // ...
00112    *  // load image, split into channel8's
00113    *
00114    *  lti::susanEdges detect;
00115    *
00116    *  lti::susanEdges::parameters detectparams;
00117    *
00118    *  // default parameters are: RGBmerge, threshold = 20...
00119    *  detectparams.edgeMerge = lti::susanEdges::parameters::RGBseparate;
00120    *  detectparams.threshold = 15;
00121    *  detect.setParameters(detectparams);
00122    *
00123    *  // choose one of these:
00124    *
00125    *  detect.apply(theimage, edgeImage);    // on copy for images
00126    *  detect.apply(theimage);               // on place for image
00127    *  detect.apply(RED, edgeChannel);       // on copy for channel8's
00128    *  detect.apply(RED);                    // on place for channel8
00129    *  detect.apply(theimage, edgechannel);  // on copy for input image and
00130    *                                           output channel8
00131    *  \endcode
00132    */
00133   class susanEdges : public edgeDetector {
00134   public:
00135     /** Parameter class for susanEdges. */
00136     class parameters : public edgeDetector::parameters {
00137 
00138     public:
00139       /**
00140        * constructor
00141        */
00142       parameters();
00143 
00144       /**
00145        * copy constrcutor
00146        */
00147       parameters(const parameters& other);
00148 
00149       /**
00150        * destructor
00151        */
00152       virtual ~parameters();
00153 
00154       /**
00155        * returns the name of the parameter object
00156        */
00157       virtual const char* getTypeName() const;
00158 
00159       /**
00160        * copy member
00161        */
00162       parameters& copy(const parameters& other);
00163 
00164       /**
00165        * clone member
00166        */
00167       virtual functor::parameters* clone() const;
00168 
00169       /**
00170        * write the parameters in the given ioHandler
00171        * @param handler the ioHandler to be used
00172        * @param complete if true (the default) the enclosing begin/end will
00173        *        be also written, otherwise only the data block will be written.
00174        * @return true if write was successful
00175        */
00176       virtual bool write(ioHandler& handler,const bool complete=true) const;
00177 
00178       /**
00179        * write the parameters in the given ioHandler
00180        * @param handler the ioHandler to be used
00181        * @param complete if true (the default) the enclosing begin/end will
00182        *        be also written, otherwise only the data block will be written.
00183        * @return true if write was successful
00184        */
00185       virtual bool read(ioHandler& handler,const bool complete=true);
00186 
00187 #     ifdef _LTI_MSC_6
00188       /**
00189        * this function is required by MSVC only, as a workaround for a
00190        * very awful bug, which exists since MSVC V.4.0, and still by
00191        * V.6.0 with all bugfixes (so called "service packs") remains
00192        * there...  This method is public due to another bug, so please
00193        * NEVER EVER call this method directly: use read() instead!
00194        */
00195       bool readMS(ioHandler& handler,const bool complete=true);
00196 
00197       /**
00198        * this function is required by MSVC only, as a workaround for a
00199        * very awful bug, which exists since MSVC V.4.0, and still by
00200        * V.6.0 with all bugfixes (so called "service packs") remains
00201        * there...  This method is public due to another bug, so please
00202        * NEVER EVER call this method directly: use write() instead!
00203        */
00204       bool writeMS(ioHandler& handler,const bool complete=true) const;
00205 #     endif
00206 
00207       // ------------------------------------------------
00208       // the parameters
00209       // ------------------------------------------------
00210 
00211       /**
00212        * the brightness threshold. controls the sensitivity of edge
00213        * detection.  threshold is an integer value between 1 and 255,
00214        * where 1 finds many edges and 255 almost none.
00215        *
00216        * The default is 20.
00217        */
00218       int threshold;
00219 
00220     };
00221 
00222     /**
00223      * constructor
00224      */
00225     susanEdges();
00226 
00227     /**
00228      * constructor with parameters
00229      */
00230     susanEdges(const parameters& par);
00231 
00232 
00233     /**
00234      * copy constructor
00235      */
00236     susanEdges(const susanEdges& other);
00237 
00238     /**
00239      * destructor
00240      */
00241     virtual ~susanEdges();
00242 
00243     /**
00244      * returns the type of the object
00245      */
00246     virtual const char* getTypeName() const;
00247 
00248     /**
00249      * clone member
00250      */
00251     virtual functor* clone() const;
00252 
00253     /**
00254      *  set the susanEdges::parameters.
00255      */
00256     virtual bool updateParameters();
00257 
00258     /**
00259      * returns current parameters.
00260      */
00261     const parameters& getParameters() const;
00262 
00263     /**
00264      * OnPlace version of apply for channels (lti::channel8).
00265      *
00266      * @param srcdest channel with the source data.  The result
00267      *                will be left here too.
00268      * @return true if ok, false otherwise.
00269      */
00270     virtual bool apply(channel& srcdest) const;
00271 
00272     /**
00273      * OnPlace version of apply for lti::channel8 data
00274      * @param srcdest channel8  with the source data.
00275      *                The resulting edge will be left here too.
00276      * @return true if ok, false otherwise.
00277      * @exception susanError is thrown if the parameters are out of range.
00278      */
00279     virtual bool apply(channel8& srcdest) const;
00280 
00281     /**
00282      * Compute the edges for the red, green and blue components of the image
00283      * and leave the result in each channel of image.
00284      * @param srcdest image with the source data.  The result
00285      *                will be left here too.
00286      * @return true if apply successful or false otherwise.
00287      */
00288     virtual bool apply(image& srcdest) const;
00289 
00290     /**
00291      * operates on a copy of the given parameters (channel)
00292      * @param src channel with the source data.
00293      * @param dest channel, where the result will be left.
00294      * @return true if ok, false otherwise.
00295      */
00296     virtual bool apply(const channel& src,channel& dest) const;
00297 
00298     /**
00299      * operates on a copy of the given %parameters.
00300      * @param src channel with the source data.
00301      * @param dest channel8 where the result will be left.
00302      * @return true if apply successful or false otherwise.
00303      */
00304     virtual bool apply(const channel& src,channel8& dest) const;
00305 
00306     /**
00307      * operates on a copy of the given lti::channel8 input.
00308      *
00309      * @param src lti::channel8 with the source data.
00310      * @param dest lti::channel8, where the binary edge will be left.
00311      * @return true if ok, false otherwise.
00312      * @exception susanError is thrown if the parameters are out of range.
00313      */
00314     virtual bool apply(const channel8& src, channel8& dest) const;
00315 
00316     /**
00317      * Compute the edges for the red, green and blue components of the image
00318      * and leave the result in each channel of the destination image.
00319      *
00320      * @param src image with the source data.
00321      * @param dest image where the result will be left.
00322      * @return true if apply successful or false otherwise.
00323      */
00324     virtual bool apply(const image& src,image& dest) const;
00325 
00326     /**
00327      * Compute the edges for the red, green and blue components of the image
00328      * and leave the sum of the results in the given channel.  Note that
00329      * if you give as parameters::edgeValue or parameters::noEdgeValue values
00330      * greater than 255/3, you can have some overflow effects on the resulting
00331      * channel.
00332      *
00333      * @param src image with the source data.
00334      * @param dest channel8 where the result will be left.
00335      * @return true if apply successful or false otherwise.
00336      */
00337     virtual bool apply(const image& src, channel8& dest) const;
00338 
00339   };
00340 
00341 } // end of namespace
00342 
00343 #endif
00344 

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