PCL
ATrousWaveletTransform.h
Go to the documentation of this file.
1 // ____ ______ __
2 // / __ \ / ____// /
3 // / /_/ // / / /
4 // / ____// /___ / /___ PixInsight Class Library
5 // /_/ \____//_____/ PCL 2.6.11
6 // ----------------------------------------------------------------------------
7 // pcl/ATrousWaveletTransform.h - Released 2024-05-07T15:27:32Z
8 // ----------------------------------------------------------------------------
9 // This file is part of the PixInsight Class Library (PCL).
10 // PCL is a multiplatform C++ framework for development of PixInsight modules.
11 //
12 // Copyright (c) 2003-2024 Pleiades Astrophoto S.L. All Rights Reserved.
13 //
14 // Redistribution and use in both source and binary forms, with or without
15 // modification, is permitted provided that the following conditions are met:
16 //
17 // 1. All redistributions of source code must retain the above copyright
18 // notice, this list of conditions and the following disclaimer.
19 //
20 // 2. All redistributions in binary form must reproduce the above copyright
21 // notice, this list of conditions and the following disclaimer in the
22 // documentation and/or other materials provided with the distribution.
23 //
24 // 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
25 // of their contributors, may be used to endorse or promote products derived
26 // from this software without specific prior written permission. For written
27 // permission, please contact info@pixinsight.com.
28 //
29 // 4. All products derived from this software, in any form whatsoever, must
30 // reproduce the following acknowledgment in the end-user documentation
31 // and/or other materials provided with the product:
32 //
33 // "This product is based on software from the PixInsight project, developed
34 // by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
35 //
36 // Alternatively, if that is where third-party acknowledgments normally
37 // appear, this acknowledgment must be reproduced in the product itself.
38 //
39 // THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
40 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
41 // TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
43 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
44 // EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
45 // INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
46 // DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
47 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
49 // POSSIBILITY OF SUCH DAMAGE.
50 // ----------------------------------------------------------------------------
51 
52 #ifndef __PCL_ATrousWaveletTransform_h
53 #define __PCL_ATrousWaveletTransform_h
54 
56 
57 #include <pcl/Defs.h>
58 #include <pcl/Diagnostics.h>
59 
60 #include <pcl/AutoPointer.h>
61 #include <pcl/KernelFilter.h>
63 #include <pcl/SeparableFilter.h>
64 
65 namespace pcl
66 {
67 
68 // ----------------------------------------------------------------------------
69 
70 class InterlacedTransformation;
71 
124 {
125 public:
126 
131 
136 
141 
161  {
164 
169 
175  {
176  kernelFilter = f.Clone();
177  PCL_CHECK( !kernelFilter.IsNull() )
178  }
179 
185  {
186  separableFilter = f.Clone();
187  PCL_CHECK( !separableFilter.IsNull() )
188  }
189 
195  {
196  if ( !s.kernelFilter.IsNull() )
197  {
198  kernelFilter = s.kernelFilter->Clone();
199  PCL_CHECK( !kernelFilter.IsNull() )
200  }
201  if ( !s.separableFilter.IsNull() )
202  {
203  separableFilter = s.separableFilter->Clone();
204  PCL_CHECK( !separableFilter.IsNull() )
205  }
206  }
207 
212  : kernelFilter( s.kernelFilter )
213  , separableFilter( s.separableFilter )
214  {
215  }
216 
222  {
223  }
224 
229  {
230  if ( s.kernelFilter.IsNull() )
231  kernelFilter.Destroy();
232  else
233  {
234  kernelFilter = s.kernelFilter->Clone();
235  PCL_CHECK( !kernelFilter.IsNull() )
236  }
237 
238  if ( s.separableFilter.IsNull() )
239  separableFilter.Destroy();
240  else
241  {
242  separableFilter = s.separableFilter->Clone();
243  PCL_CHECK( !separableFilter.IsNull() )
244  }
245 
246  return *this;
247  }
248 
252  WaveletScalingFunction& operator =( WaveletScalingFunction&& ) = default;
253 
258  bool IsSeparable() const
259  {
260  return !separableFilter.IsNull() && !separableFilter->IsEmpty();
261  }
262 
267  bool IsNonseparable() const
268  {
269  return !kernelFilter.IsNull() && !kernelFilter->IsEmpty();
270  }
271 
276  bool IsValid() const
277  {
278  return IsSeparable() || IsNonseparable();
279  }
280 
286  void Set( const KernelFilter& f )
287  {
288  separableFilter.Destroy();
289  kernelFilter = f.Clone();
290  PCL_CHECK( !kernelFilter.IsNull() )
291  }
292 
298  void Set( const SeparableFilter& f )
299  {
300  kernelFilter.Destroy();
301  separableFilter = f.Clone();
302  PCL_CHECK( !separableFilter.IsNull() )
303  }
304 
309  void Clear()
310  {
311  kernelFilter.Destroy();
312  separableFilter.Destroy();
313  }
314 
319  bool operator ==( const WaveletScalingFunction& other ) const
320  {
321  if ( !kernelFilter.IsNull() )
322  return !other.kernelFilter.IsNull() && *kernelFilter == *other.kernelFilter;
323  if ( !separableFilter.IsNull() )
324  return !other.separableFilter.IsNull() && *separableFilter == *other.separableFilter;
325  return other.kernelFilter.IsNull() && other.separableFilter.IsNull();
326  }
327  };
328 
338 
356  ATrousWaveletTransform( const WaveletScalingFunction& f, int n = 4, int d = 0 )
358  , m_scalingFunction( f )
359  {
360  PCL_CHECK( m_scalingFunction.IsValid() )
361  }
362 
381  ATrousWaveletTransform( const KernelFilter& f, int n = 4, int d = 0 )
383  , m_scalingFunction( f )
384  {
385  PCL_CHECK( m_scalingFunction.IsValid() )
386  }
387 
405  ATrousWaveletTransform( const SeparableFilter& f, int n = 4, int d = 0 )
407  , m_scalingFunction( f )
408  {
409  PCL_CHECK( m_scalingFunction.IsValid() )
410  }
411 
416 
421 
428  {
429  }
430 
434  ATrousWaveletTransform& operator =( const ATrousWaveletTransform& ) = default;
435 
439  ATrousWaveletTransform& operator =( ATrousWaveletTransform&& ) = default;
440 
446  {
447  return m_scalingFunction;
448  }
449 
457  {
458  DestroyLayers();
459  m_scalingFunction = f;
460  PCL_CHECK( m_scalingFunction.IsValid() )
461  }
462 
471  {
472  DestroyLayers();
473  m_scalingFunction.Set( f );
474  PCL_CHECK( m_scalingFunction.IsValid() )
475  }
476 
485  {
486  DestroyLayers();
487  m_scalingFunction.Set( f );
488  PCL_CHECK( m_scalingFunction.IsValid() )
489  }
490 
542  double NoiseKSigma( int j = 0, float k = 3,
543  float eps = 0.01, int n = 10, size_type* N = nullptr ) const;
544 
573  double NoiseKSigma( int j, const ImageVariant& image,
574  float low = 0.00002F, float high = 0.99998F,
575  float k = 3, float eps = 0.01, int n = 10, size_type* N = nullptr ) const;
576 
637  double NoiseMRS( const ImageVariant& image, const float sj[],
638  double sigma = 0, float k = 3, size_type* N = nullptr,
639  float low = 0.00002F, float high = 0.99998F ) const;
640 
641 private:
642 
643  /*
644  * Wavelet scaling function.
645  */
646  WaveletScalingFunction m_scalingFunction;
647 
648  /*
649  * Transform (decomposition)
650  */
651  void Transform( const pcl::Image& ) override;
652  void Transform( const pcl::DImage& ) override;
653  void Transform( const pcl::ComplexImage& ) override;
654  void Transform( const pcl::DComplexImage& ) override;
655  void Transform( const pcl::UInt8Image& ) override;
656  void Transform( const pcl::UInt16Image& ) override;
657  void Transform( const pcl::UInt32Image& ) override;
658 
659  void ValidateScalingFunction() const;
660 
661  friend class ATWTDecomposition;
662 };
663 
664 // ----------------------------------------------------------------------------
665 
678 
679 // ----------------------------------------------------------------------------
680 
681 } // pcl
682 
683 #endif // __PCL_ATrousWaveletTransform_h
684 
685 // ----------------------------------------------------------------------------
686 // EOF pcl/ATrousWaveletTransform.h - Released 2024-05-07T15:27:32Z
Discrete isotropic à trous wavelet transform.
ATrousWaveletTransform(const SeparableFilter &f, int n=4, int d=0)
double NoiseKSigma(int j=0, float k=3, float eps=0.01, int n=10, size_type *N=nullptr) const
void SetScalingFunction(const SeparableFilter &f)
ATrousWaveletTransform(const KernelFilter &f, int n=4, int d=0)
ATrousWaveletTransform(const WaveletScalingFunction &f, int n=4, int d=0)
ATrousWaveletTransform(const ATrousWaveletTransform &)=default
const WaveletScalingFunction & ScalingFunction() const
ATrousWaveletTransform(ATrousWaveletTransform &&)=default
double NoiseKSigma(int j, const ImageVariant &image, float low=0.00002F, float high=0.99998F, float k=3, float eps=0.01, int n=10, size_type *N=nullptr) const
double NoiseMRS(const ImageVariant &image, const float sj[], double sigma=0, float k=3, size_type *N=nullptr, float low=0.00002F, float high=0.99998F) const
void SetScalingFunction(const WaveletScalingFunction &f)
void SetScalingFunction(const KernelFilter &f)
A smart pointer with exclusive object ownership and optional automatic object destruction.
Definition: AutoPointer.h:241
bool IsNull() const
Definition: AutoPointer.h:453
Implements a generic, two-dimensional, shared or local image.
Definition: Image.h:278
Acts like a union for all types of images in PCL, with optional class-wide ownership of transported i...
Definition: ImageVariant.h:322
Kernel filter in two dimensions.
Definition: KernelFilter.h:90
virtual KernelFilter * Clone() const
Definition: KernelFilter.h:190
Base class of all redundant multiscale transforms.
Separable filter in two dimensions.
virtual SeparableFilter * Clone() const
bool operator==(const Array< T, A > &x1, const Array< T, A > &x2) noexcept
Definition: Array.h:2090
size_t size_type
Definition: Defs.h:609
PCL root namespace.
Definition: AbstractImage.h:77
The scaling function of a wavelet transform.
AutoPointer< SeparableFilter > separableFilter
Separable filter.
AutoPointer< KernelFilter > kernelFilter
Non-separable kernel filter.