PCL
PSFEstimator.h
Go to the documentation of this file.
1 // ____ ______ __
2 // / __ \ / ____// /
3 // / /_/ // / / /
4 // / ____// /___ / /___ PixInsight Class Library
5 // /_/ \____//_____/ PCL 2.7.0
6 // ----------------------------------------------------------------------------
7 // pcl/PSFEstimator.h - Released 2024-06-18T15:48:54Z
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_PSFEstimator_h
53 #define __PCL_PSFEstimator_h
54 
56 
57 #include <pcl/Defs.h>
58 
59 #include <pcl/StarDetector.h>
60 #include <pcl/PSFFit.h>
61 
62 namespace pcl
63 {
64 
65 // ----------------------------------------------------------------------------
66 
72 class PCL_CLASS PSFEstimator : public ParallelProcess
73 {
74 public:
75 
79  using psf_function = StarDetector::psf_function;
80 
84  PSFEstimator() = default;
85 
89  PSFEstimator( const PSFEstimator& ) = default;
90 
94  ~PSFEstimator() override
95  {
96  }
97 
101  PSFEstimator& operator =( const PSFEstimator& ) = default;
102 
111  const StarDetector& Detector() const
112  {
113  return const_cast<const StarDetector&>( m_starDetector );
114  }
115 
126  {
127  return m_starDetector;
128  }
129 
144  psf_function PSFType() const
145  {
146  return m_psfType;
147  }
148 
153  void SetPSFType( psf_function type )
154  {
155  m_psfType = type;
156  }
157 
171  float PSFCentroidTolerance() const
172  {
173  return m_psfCentroidTolerance;
174  }
175 
180  void SetPSFCentroidTolerance( float t )
181  {
182  PCL_PRECONDITION( t >= 0 )
183  m_psfCentroidTolerance = Max( 0.0F, t );
184  }
185 
199  float SaturationThreshold() const
200  {
201  return m_saturationThreshold;
202  }
203 
209  void SetSaturationThreshold( float t )
210  {
211  PCL_PRECONDITION( t >= 0.1 && t <= 1.0 )
212  m_saturationThreshold = Range( t, 0.1F, 1.0F );
213  }
214 
223  {
224  return m_saturationRelative;
225  }
226 
232  void EnableRelativeSaturation( bool enable = true )
233  {
234  m_saturationRelative = enable;
235  }
236 
242  void DisableRelativeSaturation( bool disable = true )
243  {
244  EnableRelativeSaturation( !disable );
245  }
246 
265  float RejectionLimit() const
266  {
267  return m_rejectionLimit;
268  }
269 
274  void SetRejectionLimit( float r )
275  {
276  PCL_PRECONDITION( r >= 0.5 && r <= 1 )
277  m_rejectionLimit = Range( r, 0.5F, 1.0F );
278  }
279 
290  {
291  return m_growthForFlux;
292  }
293 
300  {
301  PCL_PRECONDITION( k >= 0.5 && k <= 2.0 )
302  m_growthForFlux = Range( k, 0.5F, 2.0F );
303  }
304 
315  int MaxStars() const
316  {
317  return m_maxStars;
318  }
319 
329  void SetMaxStars( int n )
330  {
331  PCL_PRECONDITION( n >= 0 )
332  m_maxStars = Max( 0, n );
333  }
334 
344  {
345  return m_weighted;
346  }
347 
352  void EnablePSFWeighting( bool enable = true )
353  {
354  m_weighted = enable;
355  }
356 
361  void DisablePSFWeighting( bool disable = true )
362  {
363  EnablePSFWeighting( !disable );
364  }
365 
378  Array<PSFData> FitStars( const ImageVariant& image ) const;
379 
380 protected:
381 
382  mutable pcl::StarDetector m_starDetector;
383  psf_function m_psfType = PSFunction::Moffat4;
384  float m_psfCentroidTolerance = 1.5F;
385  float m_saturationThreshold = 0.75F;
386  bool m_saturationRelative = true;
387  float m_rejectionLimit = 1.0F;
388  float m_growthForFlux = 1.0F;
389  int m_maxStars = 0;
390  bool m_weighted = false;
391 };
392 
393 // ----------------------------------------------------------------------------
394 
395 } // pcl
396 
397 #endif // __PCL_PSFEstimator_h
398 
399 // ----------------------------------------------------------------------------
400 // EOF pcl/PSFEstimator.h - Released 2024-06-18T15:48:54Z
Generic dynamic array.
Definition: Array.h:100
Acts like a union for all types of images in PCL, with optional class-wide ownership of transported i...
Definition: ImageVariant.h:322
Base class of estimators based on PSF photometry.
Definition: PSFEstimator.h:73
psf_function PSFType() const
Definition: PSFEstimator.h:144
int MaxStars() const
Definition: PSFEstimator.h:315
~PSFEstimator() override
Definition: PSFEstimator.h:94
void EnableRelativeSaturation(bool enable=true)
Definition: PSFEstimator.h:232
void SetPSFType(psf_function type)
Definition: PSFEstimator.h:153
PSFEstimator(const PSFEstimator &)=default
void SetRejectionLimit(float r)
Definition: PSFEstimator.h:274
Array< PSFData > FitStars(const ImageVariant &image) const
StarDetector & Detector()
Definition: PSFEstimator.h:125
void EnablePSFWeighting(bool enable=true)
Definition: PSFEstimator.h:352
void SetPSFCentroidTolerance(float t)
Definition: PSFEstimator.h:180
float PSFCentroidTolerance() const
Definition: PSFEstimator.h:171
void SetSaturationThreshold(float t)
Definition: PSFEstimator.h:209
void SetGrowthFactorForFluxMeasurement(float k)
Definition: PSFEstimator.h:299
float RejectionLimit() const
Definition: PSFEstimator.h:265
void SetMaxStars(int n)
Definition: PSFEstimator.h:329
void DisablePSFWeighting(bool disable=true)
Definition: PSFEstimator.h:361
float SaturationThreshold() const
Definition: PSFEstimator.h:199
float GrowthFactorForFluxMeasurement() const
Definition: PSFEstimator.h:289
bool IsRelativeSaturationEnabled() const
Definition: PSFEstimator.h:222
const StarDetector & Detector() const
Definition: PSFEstimator.h:111
PSFEstimator()=default
bool IsPSFWeightingEnabled() const
Definition: PSFEstimator.h:343
void DisableRelativeSaturation(bool disable=true)
Definition: PSFEstimator.h:242
A process using multiple concurrent execution threads.
Automatic star detection.
Definition: StarDetector.h:74
PSFFit::psf_function psf_function
Definition: StarDetector.h:80
constexpr const T & Range(const T &x, const T &a, const T &b) noexcept
Definition: Utility.h:190
constexpr const T & Max(const T &a, const T &b) noexcept
Definition: Utility.h:119
PCL root namespace.
Definition: AbstractImage.h:77