1 /* 2 * * Copyright (C) 2006-2011 Anders Brander <anders@brander.dk>, 3 * * Anders Kvist <akv@lnxbx.dk> and Klaus Post <klauspost@gmail.com> 4 * 5 * This program is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU General Public License 7 * as published by the Free Software Foundation; either version 2 8 * of the License, or (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 */ 19 20 #ifndef complexfilter_h__ 21 #define complexfilter_h__ 22 #include "complexblock.h" 23 #include "floatimageplane.h" 24 25 namespace RawStudio { 26 namespace FFTFilter { 27 28 class FFTWindow; 29 30 class ComplexFilter 31 { 32 public: 33 ComplexFilter(int block_width, int block_height); 34 ComplexFilter(const ComplexFilter& p); 35 virtual ~ComplexFilter(void); 36 void process(ComplexBlock* block); 37 virtual void setSharpen( float sharpen, float sigmaSharpenMin, float sigmaSharpenMax, float scutoff ); 38 virtual gboolean skipBlock(); 39 protected: 40 virtual void processNoSharpen(ComplexBlock* block) = 0; 41 virtual void processSharpen(ComplexBlock* block) = 0; 42 const int bw; 43 const int bh; 44 const float norm; // Normalization factor 45 float lowlimit; 46 float sharpen; 47 float sigmaSquaredSharpenMin; 48 float sigmaSquaredSharpenMax; 49 FloatImagePlane *sharpenWindow; 50 }; 51 52 class DeGridComplexFilter : public ComplexFilter 53 { 54 public: 55 DeGridComplexFilter(int block_width, int block_height, float degrid, FFTWindow *window, fftwf_plan plan_forward); 56 virtual ~DeGridComplexFilter(void); 57 protected: 58 virtual void processSharpenOnly(ComplexBlock* block); 59 #if defined (__i386__) || defined (__x86_64__) 60 void processSharpenOnlySSE(ComplexBlock* block); 61 void processSharpenOnlySSE3(ComplexBlock* block); 62 #endif 63 const float degrid; 64 FFTWindow *window; 65 ComplexBlock* grid; 66 }; 67 68 class ComplexWienerFilter : public ComplexFilter 69 { 70 public: 71 ComplexWienerFilter(int block_width, int block_height, float beta, float sigma); 72 virtual ~ComplexWienerFilter(void); 73 virtual gboolean skipBlock(); 74 protected: 75 virtual void processNoSharpen(ComplexBlock* block); 76 virtual void processSharpen(ComplexBlock* block); 77 float sigmaSquaredNoiseNormed; 78 }; 79 80 class ComplexWienerFilterDeGrid : public DeGridComplexFilter 81 { 82 public: 83 ComplexWienerFilterDeGrid(int block_width, int block_height, float beta, float sigma, float degrid, fftwf_plan plan, FFTWindow *window); 84 virtual ~ComplexWienerFilterDeGrid(void); 85 virtual gboolean skipBlock(); 86 protected: 87 virtual void processNoSharpen(ComplexBlock* block); 88 virtual void processSharpen(ComplexBlock* block); 89 #if defined (__i386__) || defined (__x86_64__) 90 virtual void processSharpen_SSE3(ComplexBlock* block); 91 virtual void processSharpen_SSE(ComplexBlock* block); 92 virtual void processNoSharpen_SSE(ComplexBlock* block); 93 virtual void processNoSharpen_SSE3(ComplexBlock* block); 94 #endif 95 float sigmaSquaredNoiseNormed; 96 FFTWindow *window; 97 }; 98 99 class ComplexPatternFilter : public ComplexFilter 100 { 101 public: 102 ComplexPatternFilter(int block_width, int block_height, float beta, FloatImagePlane* pattern, float pattern_strength ); 103 virtual ~ComplexPatternFilter(void); 104 virtual gboolean skipBlock(); 105 protected: 106 virtual void processNoSharpen(ComplexBlock* block); 107 virtual void processSharpen(ComplexBlock* block); 108 FloatImagePlane* pattern; 109 const float pfactor; 110 }; 111 112 113 class ComplexFilterPatternDeGrid : public DeGridComplexFilter 114 { 115 public: 116 ComplexFilterPatternDeGrid(int block_width, int block_height, float beta, float sigma, float degrid, fftwf_plan plan, FFTWindow *window, FloatImagePlane *pattern); 117 virtual ~ComplexFilterPatternDeGrid(void); 118 virtual gboolean skipBlock(); 119 protected: 120 virtual void processNoSharpen(ComplexBlock* block); 121 virtual void processSharpen(ComplexBlock* block); 122 float sigmaSquaredNoiseNormed; 123 FloatImagePlane *pattern; 124 }; 125 126 }} // namespace RawStudio::FFTFilter 127 128 #endif // complexfilter_h__ 129