1 | // ----------------------------------------------------------------------- |
---|
2 | // GaussSmooth.hh: Definition of GaussSmooth class, used to smooth a |
---|
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 | // ----------------------------------------------------------------------- |
---|
29 | #ifndef GAUSSSMOOTH_H |
---|
30 | #define GAUSSSMOOTH_H |
---|
31 | |
---|
32 | /** |
---|
33 | * Define a Gaussian to smooth a 2D array. |
---|
34 | * |
---|
35 | * A simple class to define a Gaussian kernel that can be used to |
---|
36 | * smooth a two-dimensional array. |
---|
37 | */ |
---|
38 | |
---|
39 | class GaussSmooth |
---|
40 | { |
---|
41 | public: |
---|
42 | GaussSmooth(); ///< Basic constructor: no kernel defined. |
---|
43 | virtual ~GaussSmooth(); ///< Destructor |
---|
44 | GaussSmooth(const GaussSmooth& g); |
---|
45 | GaussSmooth& operator=(const GaussSmooth& g); |
---|
46 | |
---|
47 | |
---|
48 | /** Specific constructor that sets up kernel.*/ |
---|
49 | GaussSmooth(float maj, float min, float pa); |
---|
50 | /** Specific constructor that sets up kernel: assuming circular gaussian.*/ |
---|
51 | GaussSmooth(float maj); |
---|
52 | |
---|
53 | /** Define the size and the array of coefficients. */ |
---|
54 | void define(float maj, float min, float pa); |
---|
55 | |
---|
56 | /** Smooth an array with the Gaussian kernel*/ |
---|
57 | float *smooth(float *input, int xdim, int ydim); |
---|
58 | /** Smooth an array with the Gaussian kernel, using a mask to define |
---|
59 | blank pixels*/ |
---|
60 | float *smooth(float *input, int xdim, int ydim, bool *mask); |
---|
61 | |
---|
62 | void setKernMaj(float f){kernMaj=f;}; |
---|
63 | void setKernMin(float f){kernMin=f;}; |
---|
64 | void setKernPA(float f){kernPA=f;}; |
---|
65 | |
---|
66 | int getKernWidth(){return kernWidth;}; |
---|
67 | float getStddevScale(){return stddevScale;}; |
---|
68 | |
---|
69 | private: |
---|
70 | float kernMaj; ///< The FWHM of the major axis of the |
---|
71 | /// elliptical Gaussian. |
---|
72 | float kernMin; ///< The FWHM of the minor axis of the |
---|
73 | /// elliptical Gaussian. |
---|
74 | float kernPA; ///< The position angle of the elliptical |
---|
75 | /// Gaussian. |
---|
76 | int kernWidth; ///< The width of the kernel (in pixels). |
---|
77 | float stddevScale; ///< The factor by which the rms of the input |
---|
78 | /// array gets scaled by (assuming iid |
---|
79 | /// normally) |
---|
80 | float *kernel; ///< The coefficients of the smoothing kernel |
---|
81 | bool allocated; ///< Have the coefficients been allocated in memory? |
---|
82 | |
---|
83 | }; |
---|
84 | |
---|
85 | #endif // HANNING_H |
---|