Filter Library Camera Interface Physics

ScanFilterNCCFFT.h

00001 /*
00002  * ScanFilterNCCFFT.h - fast normalized cross-correlation filter.
00003  *
00004  * This file is part of the Camera Filter Library.
00005  * Computer Aided Measurement Environment for Realtime Atomic imaging (Camera)
00006  *
00007  * Copyright (C) 2004-2005, Leiden Probe Microscopy.
00008  * Copyright (C) 2004-2005, Universiteit Leiden.
00009  *
00010  * Authors: Martin J. Moene
00011  *
00012  * $Id: ScanFilterNCCFFT.h 464 2007-01-07 14:01:00Z moene $
00013  */
00014 
00015 #ifndef CFL_ScanFilterNCCFFT_h
00016 #define CFL_ScanFilterNCCFFT_h
00017 
00018 #if _MSC_VER > 1000
00019 #pragma once
00020 #endif // _MSC_VER > 1000
00021 
00022 #include <cfl/ScanFilter.h>             // for base class
00023 #include <cfl/ScanBaseBuffer.h>         // for ValueType
00024 
00025 /**
00026  * \addtogroup  cfl_fastnormalizedcrosscorrelation Fast Normalized Cross-Correlation Filter
00027  * \brief fast normalized cross-correlation filter.
00028  *
00029 
00030 <h3>Purpose</h3>
00031 
00032 <h3>Description</h3>
00033 
00034 <h3>Algorithm</h3>
00035 
00036 
00037 \f[
00038    \textrm{B} = \textrm{A}
00039 \f]
00040 
00041 <h3>Examples</h3>
00042 Try to find some interesting pictures for most filters.
00043 
00044 <h3>Contact</h3>
00045 Dipl.phys. M.J. Rost<br>
00046 Huygens Laboratorium<br>
00047 Universiteit Leiden<br>
00048 Niels Bohrweg 2<br>
00049 2333 CA Leiden, The Netherlands<br>
00050 <br>
00051 Tel: +31 71 5275600<br>
00052 Fax: +31 71 5275404<br>
00053 <br>
00054 E-mail: rost@physics.LeidenUniv.nl<br>
00055 Web: http://www.geocities.com/marcel_rost/<br>
00056 
00057  *
00058  * @{
00059  */
00060 
00061 DECLARE_CLASS( CScanFilterNCCFFT );         // create various types
00062 
00063 /**
00064  * \brief mean filter.
00065  *
00066  */
00067 class CScanFilterNCCFFT : public CScanFilter
00068 {
00069    /**
00070     * its dialog class.
00071     */
00072    friend class CFilterDlg_NCCFFT;
00073 
00074 public:
00075    /**
00076     * the value type.
00077     */
00078    typedef CScanBaseBuffer::ValueType ValueType;
00079 
00080    /**
00081     * the input pixel type.
00082     */
00083    typedef ValueType InputPixelType;
00084 
00085    /**
00086     * the output pixel type.
00087     */
00088    typedef ValueType OutputPixelType;
00089 
00090    /**
00091     * normalization type.
00092     */
00093    enum SubtractionType
00094    {
00095       bgNone,                   ///< none
00096       bgMean,                   ///< normal
00097       bgBackground,             ///< linear regression, planar background
00098       bgDimension_,             ///< the number of entries
00099    };
00100 
00101    /**
00102     * normalization type.
00103     */
00104    enum NormalizationType
00105    {
00106       nmNone,                   ///< none
00107       nmNormal,                 ///< normal
00108       nmPhase,                  ///< phase
00109       nmDimension_,             ///< the number of entries
00110    };
00111 
00112    /**
00113     * normalization sub-type.
00114     */
00115    enum NormalizationSubType
00116    {
00117       nsZeroMean,               ///< zero-mean
00118       nsEnergy,                 ///< energy
00119       nsPlanar,                 ///< planer bg subtr for image-under-template
00120       nsDimension_,             ///< the number of entries
00121    };
00122 
00123    /**
00124     * the scale type.
00125     */
00126    typedef double ScaleType;
00127 
00128    ///
00129    /// \name Construction
00130    /// @{
00131 
00132    /**
00133     * default constructor: setup filter to run without dialog;
00134     * see also CScanFilterNull::CScanFilterNull().
00135     */
00136    CScanFilterNCCFFT();
00137 
00138    /**
00139     * destructor.
00140     */
00141    virtual ~CScanFilterNCCFFT();
00142 
00143    /// @}
00144    /// \name Camera--Filter Interface
00145    /// @{
00146 
00147 //    /**
00148 //     * no partial data.
00149 //     */
00150 //   virtual BOOL CanDoPartialData() const;
00151 //
00152 //    /**
00153 //     * has dialog (default true).
00154 //     */
00155 //    virtual BOOL CanDoDialogEntry() const;
00156 
00157    /**
00158     * \brief configure filter with settings as provided by the application on the
00159     * filterlist window (e.g. via registry); see also CScanFilterNull::ReadFilterSettings().
00160     */
00161    virtual void ReadFilterSettings( );
00162 
00163    /**
00164     * \brief save filter settings e.g. for use with the filterlist window (e.g. via registry);
00165     * see also ReadFilterSettings().
00166     */
00167    virtual void WriteFilterSettings( ) const;
00168 
00169    /**
00170     * provide current filter parameter(s) for filter-scripting capture
00171     * in the main application;
00172     * see also CScanFilterNull::GetParameters().
00173     */
00174    virtual LPCTSTR GetParameters() const;
00175 
00176    /**
00177     * set parameters for filter-script execution of filter;
00178     * see also CScanFilterNull::SetParameters().
00179     */
00180    virtual BOOL SetParameters( LPCTSTR lpParameters );
00181 
00182 //    /**
00183 //     * the supported dragmethod(s).
00184 //     */
00185 //    virtual DragSupportType SupportDragInput() const;
00186 //
00187 //    /**
00188 //     * apply the filter to the selected area.
00189 //     */
00190 //    virtual void SetDragInput( BOOL bL2R, CRect rcIn );
00191 //
00192 //    /**
00193 //     * start filter dialog to edit parameters; no filter operations;
00194 //     * see also CScanFilterNull::EditModeless().
00195 //     */
00196 //    virtual BOOL EditModeless( CWnd *pParentWnd );
00197 
00198    /**
00199     * create filter dialog and pre Apply() filter to view result;
00200     * see also CScanFilterNull::RunModeless().
00201     */
00202    virtual BOOL RunModeless( CWnd *pParentWnd, CDocument *pDoc );
00203 
00204    /**
00205     * check parameters, take care of a properly sized output buffer,
00206     * set its name and copy filter parameters and process;
00207     * see also CScanFilterNull::Apply().
00208     */
00209    virtual BOOL Apply();
00210 
00211    /**
00212     * the number of input buffers is 2.
00213     */
00214    virtual DWORD GetNrOfInBuffers() const;
00215 
00216    /**
00217     * the requested input buffer.
00218     */
00219    virtual CScanBaseBuffer* GetInputBuffer( UINT nNr );
00220 
00221    /**
00222     * set the given input buffer.
00223     */
00224    virtual void SetInputBuffer( UINT nNr, CScanBaseBuffer *lpsbIn );
00225 
00226    /// @}
00227    /// \name Predicates
00228    /// @{
00229 
00230    /**
00231     * true if the FFT size has been relaxed (allow overlap).
00232     */
00233    bool DoRelaxFFTSize() const
00234    {
00235       return m_relax_fft_size;
00236    }
00237 
00238    /// @}
00239    /// \name Accessors
00240    /// @{
00241 
00242    /**
00243     * the normalization type.
00244     */
00245    SubtractionType GetSubtractionType() const
00246    {
00247       return m_subtract;
00248    }
00249 
00250    /**
00251     * the normalization type.
00252     */
00253    NormalizationType GetNormalizationType() const
00254    {
00255       return m_norm;
00256    }
00257 
00258    /**
00259     * the normalization sub-type.
00260     */
00261    NormalizationSubType GetNormalizationSubType() const
00262    {
00263       return m_normsub;
00264    }
00265 
00266    /**
00267     * the scale factor.
00268     */
00269    ScaleType GetScale( NormalizationType type ) const
00270    {
00271 //       return m_scale;
00272       return m_scale[ type ];
00273    }
00274 
00275    /// @}
00276    /// \name Mutators
00277    /// @{
00278 
00279    /**
00280     * set the subtraction type.
00281     */
00282    void SetSubtractionType( SubtractionType subtract )
00283    {
00284       m_subtract = subtract;
00285    }
00286 
00287    /**
00288     * set the normalization type.
00289     */
00290    void SetNormalizationType( NormalizationType norm )
00291    {
00292       m_norm = norm;
00293    }
00294 
00295    /**
00296     * set the normalization sub-type.
00297     */
00298    void SetNormalizationSubType( NormalizationSubType normsub )
00299    {
00300       m_normsub = normsub;
00301    }
00302 
00303    /**
00304     * relax the FFT image size and allow overlap in the transformation.
00305     */
00306    void SetRelaxFFTSize( bool relax_fft_size )
00307    {
00308       m_relax_fft_size = relax_fft_size;
00309    }
00310 
00311    /**
00312     * set the scale factor.
00313     */
00314    void SetScale( NormalizationType type, ScaleType scale )
00315    {
00316       m_scale[ type ] = scale;
00317    }
00318 
00319     /// @}
00320 
00321 protected:
00322    /**
00323     * store or retrieve the object's settings; see also CScanFilterNull::Serialize().
00324     */
00325    virtual void Serialize(CArchive& ar);
00326    DECLARE_SERIAL(CScanFilterNCCFFT)
00327 
00328 public:
00329    /**
00330     * the filter name.
00331     */
00332    static LPCTSTR m_lpcsFilterName;
00333 
00334    /**
00335     * the class short filtername.
00336     */
00337    static LPCTSTR m_lpcsShortFilterName;
00338 
00339    /**
00340     * the default scale factor.
00341     */
00342    static const ScaleType m_defScale;
00343 
00344 protected:
00345    /**
00346     * the second input buffer.
00347     */
00348    CScanBaseBuffer *m_lpsbIn2;
00349 
00350    /**
00351     * the normalization type.
00352     */
00353    SubtractionType m_subtract;
00354 
00355    /**
00356     * the normalization type.
00357     */
00358    NormalizationType m_norm;
00359 
00360    /**
00361     * the normalization sub-type.
00362     */
00363    NormalizationSubType m_normsub;
00364 
00365    /**
00366     * use minimal FFT size.
00367     */
00368    bool m_relax_fft_size;
00369 
00370    /**
00371     * the scale factors (one for each normalization type).
00372     */
00373    ScaleType m_scale[ nmDimension_ ];
00374 };
00375 
00376 /// @} cfl_filtermean
00377 
00378 #endif // CFL_ScanFilterNCCFFT_h
00379 
00380 /*
00381  * end of file
00382  */
00383 

Camera Filter Library documentation © 2004-2007 by Leiden Probe Microscopy