52 #ifndef __PCL_GeometricTransformation_h
53 #define __PCL_GeometricTransformation_h
58 #include <pcl/Diagnostics.h>
132 virtual bool SupportsGammaCorrection()
const
140 bool IsGammaCorrectionEnabled()
const
142 return m_gammaCorrected;
148 void EnableGammaCorrection(
bool enable =
true )
150 m_gammaCorrected = enable;
156 void DisableGammaCorrection(
bool disable =
true )
158 EnableGammaCorrection( !disable );
164 const RGBColorSystem& RGBWorkingSpace()
const
172 void SetRGBWorkingSpace(
const RGBColorSystem& rgbws )
174 m_rgbws =
new RGBColorSystem( rgbws );
180 void ClearRGBWorkingSpace()
189 void ApplyGammaCorrection(
typename P::sample* samples,
size_type length,
190 AbstractImage::ThreadData& threadData,
int maxProcessors = PCL_MAX_PROCESSORS )
const
192 if ( m_rgbws.IsNull() || m_rgbws->IsSRGB() )
193 ApplySRGBGammaCorrection<P>( samples, length, threadData, maxProcessors );
195 ApplyGammaExponentCorrection<P>( samples, length, m_rgbws->Gamma(), threadData, maxProcessors );
202 void ApplyInverseGammaCorrection(
typename P::sample* samples,
size_type length,
203 AbstractImage::ThreadData& threadData,
int maxProcessors = PCL_MAX_PROCESSORS )
const
205 if ( m_rgbws.IsNull() || m_rgbws->IsSRGB() )
206 ApplyInverseSRGBGammaCorrection<P>( samples, length, threadData, maxProcessors );
208 ApplyInverseGammaExponentCorrection<P>( samples, length, m_rgbws->Gamma(), threadData, maxProcessors );
235 PCL_PRECONDITION( gamma > 0 )
236 if ( samples !=
nullptr )
242 for (
size_type i = 0, n = 0; i < L.Length(); n += L[i++] )
243 threads.
Add(
new GammaThread<P>( threadData, gamma, samples, n, n + L[i] ) );
274 PCL_PRECONDITION( gamma > 0 )
275 if ( samples !=
nullptr )
281 for (
size_type i = 0, n = 0; i < L.Length(); n += L[i++] )
282 threads.
Add(
new GammaInvThread<P>( threadData, gamma, samples, n, n + L[i] ) );
309 if ( samples !=
nullptr )
314 for (
size_type i = 0, n = 0; i < L.Length(); n += L[i++] )
315 threads.
Add(
new SRGBGammaThread<P>( threadData, samples, n, n + L[i] ) );
342 if ( samples !=
nullptr )
347 for (
size_type i = 0, n = 0; i < L.Length(); n += L[i++] )
348 threads.
Add(
new SRGBGammaInvThread<P>( threadData, samples, n, n + L[i] ) );
356 bool m_gammaCorrected =
false;
364 using sample_type =
typename P::sample;
369 , m_samples( samples )
375 PCL_HOT_FUNCTION
void Run()
override
379 sample_type* __restrict__ f = m_samples + m_start;
380 for (
size_type i = m_start; i < m_end; ++i, ++f )
382 double x; P::FromSample( x, *f );
383 *f = P::ToSample(
pcl::Pow( x, m_gamma ) );
391 AbstractImage::ThreadData& m_data;
393 sample_type* m_samples;
403 using sample_type =
typename P::sample;
405 GammaInvThread( AbstractImage::ThreadData& data,
double gamma, sample_type* samples,
size_type start,
size_type end )
407 , m_gammaInv( 1/gamma )
408 , m_samples( samples )
414 PCL_HOT_FUNCTION
void Run()
override
418 sample_type* __restrict__ f = m_samples + m_start;
419 for (
size_type i = m_start; i < m_end; ++i, ++f )
421 double x; P::FromSample( x, *f );
422 *f = P::ToSample(
pcl::Pow( x, m_gammaInv ) );
430 AbstractImage::ThreadData& m_data;
432 sample_type* m_samples;
442 using sample_type =
typename P::sample;
444 SRGBGammaThread( AbstractImage::ThreadData& data, sample_type* samples,
size_type start,
size_type end )
446 , m_samples( samples )
452 PCL_HOT_FUNCTION
void Run()
override
456 sample_type* __restrict__ f = m_samples + m_start;
457 for (
size_type i = m_start; i < m_end; ++i, ++f )
459 double x; P::FromSample( x, *f );
468 AbstractImage::ThreadData& m_data;
469 sample_type* m_samples;
479 using sample_type =
typename P::sample;
481 SRGBGammaInvThread( AbstractImage::ThreadData& data, sample_type* samples,
size_type start,
size_type end )
483 , m_samples( samples )
489 PCL_HOT_FUNCTION
void Run()
override
493 sample_type* __restrict__ f = m_samples + m_start;
494 for (
size_type i = m_start; i < m_end; ++i, ++f )
496 double x; P::FromSample( x, *f );
505 AbstractImage::ThreadData& m_data;
506 sample_type* m_samples;
540 : m_interpolation( &p )
542 PCL_CHECK( m_interpolation !=
nullptr )
560 , m_interpolation( x.m_interpolation )
561 , m_unclipped( x.m_unclipped )
563 x.m_interpolation =
nullptr;
585 m_interpolation = x.m_interpolation;
586 x.m_interpolation =
nullptr;
587 m_unclipped = x.m_unclipped;
597 PCL_CHECK( m_interpolation !=
nullptr )
598 return *m_interpolation;
607 PCL_CHECK( m_interpolation !=
nullptr )
608 return *m_interpolation;
625 m_interpolation = &p;
626 PCL_CHECK( m_interpolation !=
nullptr )
650 m_unclipped = enable;
659 EnableUnclippedInterpolation( !disable );
665 bool m_unclipped =
false;
static void RunThreads(ReferenceArray< thread > &threads, ThreadData &data, bool useAffinity=true)
A smart pointer able to generate dynamically allocated copies of the objects pointed to by other smar...
Abstract root base class for all pixel interpolation algorithms.
static const RGBColorSystem sRGB
static double LinearToSRGB(double x)
static double SRGBToLinear(double x)
Dynamic array of pointers to objects providing direct iteration and element access by reference.
void Destroy(iterator i, size_type n=1)
void Add(const ReferenceArray &x)
Client-side interface to a PixInsight thread.
static Array< size_type > OptimalThreadLoads(size_type count, size_type overheadLimit=1u, int maxThreads=PCL_MAX_PROCESSORS)
Complex< T1 > Pow(const Complex< T1 > &c, T2 x) noexcept
#define INIT_THREAD_MONITOR()
Declares and initializes local variables used for synchronization of thread status monitoring.
#define UPDATE_THREAD_MONITOR(N)
Synchronized status monitoring of a set of image processing threads.
Thread synchronization data for status monitoring of parallel image processing tasks.