[301] | 1 | // ----------------------------------------------------------------------- |
---|
[638] | 2 | // GaussSmooth1D.hh: Definition of GaussSmooth1D class, used to smooth a |
---|
[301] | 3 | // 2D image with a Gaussian kernel. |
---|
| 4 | // ----------------------------------------------------------------------- |
---|
| 5 | // Copyright (C) 2006, Matthew Whiting, ATNF |
---|
| 6 | // |
---|
| 7 | // This program is free software; you can redistribute it and/or modify it |
---|
| 8 | // under the terms of the GNU General Public License as published by the |
---|
| 9 | // Free Software Foundation; either version 2 of the License, or (at your |
---|
| 10 | // option) any later version. |
---|
| 11 | // |
---|
| 12 | // Duchamp is distributed in the hope that it will be useful, but WITHOUT |
---|
| 13 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
---|
| 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
---|
| 15 | // for more details. |
---|
| 16 | // |
---|
| 17 | // You should have received a copy of the GNU General Public License |
---|
| 18 | // along with Duchamp; if not, write to the Free Software Foundation, |
---|
| 19 | // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA |
---|
| 20 | // |
---|
| 21 | // Correspondence concerning Duchamp may be directed to: |
---|
| 22 | // Internet email: Matthew.Whiting [at] atnf.csiro.au |
---|
| 23 | // Postal address: Dr. Matthew Whiting |
---|
| 24 | // Australia Telescope National Facility, CSIRO |
---|
| 25 | // PO Box 76 |
---|
| 26 | // Epping NSW 1710 |
---|
| 27 | // AUSTRALIA |
---|
| 28 | // ----------------------------------------------------------------------- |
---|
[638] | 29 | #ifndef GAUSSSMOOTH1D_H |
---|
| 30 | #define GAUSSSMOOTH1D_H |
---|
[1393] | 31 | #include <vector> |
---|
[528] | 32 | /// @brief |
---|
| 33 | /// Define a Gaussian to smooth a 2D array. |
---|
| 34 | /// @details |
---|
| 35 | /// A simple class to define a Gaussian kernel that can be used to |
---|
| 36 | /// smooth a two-dimensional array. |
---|
[275] | 37 | |
---|
[516] | 38 | template <class Type> |
---|
[638] | 39 | class GaussSmooth1D |
---|
[275] | 40 | { |
---|
| 41 | public: |
---|
[638] | 42 | GaussSmooth1D(); ///< Basic constructor: no kernel defined. |
---|
| 43 | virtual ~GaussSmooth1D(); ///< Destructor |
---|
| 44 | GaussSmooth1D(const GaussSmooth1D& g); |
---|
| 45 | GaussSmooth1D& operator=(const GaussSmooth1D& g); |
---|
[365] | 46 | |
---|
[275] | 47 | |
---|
[528] | 48 | /// @brief Specific constructor that sets up kernel. |
---|
[638] | 49 | GaussSmooth1D(float fwhm); |
---|
[275] | 50 | |
---|
[528] | 51 | /// @brief Define the size and the array of coefficients. |
---|
[638] | 52 | void define(float fwhm); |
---|
[275] | 53 | |
---|
[528] | 54 | /// @brief Smooth an array with the Gaussian kernel |
---|
[638] | 55 | Type *smooth(Type *input, int dim, bool normalise=false, bool scaleByCoverage=false); |
---|
[528] | 56 | /// @brief Smooth an array with the Gaussian kernel, using a mask to define blank pixels |
---|
[1393] | 57 | Type *smooth(Type *input, int dim, std::vector<bool> mask, bool normalise=false, bool scaleByCoverage=false); |
---|
[275] | 58 | |
---|
[638] | 59 | void setKernFWHM(float f){kernFWHM=f;}; |
---|
[275] | 60 | |
---|
[516] | 61 | Type getKernelPt(int i){return kernel[i];}; |
---|
| 62 | Type *getKernel(){return kernel;}; |
---|
| 63 | |
---|
[275] | 64 | int getKernWidth(){return kernWidth;}; |
---|
| 65 | float getStddevScale(){return stddevScale;}; |
---|
| 66 | |
---|
| 67 | private: |
---|
[638] | 68 | float kernFWHM; ///< The FWHM of the Gaussian. |
---|
[290] | 69 | int kernWidth; ///< The width of the kernel (in pixels). |
---|
[528] | 70 | float stddevScale; ///< The factor by which the rms of the input array gets scaled by (assuming iid normally) |
---|
[516] | 71 | Type *kernel; ///< The coefficients of the smoothing kernel |
---|
[275] | 72 | bool allocated; ///< Have the coefficients been allocated in memory? |
---|
| 73 | |
---|
| 74 | }; |
---|
| 75 | |
---|
[638] | 76 | #endif // GAUSSSMOOTH1D_H |
---|