PCL
PixelTraits.h
Go to the documentation of this file.
1 // ____ ______ __
2 // / __ \ / ____// /
3 // / /_/ // / / /
4 // / ____// /___ / /___ PixInsight Class Library
5 // /_/ \____//_____/ PCL 2.7.0
6 // ----------------------------------------------------------------------------
7 // pcl/PixelTraits.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_PixelTraits_h
53 #define __PCL_PixelTraits_h
54 
56 
57 #include <pcl/Defs.h>
58 #include <pcl/Diagnostics.h>
59 
60 #include <pcl/Complex.h>
61 #include <pcl/Math.h>
62 
63 #include <memory.h>
64 
65 namespace pcl
66 {
67 
68 // ----------------------------------------------------------------------------
69 
70 struct PixelTraitsLUT
71 {
72  const float* pFLUT8; // uint8 -> float
73  const float* pFLUTA; // i/255^2 (direct 8-bit normalization)
74  const float* p1FLUT8; // 1 - pFLUT8
75  const float* pFLUT16; // uint16 -> float
76  const float* pFLUT20; // uint20 -> float
77  const double* pDLUT8; // uint8 -> double
78  const double* pDLUTA; // i/255^2 (direct 8-bit normalization)
79  const double* p1DLUT8; // 1- pDLUT8
80  const double* pDLUT16; // uint16 -> double
81  const double* pDLUT20; // uint20 -> double
82  const uint8* p8LUT16; // uint16 -> uint8
83  const uint8* p8LUT20; // uint20 -> uint8
84  const uint16* p16LUT8; // uint8 -> uint16
85  const uint16* p16LUT20; // uint20 -> uint16
86  const uint32* p20LUT8; // uint8 -> uint20
87  const uint32* p20LUT16; // uint16 -> uint20
88  const uint32* p24LUT8; // uint8 -> uint24
89  const uint32* p24LUT16; // uint16 -> uint24
90  const uint32* p32LUT8; // uint8 -> uint32
91  const uint32* p32LUT16; // uint16 -> uint32
92  const uint32* p32LUT20; // uint20 -> uint32
93 };
94 
95 extern PCL_DATA const PixelTraitsLUT* PTLUT;
96 
97 #ifndef __PCL_DONT_USE_PIXTRAITS_LUT
98 # define pFLUT8 PTLUT->pFLUT8
99 # define pFLUTA PTLUT->pFLUTA
100 # define p1FLUT8 PTLUT->p1FLUT8
101 # define pFLUT16 PTLUT->pFLUT16
102 # define pFLUT20 PTLUT->pFLUT20
103 # define pDLUT8 PTLUT->pDLUT8
104 # define pDLUTA PTLUT->pDLUTA
105 # define p1DLUT8 PTLUT->p1DLUT8
106 # define pDLUT16 PTLUT->pDLUT16
107 # define pDLUT20 PTLUT->pDLUT20
108 # define p8LUT16 PTLUT->p8LUT16
109 # define p8LUT20 PTLUT->p8LUT20
110 # define p16LUT8 PTLUT->p16LUT8
111 # define p16LUT20 PTLUT->p16LUT20
112 # define p20LUT8 PTLUT->p20LUT8
113 # define p20LUT16 PTLUT->p20LUT16
114 # define p24LUT8 PTLUT->p24LUT8
115 # define p24LUT16 PTLUT->p24LUT16
116 # define p32LUT8 PTLUT->p32LUT8
117 # define p32LUT16 PTLUT->p32LUT16
118 # define p32LUT20 PTLUT->p32LUT20
119 #endif
120 
121 #define EPSILON_D 1.0e-16
122 #define EPSILON_F 1.0e-8F
123 
124 // ----------------------------------------------------------------------------
125 
175 template <class S>
176 class PCL_CLASS GenericPixelTraits
177 {
178 public:
179 
183  using sample = S;
184 
185  enum { bytesPerSample = sizeof( sample ) };
186  enum { bitsPerSample = bytesPerSample << 3 };
187 
191  static constexpr int BytesPerSample() noexcept
192  {
193  return bytesPerSample;
194  }
195 
199  static constexpr int BitsPerSample() noexcept
200  {
201  return bitsPerSample;
202  }
203 
208  static constexpr sample MinSampleValue() noexcept
209  {
210  return sample( 0 );
211  }
212 };
213 
214 #define IMPLEMENT_TRANSFER_OPERATIONS \
215  \
216  template <typename T> \
217  static void Fill( sample* __restrict__ f, T x, size_type n ) noexcept \
218  { \
219  PCL_PRECONDITION( f != nullptr ) \
220  sample v = ToSample( x ); \
221  PCL_IVDEP \
222  for ( ; n > 0; --n, ++f ) \
223  *f = v; \
224  } \
225  \
226  static void Fill( sample* __restrict__ f, sample x, size_type n ) noexcept \
227  { \
228  PCL_PRECONDITION( f != nullptr ) \
229  PCL_IVDEP \
230  for ( ; n > 0; --n, ++f ) \
231  *f = x; \
232  } \
233  \
234  template <typename T> \
235  static void Get( T* __restrict__ f, const sample* __restrict__ g, size_type n ) noexcept \
236  { \
237  PCL_PRECONDITION( f != nullptr && g != nullptr ) \
238  PCL_IVDEP \
239  for ( ; n > 0; --n, ++f, ++g ) \
240  FromSample( *f, *g ); \
241  } \
242  \
243  static void Get( sample* __restrict__ f, const sample* __restrict__ g, size_type n ) \
244  { \
245  PCL_PRECONDITION( f != nullptr && g != nullptr ) \
246  PCL_IVDEP \
247  for ( ; n > 0; --n, ++f, ++g ) \
248  *f = *g; \
249  } \
250  \
251  template <typename T> \
252  static void Copy( sample* __restrict__ f, const T* __restrict__ g, size_type n ) noexcept \
253  { \
254  PCL_PRECONDITION( f != nullptr && g != nullptr ) \
255  PCL_IVDEP \
256  for ( ; n > 0; --n, ++f, ++g ) \
257  *f = ToSample( *g ); \
258  } \
259  \
260  static void Copy( sample* __restrict__ f, const sample* __restrict__ g, size_type n ) \
261  { \
262  PCL_PRECONDITION( f != nullptr && g != nullptr ) \
263  PCL_IVDEP \
264  for ( ; n > 0; --n, ++f, ++g ) \
265  *f = *g; \
266  } \
267  \
268  template <typename T> \
269  static void GetMin( T* __restrict__ f, const sample* __restrict__ g, size_type n ) noexcept \
270  { \
271  PCL_PRECONDITION( f != nullptr && g != nullptr ) \
272  PCL_IVDEP \
273  for ( ; n > 0; --n, ++f, ++g ) \
274  { \
275  T h; FromSample( h, *g ); \
276  if ( h < *f ) \
277  *f = h; \
278  } \
279  } \
280  \
281  static void GetMin( sample* __restrict__ f, const sample* __restrict__ g, size_type n ) noexcept \
282  { \
283  PCL_PRECONDITION( f != nullptr && g != nullptr ) \
284  PCL_IVDEP \
285  for ( ; n > 0; --n, ++f, ++g ) \
286  if ( *g < *f ) \
287  *f = *g; \
288  } \
289  \
290  template <typename T> \
291  static void CopyMin( sample* __restrict__ f, const T* __restrict__ g, size_type n ) noexcept \
292  { \
293  PCL_PRECONDITION( f != nullptr && g != nullptr ) \
294  PCL_IVDEP \
295  for ( ; n > 0; --n, ++f, ++g ) \
296  { \
297  sample h = ToSample( *g ); \
298  if ( h < *f ) \
299  *f = h; \
300  } \
301  } \
302  \
303  static void CopyMin( sample* __restrict__ f, const sample* __restrict__ g, size_type n ) noexcept \
304  { \
305  PCL_PRECONDITION( f != nullptr && g != nullptr ) \
306  PCL_IVDEP \
307  for ( ; n > 0; --n, ++f, ++g ) \
308  if ( *g < *f ) \
309  *f = *g; \
310  } \
311  \
312  template <typename T> \
313  static void GetMax( T* __restrict__ f, const sample* __restrict__ g, size_type n ) noexcept \
314  { \
315  PCL_PRECONDITION( f != nullptr && g != nullptr ) \
316  PCL_IVDEP \
317  for ( ; n > 0; --n, ++f, ++g ) \
318  { \
319  T h; FromSample( h, *g ); \
320  if ( *f < h ) \
321  *f = h; \
322  } \
323  } \
324  \
325  static void GetMax( sample* __restrict__ f, const sample* __restrict__ g, size_type n ) noexcept \
326  { \
327  PCL_PRECONDITION( f != nullptr && g != nullptr ) \
328  PCL_IVDEP \
329  for ( ; n > 0; --n, ++f, ++g ) \
330  if ( *f < *g ) \
331  *f = *g; \
332  } \
333  \
334  template <typename T> \
335  static void CopyMax( sample* __restrict__ f, const T* __restrict__ g, size_type n ) noexcept \
336  { \
337  PCL_PRECONDITION( f != nullptr && g != nullptr ) \
338  PCL_IVDEP \
339  for ( ; n > 0; --n, ++f, ++g ) \
340  { \
341  sample h = ToSample( *g ); \
342  if ( *f < h ) \
343  *f = h; \
344  } \
345  } \
346  \
347  static void CopyMax( sample* __restrict__ f, const sample* __restrict__ g, size_type n ) noexcept \
348  { \
349  PCL_PRECONDITION( f != nullptr && g != nullptr ) \
350  PCL_IVDEP \
351  for ( ; n > 0; --n, ++f, ++g ) \
352  if ( *f < *g ) \
353  *f = *g; \
354  }
355 
356 // ----------------------------------------------------------------------------
357 
368 class PCL_CLASS FloatPixelTraits : public GenericPixelTraits<float>
369 {
370 public:
371 
376 
381 
387  using component = sample;
388 
393  static constexpr bool IsFloatSample() noexcept
394  {
395  return true;
396  }
397 
402  static constexpr bool IsComplexSample() noexcept
403  {
404  return false;
405  }
406 
413  static constexpr const char* SampleFormat() noexcept
414  {
415  return "Float32";
416  }
417 
423  static constexpr sample MaxSampleValue() noexcept
424  {
425  return 1.0F;
426  }
427 
434  static constexpr sample LowestSampleValue() noexcept
435  {
436  return std::numeric_limits<float>::lowest();
437  }
438 
445  static constexpr sample HighestSampleValue() noexcept
446  {
447  return std::numeric_limits<float>::max();
448  }
449 
453  template <typename T>
454  static constexpr sample FloatToSample( T x ) noexcept
455  {
456  return sample( x );
457  }
458 
462  static sample ToSample( uint8 x ) noexcept
463  {
464 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
465  return sample( x )/uint8_max;
466 #else
467  return pFLUT8[x];
468 #endif
469  }
470 
474  static sample ToSample( int8 x ) noexcept
475  {
476 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
477  return (sample( x ) - int8_min)/uint8_max;
478 #else
479  return pFLUT8[int( x ) - int8_min];
480 #endif
481  }
482 
486  static sample ToSample( uint16 x ) noexcept
487  {
488 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
489  return sample( x )/uint16_max;
490 #else
491  return pFLUT16[x];
492 #endif
493  }
494 
498  static sample ToSample( int16 x ) noexcept
499  {
500 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
501  return (sample( x ) - int16_min)/uint16_max;
502 #else
503  return pFLUT16[int( x ) - int16_min];
504 #endif
505  }
506 
510  static constexpr sample ToSample( uint32 x ) noexcept
511  {
512  return sample( double( x )/uint32_max );
513  }
514 
518  static constexpr sample ToSample( int32 x ) noexcept
519  {
520  return sample( (double( x ) - int32_min)/uint32_max );
521  }
522 
526  static constexpr sample ToSample( float x ) noexcept
527  {
528  return sample( x );
529  }
530 
534  static constexpr sample ToSample( double x ) noexcept
535  {
536  return sample( x );
537  }
538 
542  template <typename T>
543  static constexpr sample ToSample( const Complex<T>& x ) noexcept
544  {
545  return sample( pcl::Abs( x ) );
546  }
547 
551  static void FromSample( uint8& a, sample b ) noexcept
552  {
553  a = uint8( RoundInt( b*uint8_max ) );
554  }
555 
559  static void FromSample( int8& a, sample b ) noexcept
560  {
561  a = int8( RoundInt( b*uint8_max ) + int8_min );
562  }
563 
567  static void FromSample( uint16& a, sample b ) noexcept
568  {
569  a = uint16( RoundInt( b*uint16_max ) );
570  }
571 
575  static void FromSample( int16& a, sample b ) noexcept
576  {
577  a = int16( RoundInt( b*uint16_max ) + int16_min );
578  }
579 
583  static void FromSample( uint32& a, sample b ) noexcept
584  {
585  a = uint32( Round( double( b )*uint32_max ) );
586  }
587 
591  static void FromSample( int32& a, sample b ) noexcept
592  {
593  a = int32( Round( double( b )*uint32_max ) + int32_min );
594  }
595 
599  static void FromSample( float& a, sample b ) noexcept
600  {
601  a = float( b );
602  }
603 
607  static void FromSample( double& a, sample b ) noexcept
608  {
609  a = double( b );
610  }
611 
615  template <typename T>
616  static void FromSample( Complex<T>& a, sample b ) noexcept
617  {
618  a = typename Complex<T>::component( b );
619  }
620 
625  template <typename T>
626  static void Mov( sample& a, T b ) noexcept
627  {
628  a = ToSample( b );
629  }
630 
635  template <typename T>
636  static void Add( sample& a, T b ) noexcept
637  {
638  a += ToSample( b );
639  }
640 
645  template <typename T>
646  static void Sub( sample& a, T b ) noexcept
647  {
648  a -= ToSample( b );
649  }
650 
655  template <typename T>
656  static void Mul( sample& a, T b ) noexcept
657  {
658  a *= ToSample( b );
659  }
660 
665  template <typename T>
666  static void Div( sample& a, T b ) noexcept
667  {
668  a /= ToSample( b );
669  }
670 
675  template <typename T>
676  static void Pow( sample& a, T b ) noexcept
677  {
678  a = pcl::Pow( a, ToSample( b ) );
679  }
680 
685  template <typename T>
686  static void Dif( sample& a, T b ) noexcept
687  {
688  a = pcl::Abs( a - ToSample( b ) );
689  }
690 
695  template <typename T>
696  static void Min( sample& a, T b ) noexcept
697  {
698  a = pcl::Min( a, ToSample( b ) );
699  }
700 
705  template <typename T>
706  static void Max( sample& a, T b ) noexcept
707  {
708  a = pcl::Max( a, ToSample( b ) );
709  }
710 
717  template <typename T>
718  static void Or( sample& a, T b ) noexcept
719  {
720  uint8 ia; FromSample( ia, a );
721  uint8 ib; FromSample( ib, ToSample( b ) );
722  a = ToSample( uint8( ia | ib ) );
723  }
724 
731  template <typename T>
732  static void Nor( sample& a, T b ) noexcept
733  {
734  uint8 ia; FromSample( ia, a );
735  uint8 ib; FromSample( ib, ToSample( b ) );
736  a = ToSample( uint8( ~(ia | ib) ) );
737  }
738 
745  template <typename T>
746  static void And( sample& a, T b ) noexcept
747  {
748  uint8 ia; FromSample( ia, a );
749  uint8 ib; FromSample( ib, ToSample( b ) );
750  a = ToSample( uint8( ia & ib ) );
751  }
752 
758  static void Not( sample& a ) noexcept
759  {
760  uint8 ia; FromSample( ia, a );
761  a = ToSample( uint8( ~ia ) );
762  }
763 
770  template <typename T>
771  static void Not( sample& a, T b ) noexcept
772  {
773  uint8 ib; FromSample( ib, ToSample( b ) );
774  a = ToSample( uint8( ~ib ) );
775  }
776 
783  template <typename T>
784  static void Nand( sample& a, T b ) noexcept
785  {
786  uint8 ia; FromSample( ia, a );
787  uint8 ib; FromSample( ib, ToSample( b ) );
788  a = ToSample( uint8( ~(ia & ib) ) );
789  }
790 
797  template <typename T>
798  static void Xor( sample& a, T b ) noexcept
799  {
800  uint8 ia; FromSample( ia, a );
801  uint8 ib; FromSample( ib, ToSample( b ) );
802  a = ToSample( uint8( ia ^ ib ) );
803  }
804 
811  template <typename T>
812  static void Xnor( sample& a, T b ) noexcept
813  {
814  uint8 ia; FromSample( ia, a );
815  uint8 ib; FromSample( ib, ToSample( b ) );
816  a = ToSample( uint8( ~(ia ^ ib) ) );
817  }
818 
824  template <typename T>
825  static void ColorBurn( sample& a, T b ) noexcept
826  {
827  a = 1 - pcl::Min( (1 - a)/pcl::Max( EPSILON_F, ToSample( b ) ), 1.0F );
828  }
829 
835  template <typename T>
836  static void LinearBurn( sample& a, T b ) noexcept
837  {
838  a = a + ToSample( b ) - 1;
839  }
840 
846  template <typename T>
847  static void Screen( sample& a, T b ) noexcept
848  {
849  a = 1 - (1 - a)*(1 - ToSample( b ));
850  }
851 
857  template <typename T>
858  static void ColorDodge( sample& a, T b ) noexcept
859  {
860  a = pcl::Min( a/pcl::Max( EPSILON_F, (1 - ToSample( b )) ), 1.0F );
861  }
862 
868  template <typename T>
869  static void Overlay( sample& a, T b ) noexcept
870  {
871  a = (a > 0.5F) ? 1 - ((1 - 2*(a - 0.5F)) * (1 - ToSample( b ))) : 2*a*ToSample( b );
872  }
873 
879  template <typename T>
880  static void SoftLight( sample& a, T b ) noexcept
881  {
882  sample fb = ToSample( b );
883  a = (1 - 2*fb)*a*a + 2*a*fb; // Pegtop's formula
884  }
885 
891  template <typename T>
892  static void HardLight( sample& a, T b ) noexcept
893  {
894  sample fb = ToSample( b );
895  a = (fb > 0.5F) ? 1 - (1 - a)*(1 - 2*(fb - 0.5F)) : 2*a*fb;
896  }
897 
903  template <typename T>
904  static void VividLight( sample& a, T b ) noexcept
905  {
906  sample fb = ToSample( b );
907  a = (fb < 0.5F) ? pcl::Max( 0.0F, 1 - (1 - a)/pcl::Max( EPSILON_F, 2*fb ) ) : pcl::Min( a/pcl::Max( EPSILON_F, 2*(1 - fb) ), 1.0F );
908  }
909 
915  template <typename T>
916  static void LinearLight( sample& a, T b ) noexcept
917  {
918  sample fb = ToSample( b );
919  a = pcl::Range( a + 2*fb - 1, 0.0F, 1.0F );
920  }
921 
927  template <typename T>
928  static void PinLight( sample& a, T b ) noexcept
929  {
930  sample fb = ToSample( b );
931  a = (fb > 0.5F) ? pcl::Max( a, 2*(fb - 0.5F) ) : pcl::Min( a, 2*fb );
932  }
933 
939  template <typename T>
940  static void Exclusion( sample& a, T b ) noexcept
941  {
942  a = pcl::Range( 0.5F - 2*(a - 0.5F)*(ToSample( b ) - 0.5F), 0.0F, 1.0F );
943  }
944 
945  // -------------------------------------------------------------------------
946 
947  IMPLEMENT_TRANSFER_OPERATIONS
948 };
949 
950 // ----------------------------------------------------------------------------
951 
962 class PCL_CLASS DoublePixelTraits : public GenericPixelTraits<double>
963 {
964 public:
965 
970 
975 
981  using component = sample;
982 
987  static constexpr bool IsFloatSample() noexcept
988  {
989  return true;
990  }
991 
996  static constexpr bool IsComplexSample() noexcept
997  {
998  return false;
999  }
1000 
1007  static constexpr const char* SampleFormat() noexcept
1008  {
1009  return "Float64";
1010  }
1011 
1017  static constexpr sample MaxSampleValue() noexcept
1018  {
1019  return 1.0;
1020  }
1021 
1028  static constexpr sample LowestSampleValue() noexcept
1029  {
1030  return std::numeric_limits<double>::lowest();
1031  }
1032 
1039  static constexpr sample HighestSampleValue() noexcept
1040  {
1041  return std::numeric_limits<double>::max();
1042  }
1043 
1047  template <typename T>
1048  static constexpr sample FloatToSample( T x ) noexcept
1049  {
1050  return sample( x );
1051  }
1052 
1056  static sample ToSample( uint8 x ) noexcept
1057  {
1058 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
1059  return sample( x )/uint8_max;
1060 #else
1061  return pDLUT8[x];
1062 #endif
1063  }
1064 
1068  static sample ToSample( int8 x ) noexcept
1069  {
1070 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
1071  return (sample( x ) - int8_min)/uint8_max;
1072 #else
1073  return pDLUT8[int( x ) - int8_min];
1074 #endif
1075  }
1076 
1080  static sample ToSample( uint16 x ) noexcept
1081  {
1082 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
1083  return sample( x )/uint16_max;
1084 #else
1085  return pDLUT16[x];
1086 #endif
1087  }
1088 
1092  static sample ToSample( int16 x ) noexcept
1093  {
1094 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
1095  return (sample( x ) - int16_min)/uint16_max;
1096 #else
1097  return pDLUT16[int( x ) - int16_min];
1098 #endif
1099  }
1100 
1104  static constexpr sample ToSample( uint32 x ) noexcept
1105  {
1106  return sample( x )/uint32_max;
1107  }
1108 
1112  static constexpr sample ToSample( int32 x ) noexcept
1113  {
1114  return (sample( x ) - int32_min)/uint32_max;
1115  }
1116 
1120  static constexpr sample ToSample( float x ) noexcept
1121  {
1122  return sample( x );
1123  }
1124 
1128  static constexpr sample ToSample( double x ) noexcept
1129  {
1130  return sample( x );
1131  }
1132 
1136  template <typename T>
1137  static constexpr sample ToSample( const Complex<T>& x ) noexcept
1138  {
1139  return sample( pcl::Abs( x ) );
1140  }
1141 
1145  static void FromSample( uint8& a, sample b ) noexcept
1146  {
1147  a = uint8( RoundInt( b*uint8_max ) );
1148  }
1149 
1153  static void FromSample( int8& a, sample b ) noexcept
1154  {
1155  a = int8( RoundInt( b*uint8_max ) + int8_min );
1156  }
1157 
1161  static void FromSample( uint16& a, sample b ) noexcept
1162  {
1163  a = uint16( RoundInt( b*uint16_max ) );
1164  }
1165 
1169  static void FromSample( int16& a, sample b ) noexcept
1170  {
1171  a = int16( RoundInt( b*uint16_max ) + int16_min );
1172  }
1173 
1177  static void FromSample( uint32& a, sample b ) noexcept
1178  {
1179  a = uint32( Round( sample( b )*uint32_max ) );
1180  }
1181 
1185  static void FromSample( int32& a, sample b ) noexcept
1186  {
1187  a = int32( Round( sample( b )*uint32_max ) + int32_min );
1188  }
1189 
1193  static void FromSample( float& a, sample b ) noexcept
1194  {
1195  a = float( b );
1196  }
1197 
1201  static void FromSample( double& a, sample b ) noexcept
1202  {
1203  a = double( b );
1204  }
1205 
1209  template <typename T>
1210  static void FromSample( Complex<T>& a, sample b ) noexcept
1211  {
1212  a = typename Complex<T>::component( b );
1213  }
1214 
1219  template <typename T>
1220  static void Mov( sample& a, T b ) noexcept
1221  {
1222  a = ToSample( b );
1223  }
1224 
1229  template <typename T>
1230  static void Add( sample& a, T b ) noexcept
1231  {
1232  a += ToSample( b );
1233  }
1234 
1239  template <typename T>
1240  static void Sub( sample& a, T b ) noexcept
1241  {
1242  a -= ToSample( b );
1243  }
1244 
1249  template <typename T>
1250  static void Mul( sample& a, T b ) noexcept
1251  {
1252  a *= ToSample( b );
1253  }
1254 
1259  template <typename T>
1260  static void Div( sample& a, T b ) noexcept
1261  {
1262  a /= ToSample( b );
1263  }
1264 
1269  template <typename T>
1270  static void Pow( sample& a, T b ) noexcept
1271  {
1272  a = pcl::Pow( a, ToSample( b ) );
1273  }
1274 
1279  template <typename T>
1280  static void Dif( sample& a, T b ) noexcept
1281  {
1282  a = pcl::Abs( a - ToSample( b ) );
1283  }
1284 
1289  template <typename T>
1290  static void Min( sample& a, T b ) noexcept
1291  {
1292  a = pcl::Min( a, ToSample( b ) );
1293  }
1294 
1299  template <typename T>
1300  static void Max( sample& a, T b ) noexcept
1301  {
1302  a = pcl::Max( a, ToSample( b ) );
1303  }
1304 
1311  template <typename T>
1312  static void Or( sample& a, T b ) noexcept
1313  {
1314  uint8 ia; FromSample( ia, a );
1315  uint8 ib; FromSample( ib, ToSample( b ) );
1316  a = ToSample( uint8( ia | ib ) );
1317  }
1318 
1325  template <typename T>
1326  static void Nor( sample& a, T b ) noexcept
1327  {
1328  uint8 ia; FromSample( ia, a );
1329  uint8 ib; FromSample( ib, ToSample( b ) );
1330  a = ToSample( uint8( ~(ia | ib) ) );
1331  }
1332 
1339  template <typename T>
1340  static void And( sample& a, T b ) noexcept
1341  {
1342  uint8 ia; FromSample( ia, a );
1343  uint8 ib; FromSample( ib, ToSample( b ) );
1344  a = ToSample( uint8( ia & ib ) );
1345  }
1346 
1352  static void Not( sample& a ) noexcept
1353  {
1354  uint8 ia; FromSample( ia, a );
1355  a = ToSample( uint8( ~ia ) );
1356  }
1357 
1364  template <typename T>
1365  static void Not( sample& a, T b ) noexcept
1366  {
1367  uint8 ib; FromSample( ib, ToSample( b ) );
1368  a = ToSample( uint8( ~ib ) );
1369  }
1370 
1377  template <typename T>
1378  static void Nand( sample& a, T b ) noexcept
1379  {
1380  uint8 ia; FromSample( ia, a );
1381  uint8 ib; FromSample( ib, ToSample( b ) );
1382  a = ToSample( uint8( ~(ia & ib) ) );
1383  }
1384 
1391  template <typename T>
1392  static void Xor( sample& a, T b ) noexcept
1393  {
1394  uint8 ia; FromSample( ia, a );
1395  uint8 ib; FromSample( ib, ToSample( b ) );
1396  a = ToSample( uint8( ia ^ ib ) );
1397  }
1398 
1405  template <typename T>
1406  static void Xnor( sample& a, T b ) noexcept
1407  {
1408  uint8 ia; FromSample( ia, a );
1409  uint8 ib; FromSample( ib, ToSample( b ) );
1410  a = ToSample( uint8( ~(ia ^ ib) ) );
1411  }
1412 
1418  template <typename T>
1419  static void ColorBurn( sample& a, T b ) noexcept
1420  {
1421  a = 1 - pcl::Min( (1 - a)/pcl::Max( EPSILON_D, ToSample( b ) ), 1.0 );
1422  }
1423 
1429  template <typename T>
1430  static void LinearBurn( sample& a, T b ) noexcept
1431  {
1432  a = a + ToSample( b ) - 1;
1433  }
1434 
1440  template <typename T>
1441  static void Screen( sample& a, T b ) noexcept
1442  {
1443  a = 1 - (1 - a)*(1 - ToSample( b ));
1444  }
1445 
1451  template <typename T>
1452  static void ColorDodge( sample& a, T b ) noexcept
1453  {
1454  a = pcl::Min( a/pcl::Max( EPSILON_D, (1 - ToSample( b )) ), 1.0 );
1455  }
1456 
1462  template <typename T>
1463  static void Overlay( sample& a, T b ) noexcept
1464  {
1465  a = (a > 0.5) ? 1 - ((1 - 2*(a - 0.5)) * (1 - ToSample( b ))) : 2*a*ToSample( b );
1466  }
1467 
1473  template <typename T>
1474  static void SoftLight( sample& a, T b ) noexcept
1475  {
1476  sample fb = ToSample( b );
1477  a = (1 - 2*fb)*a*a + 2*a*fb; // Pegtop's formula
1478  }
1479 
1485  template <typename T>
1486  static void HardLight( sample& a, T b ) noexcept
1487  {
1488  sample fb = ToSample( b );
1489  a = (fb > 0.5) ? 1 - (1 - a)*(1 - 2*(fb - 0.5)) : 2*a*fb;
1490  }
1491 
1497  template <typename T>
1498  static void VividLight( sample& a, T b ) noexcept
1499  {
1500  sample fb = ToSample( b );
1501  a = (fb < 0.5) ? pcl::Max( 0.0, 1 - (1 - a)/pcl::Max( EPSILON_D, 2*fb ) ) : pcl::Min( a/pcl::Max( EPSILON_D, 2*(1 - fb) ), 1.0 );
1502  }
1503 
1509  template <typename T>
1510  static void LinearLight( sample& a, T b ) noexcept
1511  {
1512  sample fb = ToSample( b );
1513  a = pcl::Range( a + 2*fb - 1, 0.0, 1.0 );
1514  }
1515 
1521  template <typename T>
1522  static void PinLight( sample& a, T b ) noexcept
1523  {
1524  sample fb = ToSample( b );
1525  a = (fb > 0.5) ? pcl::Max( a, 2*(fb - 0.5) ) : pcl::Min( a, 2*fb );
1526  }
1527 
1533  template <typename T>
1534  static void Exclusion( sample& a, T b ) noexcept
1535  {
1536  a = pcl::Range( 0.5 - 2*(a - 0.5)*(ToSample( b ) - 0.5), 0.0, 1.0 );
1537  }
1538 
1539  // -------------------------------------------------------------------------
1540 
1541  IMPLEMENT_TRANSFER_OPERATIONS
1542 };
1543 
1544 // ----------------------------------------------------------------------------
1545 
1556 class PCL_CLASS ComplexPixelTraits : public GenericPixelTraits<Complex<float> >
1557 {
1558 public:
1559 
1564 
1569 
1575 
1576  static constexpr int BitsPerSample() noexcept
1577  {
1578  return sizeof( component ) << 3;
1579  }
1580 
1585  static constexpr bool IsFloatSample() noexcept
1586  {
1587  return false;
1588  }
1589 
1594  static constexpr bool IsComplexSample() noexcept
1595  {
1596  return true;
1597  }
1598 
1605  static constexpr const char* SampleFormat() noexcept
1606  {
1607  return "Complex32";
1608  }
1609 
1615  static sample MaxSampleValue() noexcept
1616  {
1617  return sample( component( 1 ) );
1618  }
1619 
1626  static sample LowestSampleValue() noexcept
1627  {
1628  return sample( component( std::numeric_limits<component>::lowest() ) );
1629  }
1630 
1637  static sample HighestSampleValue() noexcept
1638  {
1639  return sample( component( std::numeric_limits<component>::max() ) );
1640  }
1641 
1645  template <typename T>
1646  static sample FloatToSample( T x ) noexcept
1647  {
1648  return sample( component( x ) );
1649  }
1650 
1651  template <typename T>
1652  static sample FloatToSample( sample x ) noexcept
1653  {
1654  return sample( x );
1655  }
1656 
1660  static sample ToSample( uint8 x ) noexcept
1661  {
1662 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
1663  return sample( component( x )/uint8_max );
1664 #else
1665  return sample( component( pFLUT8[x] ) );
1666 #endif
1667  }
1668 
1672  static sample ToSample( int8 x ) noexcept
1673  {
1674 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
1675  return sample( (component( x ) - int8_min)/uint8_max );
1676 #else
1677  return sample( component( pFLUT8[int( x ) - int8_min] ) );
1678 #endif
1679  }
1680 
1684  static sample ToSample( uint16 x ) noexcept
1685  {
1686 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
1687  return sample( component( x )/uint16_max );
1688 #else
1689  return sample( component( pFLUT16[x] ) );
1690 #endif
1691  }
1692 
1696  static sample ToSample( int16 x ) noexcept
1697  {
1698 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
1699  return sample( (component( x ) - int16_min)/uint16_max );
1700 #else
1701  return sample( component( pFLUT16[int( x ) - int16_min] ) );
1702 #endif
1703  }
1704 
1708  static sample ToSample( uint32 x ) noexcept
1709  {
1710  return sample( component( double( x )/uint32_max ) );
1711  }
1712 
1716  static sample ToSample( int32 x ) noexcept
1717  {
1718  return sample( component( (double( x ) - int32_min)/uint32_max ) );
1719  }
1720 
1724  static sample ToSample( float x ) noexcept
1725  {
1726  return sample( component( x ) );
1727  }
1728 
1732  static sample ToSample( double x ) noexcept
1733  {
1734  return sample( component( x ) );
1735  }
1736 
1740  template <typename T>
1741  static sample ToSample( const Complex<T>& x ) noexcept
1742  {
1743  return sample( x );
1744  }
1745 
1749  static void FromSample( uint8& a, sample b ) noexcept
1750  {
1751  a = uint8( RoundInt( pcl::Abs( b )*uint8_max ) );
1752  }
1753 
1757  static void FromSampl( int8& a, sample b ) noexcept
1758  {
1759  a = int8( RoundInt( pcl::Abs( b )*uint8_max ) + int8_min );
1760  }
1761 
1765  static void FromSample( uint16& a, sample b ) noexcept
1766  {
1767  a = uint16( RoundInt( pcl::Abs( b )*uint16_max ) );
1768  }
1769 
1773  static void FromSample( int16& a, sample b ) noexcept
1774  {
1775  a = int16( RoundInt( pcl::Abs( b )*uint16_max ) + int16_min );
1776  }
1777 
1781  static void FromSample( uint32& a, sample b ) noexcept
1782  {
1783  a = uint32( Round( double( pcl::Abs( b ) )*uint32_max ) );
1784  }
1785 
1789  static void FromSample( int32& a, sample b ) noexcept
1790  {
1791  a = int32( Round( double( pcl::Abs( b ) )*uint32_max ) + int32_min );
1792  }
1793 
1797  static void FromSample( float& a, sample b ) noexcept
1798  {
1799  a = float( pcl::Abs( b ) );
1800  }
1801 
1805  static void FromSample( double& a, sample b ) noexcept
1806  {
1807  a = double( pcl::Abs( b ) );
1808  }
1809 
1813  template <typename T>
1814  static void FromSample( Complex<T>& a, sample b ) noexcept
1815  {
1816  a = Complex<T>( b );
1817  }
1818 
1823  template <typename T>
1824  static void Mov( sample& a, T b ) noexcept
1825  {
1826  a = ToSample( b );
1827  }
1828 
1833  template <typename T>
1834  static void Add( sample& a, T b ) noexcept
1835  {
1836  a += ToSample( b );
1837  }
1838 
1843  template <typename T>
1844  static void Sub( sample& a, T b ) noexcept
1845  {
1846  a -= ToSample( b );
1847  }
1848 
1853  template <typename T>
1854  static void Mul( sample& a, T b ) noexcept
1855  {
1856  a *= ToSample( b );
1857  }
1858 
1863  template <typename T>
1864  static void Div( sample& a, T b ) noexcept
1865  {
1866  a /= ToSample( b );
1867  }
1868 
1873  template <typename T>
1874  static void Pow( sample& a, T b ) noexcept
1875  {
1876  a = pcl::Pow( a, ToSample( b ) );
1877  }
1878 
1883  template <typename T>
1884  static void Dif( sample& a, T b ) noexcept
1885  {
1886  a = pcl::Abs( a - ToSample( b ) );
1887  }
1888 
1893  template <typename T>
1894  static void Min( sample& a, T b ) noexcept
1895  {
1896  a = pcl::Min( a, ToSample( b ) );
1897  }
1898 
1903  template <typename T>
1904  static void Max( sample& a, T b ) noexcept
1905  {
1906  a = pcl::Max( a, ToSample( b ) );
1907  }
1908 
1915  template <typename T>
1916  static void Or( sample& a, T b ) noexcept
1917  {
1918  uint8 ia; FromSample( ia, a );
1919  uint8 ib; FromSample( ib, ToSample( b ) );
1920  a = ToSample( uint8( ia | ib ) );
1921  }
1922 
1929  template <typename T>
1930  static void Nor( sample& a, T b ) noexcept
1931  {
1932  uint8 ia; FromSample( ia, a );
1933  uint8 ib; FromSample( ib, ToSample( b ) );
1934  a = ToSample( uint8( ~(ia | ib) ) );
1935  }
1936 
1943  template <typename T>
1944  static void And( sample& a, T b ) noexcept
1945  {
1946  uint8 ia; FromSample( ia, a );
1947  uint8 ib; FromSample( ib, ToSample( b ) );
1948  a = ToSample( uint8( ia & ib ) );
1949  }
1950 
1956  static void Not( sample& a ) noexcept
1957  {
1958  uint8 ia; FromSample( ia, a );
1959  a = ToSample( uint8( ~ia ) );
1960  }
1961 
1968  template <typename T>
1969  static void Not( sample& a, T b ) noexcept
1970  {
1971  uint8 ib; FromSample( ib, ToSample( b ) );
1972  a = ToSample( uint8( ~ib ) );
1973  }
1974 
1981  template <typename T>
1982  static void Nand( sample& a, T b ) noexcept
1983  {
1984  uint8 ia; FromSample( ia, a );
1985  uint8 ib; FromSample( ib, ToSample( b ) );
1986  a = ToSample( uint8( ~(ia & ib) ) );
1987  }
1988 
1995  template <typename T>
1996  static void Xor( sample& a, T b ) noexcept
1997  {
1998  uint8 ia; FromSample( ia, a );
1999  uint8 ib; FromSample( ib, ToSample( b ) );
2000  a = ToSample( uint8( ia ^ ib ) );
2001  }
2002 
2009  template <typename T>
2010  static void Xnor( sample& a, T b ) noexcept
2011  {
2012  uint8 ia; FromSample( ia, a );
2013  uint8 ib; FromSample( ib, ToSample( b ) );
2014  a = ToSample( uint8( ~(ia ^ ib) ) );
2015  }
2016 
2022  template <typename T>
2023  static void ColorBurn( sample& a, T b ) noexcept
2024  {
2025  float fa; FromSample( fa, a );
2026  float fb; FromSample( fb, ToSample( b ) );
2027  a = ToSample( 1 - pcl::Min( (1 - fa)/pcl::Max( EPSILON_F, fb ), 1.0F ) );
2028  }
2029 
2030  static void ColorBurn( sample& a, float b ) noexcept
2031  {
2032  float fa; FromSample( fa, a );
2033  a = ToSample( 1 - pcl::Min( (1 - fa)/pcl::Max( EPSILON_F, b ), 1.0F ) );
2034  }
2035 
2036  static void ColorBurn( sample& a, double b ) noexcept
2037  {
2038  double fa; FromSample( fa, a );
2039  a = ToSample( 1 - pcl::Min( (1 - fa)/pcl::Max( EPSILON_D, b ), 1.0 ) );
2040  }
2041 
2047  template <typename T>
2048  static void LinearBurn( sample& a, T b ) noexcept
2049  {
2050  float fa; FromSample( fa, a );
2051  float fb; FromSample( fb, ToSample( b ) );
2052  a = ToSample( fa + fb - 1 );
2053  }
2054 
2055  static void LinearBurn( sample& a, float b ) noexcept
2056  {
2057  float fa; FromSample( fa, a );
2058  a = ToSample( fa + b - 1 );
2059  }
2060 
2061  static void LinearBurn( sample& a, double b ) noexcept
2062  {
2063  double fa; FromSample( fa, a );
2064  a = ToSample( fa + b - 1 );
2065  }
2066 
2072  template <typename T>
2073  static void Screen( sample& a, T b ) noexcept
2074  {
2075  float fa; FromSample( fa, a );
2076  float fb; FromSample( fb, ToSample( b ) );
2077  a = ToSample( 1 - (1 - fa)*(1 - fb) );
2078  }
2079 
2080  static void Screen( sample& a, float b ) noexcept
2081  {
2082  float fa; FromSample( fa, a );
2083  a = ToSample( 1 - (1 - fa)*(1 - b) );
2084  }
2085 
2086  static void Screen( sample& a, double b ) noexcept
2087  {
2088  double fa; FromSample( fa, a );
2089  a = ToSample( 1 - (1 - fa)*(1 - b) );
2090  }
2091 
2097  template <typename T>
2098  static void ColorDodge( sample& a, T b ) noexcept
2099  {
2100  float fa; FromSample( fa, a );
2101  float fb; FromSample( fb, ToSample( b ) );
2102  a = ToSample( pcl::Min( fa/pcl::Max( EPSILON_F, 1 - fb ), 1.0F ) );
2103  }
2104 
2105  static void ColorDodge( sample& a, float b ) noexcept
2106  {
2107  float fa; FromSample( fa, a );
2108  a = ToSample( pcl::Min( fa/pcl::Max( EPSILON_F, 1 - b ), 1.0F ) );
2109  }
2110 
2111  static void ColorDodge( sample& a, double b ) noexcept
2112  {
2113  double fa; FromSample( fa, a );
2114  a = ToSample( pcl::Min( fa/pcl::Max( EPSILON_D, 1 - b ), 1.0 ) );
2115  }
2116 
2122  template <typename T>
2123  static void Overlay( sample& a, T b ) noexcept
2124  {
2125  float fa; FromSample( fa, a );
2126  float fb; FromSample( fb, ToSample( b ) );
2127  a = ToSample( (fa > 0.5F) ? 1 - ((1 - 2*(fa - 0.5F)) * (1 - fb)) : 2*a*fb );
2128  }
2129 
2130  static void Overlay( sample& a, float b ) noexcept
2131  {
2132  float fa; FromSample( fa, a );
2133  a = ToSample( (fa > 0.5F) ? 1 - ((1 - 2*(fa - 0.5F)) * (1 - b)) : 2*a*b );
2134  }
2135 
2136  static void Overlay( sample& a, double b ) noexcept
2137  {
2138  double fa; FromSample( fa, a );
2139  a = ToSample( (fa > 0.5) ? 1 - ((1 - 2*(fa - 0.5)) * (1 - b)) : 2*a*b );
2140  }
2141 
2147  template <typename T>
2148  static void SoftLight( sample& a, T b ) noexcept
2149  {
2150  float fa; FromSample( fa, a );
2151  float fb; FromSample( fb, ToSample( b ) );
2152  a = ToSample( (1 - 2*fb)*fa*fa + 2*fa*fb ); // Pegtop's formula
2153  }
2154 
2155  static void SoftLight( sample& a, float b ) noexcept
2156  {
2157  float fa; FromSample( fa, a );
2158  a = ToSample( (1 - 2*b)*fa*fa + 2*fa*b );
2159  }
2160 
2161  static void SoftLight( sample& a, double b ) noexcept
2162  {
2163  double fa; FromSample( fa, a );
2164  a = ToSample( (1 - 2*b)*fa*fa + 2*fa*b );
2165  }
2166 
2172  template <typename T>
2173  static void HardLight( sample& a, T b ) noexcept
2174  {
2175  float fa; FromSample( fa, a );
2176  float fb; FromSample( fb, ToSample( b ) );
2177  a = ToSample( (fb > 0.5F) ? 1 - (1 - fa)*(1 - 2*(fb - 0.5F)) : 2*fa*fb );
2178  }
2179 
2180  static void HardLight( sample& a, float b ) noexcept
2181  {
2182  float fa; FromSample( fa, a );
2183  a = ToSample( (b > 0.5F) ? 1 - (1 - fa)*(1 - 2*(b - 0.5F)) : 2*fa*b );
2184  }
2185 
2186  static void HardLight( sample& a, double b ) noexcept
2187  {
2188  double fa; FromSample( fa, a );
2189  a = ToSample( (b > 0.5) ? 1 - (1 - fa)*(1 - 2*(b - 0.5)) : 2*fa*b );
2190  }
2191 
2197  template <typename T>
2198  static void VividLight( sample& a, T b ) noexcept
2199  {
2200  float fa; FromSample( fa, a );
2201  float fb; FromSample( fb, ToSample( b ) );
2202  a = ToSample( (fb < 0.5F) ? pcl::Max( 0.0F, 1 - (1 - fa)/pcl::Max( EPSILON_F, 2*fb ) ) : pcl::Min( fa/pcl::Max( EPSILON_F, 2*(1 - fb) ), 1.0F ) );
2203  }
2204 
2205  static void VividLight( sample& a, float b ) noexcept
2206  {
2207  float fa; FromSample( fa, a );
2208  a = ToSample( (b < 0.5F) ? pcl::Max( 0.0F, 1 - (1 - fa)/pcl::Max( EPSILON_F, 2*b ) ) : pcl::Min( fa/pcl::Max( EPSILON_F, 2*(1 - b) ), 1.0F ) );
2209  }
2210 
2211  static void VividLight( sample& a, double b ) noexcept
2212  {
2213  double fa; FromSample( fa, a );
2214  a = ToSample( (b < 0.5) ? pcl::Max( 0.0, 1 - (1 - fa)/pcl::Max( EPSILON_D, 2*b ) ) : pcl::Min( fa/pcl::Max( EPSILON_D, 2*(1 - b) ), 1.0 ) );
2215  }
2216 
2222  template <typename T>
2223  static void LinearLight( sample& a, T b ) noexcept
2224  {
2225  float fa; FromSample( fa, a );
2226  float fb; FromSample( fb, ToSample( b ) );
2227  a = ToSample( pcl::Range( fa + 2*fb - 1, 0.0F, 1.0F ) );
2228  }
2229 
2230  static void LinearLight( sample& a, float b ) noexcept
2231  {
2232  float fa; FromSample( fa, a );
2233  a = ToSample( pcl::Range( fa + 2*b - 1, 0.0F, 1.0F ) );
2234  }
2235 
2236  static void LinearLight( sample& a, double b ) noexcept
2237  {
2238  double fa; FromSample( fa, a );
2239  a = ToSample( pcl::Range( fa + 2*b - 1, 0.0, 1.0 ) );
2240  }
2241 
2247  template <typename T>
2248  static void PinLight( sample& a, T b ) noexcept
2249  {
2250  float fa; FromSample( fa, a );
2251  float fb; FromSample( fb, ToSample( b ) );
2252  a = ToSample( (fb > 0.5F) ? pcl::Max( fa, 2*(fb - 0.5F) ) : pcl::Min( fa, 2*fb ) );
2253  }
2254 
2255  static void PinLight( sample& a, float b ) noexcept
2256  {
2257  float fa; FromSample( fa, a );
2258  a = ToSample( (b > 0.5F) ? pcl::Max( fa, 2*(b - 0.5F) ) : pcl::Min( fa, 2*b ) );
2259  }
2260 
2261  static void PinLight( sample& a, double b ) noexcept
2262  {
2263  double fa; FromSample( fa, a );
2264  a = ToSample( (b > 0.5) ? pcl::Max( fa, 2*(b - 0.5) ) : pcl::Min( fa, 2*b ) );
2265  }
2266 
2272  template <typename T>
2273  static void Exclusion( sample& a, T b ) noexcept
2274  {
2275  float fa; FromSample( fa, a );
2276  float fb; FromSample( fb, ToSample( b ) );
2277  a = ToSample( pcl::Range( 0.5F - 2*(fa - 0.5F)*(fb - 0.5F), 0.0F, 1.0F ) );
2278  }
2279 
2280  static void Exclusion( sample& a, float b ) noexcept
2281  {
2282  float fa; FromSample( fa, a );
2283  a = ToSample( pcl::Range( 0.5F - 2*(fa - 0.5F)*(b - 0.5F), 0.0F, 1.0F ) );
2284  }
2285 
2286  static void Exclusion( sample& a, double b ) noexcept
2287  {
2288  double fa; FromSample( fa, a );
2289  a = ToSample( pcl::Range( 0.5 - 2*(fa - 0.5)*(b - 0.5), 0.0, 1.0 ) );
2290  }
2291 
2292  // -------------------------------------------------------------------------
2293 
2294  IMPLEMENT_TRANSFER_OPERATIONS
2295 };
2296 
2297 // ----------------------------------------------------------------------------
2298 
2309 class PCL_CLASS DComplexPixelTraits : public GenericPixelTraits<Complex<double> >
2310 {
2311 public:
2312 
2317 
2322 
2328 
2331  static constexpr int BitsPerSample() noexcept
2332  {
2333  return sizeof( component ) << 3;
2334  }
2335 
2340  static constexpr bool IsFloatSample() noexcept
2341  {
2342  return false;
2343  }
2344 
2349  static constexpr bool IsComplexSample() noexcept
2350  {
2351  return true;
2352  }
2353 
2360  static constexpr const char* SampleFormat() noexcept
2361  {
2362  return "Complex64";
2363  }
2364 
2370  static sample MaxSampleValue() noexcept
2371  {
2372  return sample( component( 1 ) );
2373  }
2374 
2381  static sample LowestSampleValue() noexcept
2382  {
2383  return sample( component( std::numeric_limits<component>::lowest() ) );
2384  }
2385 
2392  static sample HighestSampleValue() noexcept
2393  {
2394  return sample( component( std::numeric_limits<component>::max() ) );
2395  }
2396 
2400  template <typename T>
2401  static sample FloatToSample( T x ) noexcept
2402  {
2403  return sample( component( x ) );
2404  }
2405 
2406  template <typename T>
2407  static sample FloatToSample( sample x ) noexcept
2408  {
2409  return sample( x );
2410  }
2411 
2415  static sample ToSample( uint8 x ) noexcept
2416  {
2417 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
2418  return sample( component( x )/uint8_max );
2419 #else
2420  return sample( component( pDLUT8[x] ) );
2421 #endif
2422  }
2423 
2427  static sample ToSample( int8 x ) noexcept
2428  {
2429 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
2430  return sample( (component( x ) - int8_min)/uint8_max );
2431 #else
2432  return sample( component( pDLUT8[int( x ) - int8_min] ) );
2433 #endif
2434  }
2435 
2439  static sample ToSample( uint16 x ) noexcept
2440  {
2441 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
2442  return sample( component( x )/uint16_max );
2443 #else
2444  return sample( component( pDLUT16[x] ) );
2445 #endif
2446  }
2447 
2451  static sample ToSample( int16 x ) noexcept
2452  {
2453 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
2454  return sample( (component( x ) - int16_min)/uint16_max );
2455 #else
2456  return sample( component( pDLUT16[int( x ) - int16_min] ) );
2457 #endif
2458  }
2459 
2463  static sample ToSample( uint32 x ) noexcept
2464  {
2465  return sample( component( x )/uint32_max );
2466  }
2467 
2471  static sample ToSample( int32 x ) noexcept
2472  {
2473  return sample( (component( x ) - int32_min)/uint32_max );
2474  }
2475 
2479  static sample ToSample( float x ) noexcept
2480  {
2481  return sample( component( x ) );
2482  }
2483 
2487  static sample ToSample( double x ) noexcept
2488  {
2489  return sample( component( x ) );
2490  }
2491 
2495  template <typename T>
2496  static sample ToSample( const Complex<T>& x ) noexcept
2497  {
2498  return sample( x );
2499  }
2500 
2504  static void FromSample( uint8& a, sample b ) noexcept
2505  {
2506  a = uint8( RoundInt( pcl::Abs( b )*uint8_max ) );
2507  }
2508 
2512  static void FromSample( int8& a, sample b ) noexcept
2513  {
2514  a = int8( RoundInt( pcl::Abs( b )*uint8_max ) + int8_min );
2515  }
2516 
2520  static void FromSample( uint16& a, sample b ) noexcept
2521  {
2522  a = uint16( RoundInt( pcl::Abs( b )*uint16_max ) );
2523  }
2524 
2528  static void FromSample( int16& a, sample b ) noexcept
2529  {
2530  a = int16( RoundInt( pcl::Abs( b )*uint16_max ) + int16_min );
2531  }
2532 
2536  static void FromSample( uint32& a, sample b ) noexcept
2537  {
2538  a = uint32( Round( component( pcl::Abs( b ) )*uint32_max ) );
2539  }
2540 
2544  static void FromSample( int32& a, sample b ) noexcept
2545  {
2546  a = int32( Round( component( pcl::Abs( b ) )*uint32_max ) + int32_min );
2547  }
2548 
2552  static void FromSample( float& a, sample b ) noexcept
2553  {
2554  a = float( pcl::Abs( b ) );
2555  }
2556 
2560  static void FromSample( double& a, sample b ) noexcept
2561  {
2562  a = double( pcl::Abs( b ) );
2563  }
2564 
2568  template <typename T>
2569  static void FromSample( Complex<T>& a, sample b ) noexcept
2570  {
2571  a = Complex<T>( b );
2572  }
2573 
2578  template <typename T>
2579  static void Mov( sample& a, T b ) noexcept
2580  {
2581  a = ToSample( b );
2582  }
2583 
2588  template <typename T>
2589  static void Add( sample& a, T b ) noexcept
2590  {
2591  a += ToSample( b );
2592  }
2593 
2598  template <typename T>
2599  static void Sub( sample& a, T b ) noexcept
2600  {
2601  a -= ToSample( b );
2602  }
2603 
2608  template <typename T>
2609  static void Mul( sample& a, T b ) noexcept
2610  {
2611  a *= ToSample( b );
2612  }
2613 
2618  template <typename T>
2619  static void Div( sample& a, T b ) noexcept
2620  {
2621  a /= ToSample( b );
2622  }
2623 
2628  template <typename T>
2629  static void Pow( sample& a, T b ) noexcept
2630  {
2631  a = pcl::Pow( a, ToSample( b ) );
2632  }
2633 
2638  template <typename T>
2639  static void Dif( sample& a, T b ) noexcept
2640  {
2641  a = pcl::Abs( a - ToSample( b ) );
2642  }
2643 
2648  template <typename T>
2649  static void Min( sample& a, T b ) noexcept
2650  {
2651  a = pcl::Min( a, ToSample( b ) );
2652  }
2653 
2658  template <typename T>
2659  static void Max( sample& a, T b ) noexcept
2660  {
2661  a = pcl::Max( a, ToSample( b ) );
2662  }
2663 
2670  template <typename T>
2671  static void Or( sample& a, T b ) noexcept
2672  {
2673  uint8 ia; FromSample( ia, a );
2674  uint8 ib; FromSample( ib, ToSample( b ) );
2675  a = ToSample( uint8( ia | ib ) );
2676  }
2677 
2684  template <typename T>
2685  static void Nor( sample& a, T b ) noexcept
2686  {
2687  uint8 ia; FromSample( ia, a );
2688  uint8 ib; FromSample( ib, ToSample( b ) );
2689  a = ToSample( uint8( ~(ia | ib) ) );
2690  }
2691 
2698  template <typename T>
2699  static void And( sample& a, T b ) noexcept
2700  {
2701  uint8 ia; FromSample( ia, a );
2702  uint8 ib; FromSample( ib, ToSample( b ) );
2703  a = ToSample( uint8( ia & ib ) );
2704  }
2705 
2711  static void Not( sample& a ) noexcept
2712  {
2713  uint8 ia; FromSample( ia, a );
2714  a = ToSample( uint8( ~ia ) );
2715  }
2716 
2723  template <typename T>
2724  static void Not( sample& a, T b ) noexcept
2725  {
2726  uint8 ib; FromSample( ib, ToSample( b ) );
2727  a = ToSample( uint8( ~ib ) );
2728  }
2729 
2736  template <typename T>
2737  static void Nand( sample& a, T b ) noexcept
2738  {
2739  uint8 ia; FromSample( ia, a );
2740  uint8 ib; FromSample( ib, ToSample( b ) );
2741  a = ToSample( uint8( ~(ia & ib) ) );
2742  }
2743 
2750  template <typename T>
2751  static void Xor( sample& a, T b ) noexcept
2752  {
2753  uint8 ia; FromSample( ia, a );
2754  uint8 ib; FromSample( ib, ToSample( b ) );
2755  a = ToSample( uint8( ia ^ ib ) );
2756  }
2757 
2764  template <typename T>
2765  static void Xnor( sample& a, T b ) noexcept
2766  {
2767  uint8 ia; FromSample( ia, a );
2768  uint8 ib; FromSample( ib, ToSample( b ) );
2769  a = ToSample( uint8( ~(ia ^ ib) ) );
2770  }
2771 
2777  template <typename T>
2778  static void ColorBurn( sample& a, T b ) noexcept
2779  {
2780  double fa; FromSample( fa, a );
2781  double fb; FromSample( fb, ToSample( b ) );
2782  a = ToSample( 1 - pcl::Min( (1 - fa)/pcl::Max( EPSILON_D, fb ), 1.0 ) );
2783  }
2784 
2785  static void ColorBurn( sample& a, float b ) noexcept
2786  {
2787  double fa; FromSample( fa, a );
2788  a = ToSample( 1 - pcl::Min( (1 - fa)/pcl::Max( EPSILON_D, double( b ) ), 1.0 ) );
2789  }
2790 
2791  static void ColorBurn( sample& a, double b ) noexcept
2792  {
2793  double fa; FromSample( fa, a );
2794  a = ToSample( 1 - pcl::Min( (1 - fa)/pcl::Max( EPSILON_D, b ), 1.0 ) );
2795  }
2796 
2802  template <typename T>
2803  static void LinearBurn( sample& a, T b ) noexcept
2804  {
2805  double fa; FromSample( fa, a );
2806  double fb; FromSample( fb, ToSample( b ) );
2807  a = ToSample( fa + fb - 1 );
2808  }
2809 
2810  static void LinearBurn( sample& a, float b ) noexcept
2811  {
2812  double fa; FromSample( fa, a );
2813  a = ToSample( fa + double( b ) - 1 );
2814  }
2815 
2816  static void LinearBurn( sample& a, double b ) noexcept
2817  {
2818  double fa; FromSample( fa, a );
2819  a = ToSample( fa + b - 1 );
2820  }
2821 
2827  template <typename T>
2828  static void Screen( sample& a, T b ) noexcept
2829  {
2830  double fa; FromSample( fa, a );
2831  double fb; FromSample( fb, ToSample( b ) );
2832  a = ToSample( 1 - (1 - fa)*(1 - fb) );
2833  }
2834 
2835  static void Screen( sample& a, float b ) noexcept
2836  {
2837  double fa; FromSample( fa, a );
2838  a = ToSample( 1 - (1 - fa)*(1 - double( b )) );
2839  }
2840 
2841  static void Screen( sample& a, double b ) noexcept
2842  {
2843  double fa; FromSample( fa, a );
2844  a = ToSample( 1 - (1 - fa)*(1 - b) );
2845  }
2846 
2852  template <typename T>
2853  static void ColorDodge( sample& a, T b ) noexcept
2854  {
2855  double fa; FromSample( fa, a );
2856  double fb; FromSample( fb, ToSample( b ) );
2857  a = ToSample( pcl::Min( fa/pcl::Max( EPSILON_D, 1 - fb ), 1.0 ) );
2858  }
2859 
2860  static void ColorDodge( sample& a, float b ) noexcept
2861  {
2862  double fa; FromSample( fa, a );
2863  a = ToSample( pcl::Min( fa/pcl::Max( EPSILON_D, 1 - double( b ) ), 1.0 ) );
2864  }
2865 
2866  static void ColorDodge( sample& a, double b ) noexcept
2867  {
2868  double fa; FromSample( fa, a );
2869  a = ToSample( pcl::Min( fa/pcl::Max( EPSILON_D, 1 - b ), 1.0 ) );
2870  }
2871 
2877  template <typename T>
2878  static void Overlay( sample& a, T b ) noexcept
2879  {
2880  double fa; FromSample( fa, a );
2881  double fb; FromSample( fb, ToSample( b ) );
2882  a = ToSample( (fa > 0.5) ? 1 - ((1 - 2*(fa - 0.5)) * (1 - fb)) : 2*a*fb );
2883  }
2884 
2885  static void Overlay( sample& a, float b ) noexcept
2886  {
2887  double fa; FromSample( fa, a );
2888  a = ToSample( (fa > 0.5) ? 1 - ((1 - 2*(fa - 0.5)) * (1 - double( b ))) : 2*a*double( b ) );
2889  }
2890 
2891  static void Overlay( sample& a, double b ) noexcept
2892  {
2893  double fa; FromSample( fa, a );
2894  a = ToSample( (fa > 0.5) ? 1 - ((1 - 2*(fa - 0.5)) * (1 - b)) : 2*a*b );
2895  }
2896 
2902  template <typename T>
2903  static void SoftLight( sample& a, T b ) noexcept
2904  {
2905  double fa; FromSample( fa, a );
2906  double fb; FromSample( fb, ToSample( b ) );
2907  a = ToSample( (1 - 2*fb)*fa*fa + 2*fa*fb ); // Pegtop's formula
2908  }
2909 
2910  static void SoftLight( sample& a, float b ) noexcept
2911  {
2912  double fa; FromSample( fa, a );
2913  double fb = double( b );
2914  a = ToSample( (1 - 2*fb)*fa*fa + 2*fa*fb );
2915  }
2916 
2917  static void SoftLight( sample& a, double b ) noexcept
2918  {
2919  double fa; FromSample( fa, a );
2920  a = ToSample( (1 - 2*b)*fa*fa + 2*fa*b );
2921  }
2922 
2928  template <typename T>
2929  static void HardLight( sample& a, T b ) noexcept
2930  {
2931  double fa; FromSample( fa, a );
2932  double fb; FromSample( fb, ToSample( b ) );
2933  a = ToSample( (fb > 0.5) ? 1 - (1 - fa)*(1 - 2*(fb - 0.5)) : 2*fa*fb );
2934  }
2935 
2936  static void HardLight( sample& a, float b ) noexcept
2937  {
2938  double fa; FromSample( fa, a );
2939  double fb = double( b );
2940  a = ToSample( (fb > 0.5) ? 1 - (1 - fa)*(1 - 2*(fb - 0.5)) : 2*fa*fb );
2941  }
2942 
2943  static void HardLight( sample& a, double b ) noexcept
2944  {
2945  double fa; FromSample( fa, a );
2946  a = ToSample( (b > 0.5) ? 1 - (1 - fa)*(1 - 2*(b - 0.5)) : 2*fa*b );
2947  }
2948 
2954  template <typename T>
2955  static void VividLight( sample& a, T b ) noexcept
2956  {
2957  double fa; FromSample( fa, a );
2958  double fb; FromSample( fb, ToSample( b ) );
2959  a = ToSample( (fb < 0.5) ? pcl::Max( 0.0, 1 - (1 - fa)/pcl::Max( EPSILON_D, 2*fb ) ) : pcl::Min( fa/pcl::Max( EPSILON_D, 2*(1 - fb) ), 1.0 ) );
2960  }
2961 
2962  static void VividLight( sample& a, float b ) noexcept
2963  {
2964  double fa; FromSample( fa, a );
2965  double fb = double( b );
2966  a = ToSample( (fb < 0.5) ? pcl::Max( 0.0, 1 - (1 - fa)/pcl::Max( EPSILON_D, 2*fb ) ) : pcl::Min( fa/pcl::Max( EPSILON_D, 2*(1 - fb) ), 1.0 ) );
2967  }
2968 
2969  static void VividLight( sample& a, double b ) noexcept
2970  {
2971  double fa; FromSample( fa, a );
2972  a = ToSample( (b < 0.5) ? pcl::Max( 0.0, 1 - (1 - fa)/pcl::Max( EPSILON_D, 2*b ) ) : pcl::Min( fa/pcl::Max( EPSILON_D, 2*(1 - b) ), 1.0 ) );
2973  }
2974 
2980  template <typename T>
2981  static void LinearLight( sample& a, T b ) noexcept
2982  {
2983  double fa; FromSample( fa, a );
2984  double fb; FromSample( fb, ToSample( b ) );
2985  a = ToSample( pcl::Range( fa + 2*fb - 1, 0.0, 1.0 ) );
2986  }
2987 
2988  static void LinearLight( sample& a, float b ) noexcept
2989  {
2990  double fa; FromSample( fa, a );
2991  double fb = double( b );
2992  a = ToSample( pcl::Range( fa + 2*fb - 1, 0.0, 1.0 ) );
2993  }
2994 
2995  static void LinearLight( sample& a, double b ) noexcept
2996  {
2997  double fa; FromSample( fa, a );
2998  a = ToSample( pcl::Range( fa + 2*b - 1, 0.0, 1.0 ) );
2999  }
3000 
3006  template <typename T>
3007  static void PinLight( sample& a, T b ) noexcept
3008  {
3009  double fa; FromSample( fa, a );
3010  double fb; FromSample( fb, ToSample( b ) );
3011  a = ToSample( (fb > 0.5) ? pcl::Max( fa, 2*(fb - 0.5) ) : pcl::Min( fa, 2*fb ) );
3012  }
3013 
3014  static void PinLight( sample& a, float b ) noexcept
3015  {
3016  double fa; FromSample( fa, a );
3017  double fb = double( b );
3018  a = ToSample( (fb > 0.5) ? pcl::Max( fa, 2*(fb - 0.5) ) : pcl::Min( fa, 2*fb ) );
3019  }
3020 
3021  static void PinLight( sample& a, double b ) noexcept
3022  {
3023  double fa; FromSample( fa, a );
3024  a = ToSample( (b > 0.5) ? pcl::Max( fa, 2*(b - 0.5) ) : pcl::Min( fa, 2*b ) );
3025  }
3026 
3032  template <typename T>
3033  static void Exclusion( sample& a, T b ) noexcept
3034  {
3035  double fa; FromSample( fa, a );
3036  double fb; FromSample( fb, ToSample( b ) );
3037  a = ToSample( pcl::Range( 0.5 - 2*(fa - 0.5)*(fb - 0.5), 0.0, 1.0 ) );
3038  }
3039 
3040  static void Exclusion( sample& a, float b ) noexcept
3041  {
3042  double fa; FromSample( fa, a );
3043  a = ToSample( pcl::Range( 0.5 - 2*(fa - 0.5)*(double( b ) - 0.5), 0.0, 1.0 ) );
3044  }
3045 
3046  static void Exclusion( sample& a, double b ) noexcept
3047  {
3048  double fa; FromSample( fa, a );
3049  a = ToSample( pcl::Range( 0.5 - 2*(fa - 0.5)*(b - 0.5), 0.0, 1.0 ) );
3050  }
3051 
3052  // -------------------------------------------------------------------------
3053 
3054  IMPLEMENT_TRANSFER_OPERATIONS
3055 };
3056 
3057 // ----------------------------------------------------------------------------
3058 
3069 class PCL_CLASS UInt8PixelTraits : public GenericPixelTraits<uint8>
3070 {
3071 public:
3072 
3077 
3082 
3089 
3094  static constexpr bool IsFloatSample() noexcept
3095  {
3096  return false;
3097  }
3098 
3103  static constexpr bool IsComplexSample() noexcept
3104  {
3105  return false;
3106  }
3107 
3114  static constexpr const char* SampleFormat() noexcept
3115  {
3116  return "UInt8";
3117  }
3118 
3124  static constexpr sample MaxSampleValue() noexcept
3125  {
3126  return uint8_max;
3127  }
3128 
3134  static constexpr sample LowestSampleValue() noexcept
3135  {
3136  return sample( 0 );
3137  }
3138 
3144  static constexpr sample HighestSampleValue() noexcept
3145  {
3146  return uint8_max;
3147  }
3148 
3152  template <typename T>
3153  static sample FloatToSample( T x ) noexcept
3154  {
3155 #ifdef __PCL_ENFORCE_PIXTRAITS_FLOAT_RANGE
3156  return sample( pcl::Range( Round( x ), T( 0 ), T( uint8_max ) ) );
3157 #else
3158  // ### N.B.: x must be in the range [0,uint8_max].
3159  return sample( RoundInt( x ) );
3160 #endif
3161  }
3162 
3166  static constexpr sample ToSample( uint8 x ) noexcept
3167  {
3168  return sample( x );
3169  }
3170 
3174  static constexpr sample ToSample( int8 x ) noexcept
3175  {
3176  return sample( int32( x ) - int32( int8_min ) );
3177  }
3178 
3182  static sample ToSample( uint16 x ) noexcept
3183  {
3184 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
3185  return sample( Round( double( x )*uint16_to_uint8 ) );
3186 #else
3187  return p8LUT16[x];
3188 #endif
3189  }
3190 
3194  static sample ToSample( int16 x ) noexcept
3195  {
3196 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
3197  return sample( Round( (double( x ) - int16_min)*uint16_to_uint8 ) );
3198 #else
3199  return p8LUT16[int( x ) - int16_min];
3200 #endif
3201  }
3202 
3206  static sample ToSample( uint32 x ) noexcept
3207  {
3208  return sample( Round( double( x )*uint32_to_uint8 ) );
3209  }
3210 
3214  static sample ToSample( int32 x ) noexcept
3215  {
3216  return sample( Round( (double( x ) - int32_min)*uint32_to_uint8 ) );
3217  }
3218 
3222  static sample ToSample( float x ) noexcept
3223  {
3224  return FloatToSample( x*uint8_max );
3225  }
3226 
3232  static sample ToSampleConstrained( float x ) noexcept
3233  {
3234  return FloatToSample( pcl::Range( x, 0.0F, 1.0F )*uint8_max );
3235  }
3236 
3240  static sample ToSample( double x ) noexcept
3241  {
3242  return FloatToSample( x*uint8_max );
3243  }
3244 
3250  static sample ToSampleConstrained( double x ) noexcept
3251  {
3252  return FloatToSample( pcl::Range( x, 0.0, 1.0 )*uint8_max );
3253  }
3254 
3258  template <typename T>
3259  static sample ToSample( const Complex<T>& x ) noexcept
3260  {
3261  return ToSample( pcl::Abs( x ) );
3262  }
3263 
3267  static void FromSample( uint8& a, sample b ) noexcept
3268  {
3269  a = uint8( b );
3270  }
3271 
3275  static void FromSample( int8& a, sample b ) noexcept
3276  {
3277  a = int8( int32( b ) + int32( int8_min ) );
3278  }
3279 
3283  static void FromSample( uint16& a, sample b ) noexcept
3284  {
3285 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
3286  a = uint16( b )*uint8_to_uint16;
3287 #else
3288  a = p16LUT8[b];
3289 #endif
3290  }
3291 
3295  static void FromSample( int16& a, sample b ) noexcept
3296  {
3297 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
3298  a = int16( int32( uint16( b )*uint8_to_uint16 ) + int32( int16_min ) );
3299 #else
3300  a = int16( int32( p16LUT8[b] ) + int32( int16_min ) );
3301 #endif
3302  }
3303 
3307  static void FromSample( uint32& a, sample b ) noexcept
3308  {
3309 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
3310  a = uint32( b )*uint8_to_uint32;
3311 #else
3312  a = p32LUT8[b];
3313 #endif
3314  }
3315 
3319  static void FromSample( int32& a, sample b ) noexcept
3320  {
3321 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
3322  a = int32( double( uint32( b )*uint8_to_uint32 ) + int32_min );
3323 #else
3324  a = int32( int64( p32LUT8[b] ) + int64( int32_min ) );
3325 #endif
3326  }
3327 
3331  static void FromSample( float& a, sample b ) noexcept
3332  {
3333 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
3334  a = float( b )/uint8_max;
3335 #else
3336  a = pFLUT8[b];
3337 #endif
3338  }
3339 
3343  static void FromSample( double& a, sample b ) noexcept
3344  {
3345 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
3346  a = double( b )/uint8_max;
3347 #else
3348  a = pDLUT8[b];
3349 #endif
3350  }
3351 
3355  template <typename T>
3356  static void FromSample( Complex<T>& a, sample b ) noexcept
3357  {
3358  typename Complex<T>::component c;
3359  FromSample( c, b );
3360  a = c;
3361  }
3362 
3367  template <typename T>
3368  static void Mov( sample& a, T b ) noexcept
3369  {
3370  a = ToSample( b );
3371  }
3372 
3377  template <typename T>
3378  static void Add( sample& a, T b ) noexcept
3379  {
3380  a = sample( pcl::Range( uint32( a ) + uint32( ToSample( b ) ),
3381  uint32( 0 ), uint32( uint8_max ) ) );
3382  }
3383 
3388  template <typename T>
3389  static void Sub( sample& a, T b ) noexcept
3390  {
3391  a = sample( pcl::Range( int32( a ) - int32( ToSample( b ) ),
3392  int32( 0 ), int32( uint8_max ) ) );
3393  }
3394 
3399  template <typename T>
3400  static void Mul( sample& a, T b ) noexcept
3401  {
3402  float fa; FromSample( fa, a );
3403  float fb; FromSample( fb, ToSample( b ) );
3404  a = ToSample( fa * fb );
3405  }
3406 
3409  static void Mul( sample& a, float b ) noexcept
3410  {
3411  float fa; FromSample( fa, a );
3412  a = ToSample( fa * b );
3413  }
3414 
3417  static void Mul( sample& a, double b ) noexcept
3418  {
3419  double fa; FromSample( fa, a );
3420  a = ToSample( fa * b );
3421  }
3422 
3425  static void Mul( sample& a, pcl::Complex<float> b ) noexcept
3426  {
3427  float fa; FromSample( fa, a );
3428  a = ToSample( fa * b );
3429  }
3430 
3433  static void Mul( sample& a, pcl::Complex<double> b ) noexcept
3434  {
3435  double fa; FromSample( fa, a );
3436  a = ToSample( fa * b );
3437  }
3438 
3443  template <typename T>
3444  static void Div( sample& a, T b ) noexcept
3445  {
3446  a = FloatToSample( float( a )/float( ToSample( b ) ) );
3447  }
3448 
3451  static void Div( sample& a, float b ) noexcept
3452  {
3453  float fa; FromSample( fa, a );
3454  a = ToSample( fa / b );
3455  }
3456 
3459  static void Div( sample& a, double b ) noexcept
3460  {
3461  double fa; FromSample( fa, a );
3462  a = ToSample( fa / b );
3463  }
3464 
3467  static void Div( sample& a, pcl::Complex<float> b ) noexcept
3468  {
3469  float fa; FromSample( fa, a );
3470  a = ToSample( fa / b );
3471  }
3472 
3475  static void Div( sample& a, pcl::Complex<double> b ) noexcept
3476  {
3477  double fa; FromSample( fa, a );
3478  a = ToSample( fa / b );
3479  }
3480 
3485  template <typename T>
3486  static void Pow( sample& a, T b ) noexcept
3487  {
3488  float fa; FromSample( fa, a );
3489  float fb; FromSample( fb, ToSample( b ) );
3490  a = ToSample( pcl::Pow( fa, fb ) );
3491  }
3492 
3495  static void Pow( sample& a, float b ) noexcept
3496  {
3497  float fa; FromSample( fa, a );
3498  a = ToSample( pcl::Pow( fa, b ) );
3499  }
3500 
3503  static void Pow( sample& a, double b ) noexcept
3504  {
3505  double fa; FromSample( fa, a );
3506  a = ToSample( pcl::Pow( fa, b ) );
3507  }
3508 
3511  static void Pow( sample& a, pcl::Complex<float> b ) noexcept
3512  {
3513  float fa; FromSample( fa, a );
3514  a = ToSample( pcl::Pow( fa, b ) );
3515  }
3516 
3519  static void Pow( sample& a, pcl::Complex<double> b ) noexcept
3520  {
3521  double fa; FromSample( fa, a );
3522  a = ToSample( pcl::Pow( fa, b ) );
3523  }
3524 
3529  template <typename T>
3530  static void Dif( sample& a, T b ) noexcept
3531  {
3532  a = sample( pcl::Range( pcl::Abs( int32( a ) - int32( ToSample( b ) ) ),
3533  int32( 0 ), int32( uint8_max ) ) );
3534  }
3535 
3540  template <typename T>
3541  static void Min( sample& a, T b ) noexcept
3542  {
3543  a = pcl::Min( a, ToSample( b ) );
3544  }
3545 
3550  template <typename T>
3551  static void Max( sample& a, T b ) noexcept
3552  {
3553  a = pcl::Max( a, ToSample( b ) );
3554  }
3555 
3561  template <typename T>
3562  static void Or( sample& a, T b ) noexcept
3563  {
3564  a |= ToSample( b );
3565  }
3566 
3572  template <typename T>
3573  static void Nor( sample& a, T b ) noexcept
3574  {
3575  a = ~(a | ToSample( b ));
3576  }
3577 
3583  template <typename T>
3584  static void And( sample& a, T b ) noexcept
3585  {
3586  a &= ToSample( b );
3587  }
3588 
3592  static void Not( sample& a ) noexcept
3593  {
3594  a = sample( ~a );
3595  }
3596 
3602  template <typename T>
3603  static void Not( sample& a, T b ) noexcept
3604  {
3605  a = sample( ~ToSample( b ) );
3606  }
3607 
3613  template <typename T>
3614  static void Nand( sample& a, T b ) noexcept
3615  {
3616  a = sample( ~(a & ToSample( b )) );
3617  }
3618 
3624  template <typename T>
3625  static void Xor( sample& a, T b ) noexcept
3626  {
3627  a ^= ToSample( b );
3628  }
3629 
3635  template <typename T>
3636  static void Xnor( sample& a, T b ) noexcept
3637  {
3638  a = sample( ~(a ^ ToSample( b )) );
3639  }
3640 
3646  template <typename T>
3647  static void ColorBurn( sample& a, T b ) noexcept
3648  {
3649  float fa; FromSample( fa, a );
3650  float fb; FromSample( fb, ToSample( b ) );
3651  a = ToSample( 1 - pcl::Min( (1 - fa)/pcl::Max( EPSILON_F, fb ), 1.0F ) );
3652  }
3653 
3654  static void ColorBurn( sample& a, float b ) noexcept
3655  {
3656  float fa; FromSample( fa, a );
3657  a = ToSample( 1 - pcl::Min( (1 - fa)/pcl::Max( EPSILON_F, b ), 1.0F ) );
3658  }
3659 
3660  static void ColorBurn( sample& a, double b ) noexcept
3661  {
3662  double fa; FromSample( fa, a );
3663  a = ToSample( 1 - pcl::Min( (1 - fa)/pcl::Max( EPSILON_D, b ), 1.0 ) );
3664  }
3665 
3671  template <typename T>
3672  static void LinearBurn( sample& a, T b ) noexcept
3673  {
3674  float fa; FromSample( fa, a );
3675  float fb; FromSample( fb, ToSample( b ) );
3676  a = ToSample( fa + fb - 1 );
3677  }
3678 
3679  static void LinearBurn( sample& a, float b ) noexcept
3680  {
3681  float fa; FromSample( fa, a );
3682  a = ToSample( fa + b - 1 );
3683  }
3684 
3685  static void LinearBurn( sample& a, double b ) noexcept
3686  {
3687  double fa; FromSample( fa, a );
3688  a = ToSample( fa + b - 1 );
3689  }
3690 
3696  template <typename T>
3697  static void Screen( sample& a, T b ) noexcept
3698  {
3699  float fa; FromSample( fa, a );
3700  float fb; FromSample( fb, ToSample( b ) );
3701  a = ToSample( 1 - (1 - fa)*(1 - fb) );
3702  }
3703 
3704  static void Screen( sample& a, float b ) noexcept
3705  {
3706  float fa; FromSample( fa, a );
3707  a = ToSample( 1 - (1 - fa)*(1 - b) );
3708  }
3709 
3710  static void Screen( sample& a, double b ) noexcept
3711  {
3712  double fa; FromSample( fa, a );
3713  a = ToSample( 1 - (1 - fa)*(1 - b) );
3714  }
3715 
3721  template <typename T>
3722  static void ColorDodge( sample& a, T b ) noexcept
3723  {
3724  float fa; FromSample( fa, a );
3725  float fb; FromSample( fb, ToSample( b ) );
3726  a = ToSample( pcl::Min( fa/pcl::Max( EPSILON_F, 1 - fb ), 1.0F ) );
3727  }
3728 
3729  static void ColorDodge( sample& a, float b ) noexcept
3730  {
3731  float fa; FromSample( fa, a );
3732  a = ToSample( pcl::Min( fa/pcl::Max( EPSILON_F, 1 - b ), 1.0F ) );
3733  }
3734 
3735  static void ColorDodge( sample& a, double b ) noexcept
3736  {
3737  double fa; FromSample( fa, a );
3738  a = ToSample( pcl::Min( fa/pcl::Max( EPSILON_D, 1 - b ), 1.0 ) );
3739  }
3740 
3746  template <typename T>
3747  static void Overlay( sample& a, T b ) noexcept
3748  {
3749  float fa; FromSample( fa, a );
3750  float fb; FromSample( fb, ToSample( b ) );
3751  a = ToSample( (fa > 0.5F) ? 1 - ((1 - 2*(fa - 0.5F)) * (1 - fb)) : 2*a*fb );
3752  }
3753 
3754  static void Overlay( sample& a, float b ) noexcept
3755  {
3756  float fa; FromSample( fa, a );
3757  a = ToSample( (fa > 0.5F) ? 1 - ((1 - 2*(fa - 0.5F)) * (1 - b)) : 2*a*b );
3758  }
3759 
3760  static void Overlay( sample& a, double b ) noexcept
3761  {
3762  double fa; FromSample( fa, a );
3763  a = ToSample( (fa > 0.5) ? 1 - ((1 - 2*(fa - 0.5)) * (1 - b)) : 2*a*b );
3764  }
3765 
3771  template <typename T>
3772  static void SoftLight( sample& a, T b ) noexcept
3773  {
3774  float fa; FromSample( fa, a );
3775  float fb; FromSample( fb, ToSample( b ) );
3776  a = ToSample( (1 - 2*fb)*fa*fa + 2*fa*fb ); // Pegtop's formula
3777  }
3778 
3779  static void SoftLight( sample& a, float b ) noexcept
3780  {
3781  float fa; FromSample( fa, a );
3782  a = ToSample( (1 - 2*b)*fa*fa + 2*fa*b );
3783  }
3784 
3785  static void SoftLight( sample& a, double b ) noexcept
3786  {
3787  double fa; FromSample( fa, a );
3788  a = ToSample( (1 - 2*b)*fa*fa + 2*fa*b );
3789  }
3790 
3796  template <typename T>
3797  static void HardLight( sample& a, T b ) noexcept
3798  {
3799  float fa; FromSample( fa, a );
3800  float fb; FromSample( fb, ToSample( b ) );
3801  a = ToSample( (fb > 0.5F) ? 1 - (1 - fa)*(1 - 2*(fb - 0.5F)) : 2*fa*fb );
3802  }
3803 
3804  static void HardLight( sample& a, float b ) noexcept
3805  {
3806  float fa; FromSample( fa, a );
3807  a = ToSample( (b > 0.5F) ? 1 - (1 - fa)*(1 - 2*(b - 0.5F)) : 2*fa*b );
3808  }
3809 
3810  static void HardLight( sample& a, double b ) noexcept
3811  {
3812  double fa; FromSample( fa, a );
3813  a = ToSample( (b > 0.5) ? 1 - (1 - fa)*(1 - 2*(b - 0.5)) : 2*fa*b );
3814  }
3815 
3821  template <typename T>
3822  static void VividLight( sample& a, T b ) noexcept
3823  {
3824  float fa; FromSample( fa, a );
3825  float fb; FromSample( fb, ToSample( b ) );
3826  a = ToSample( (fb < 0.5F) ? pcl::Max( 0.0F, 1 - (1 - fa)/pcl::Max( EPSILON_F, 2*fb ) ) : pcl::Min( fa/pcl::Max( EPSILON_F, 2*(1 - fb) ), 1.0F ) );
3827  }
3828 
3829  static void VividLight( sample& a, float b ) noexcept
3830  {
3831  float fa; FromSample( fa, a );
3832  a = ToSample( (b < 0.5F) ? pcl::Max( 0.0F, 1 - (1 - fa)/pcl::Max( EPSILON_F, 2*b ) ) : pcl::Min( fa/pcl::Max( EPSILON_F, 2*(1 - b) ), 1.0F ) );
3833  }
3834 
3835  static void VividLight( sample& a, double b ) noexcept
3836  {
3837  double fa; FromSample( fa, a );
3838  a = ToSample( (b < 0.5) ? pcl::Max( 0.0, 1 - (1 - fa)/pcl::Max( EPSILON_D, 2*b ) ) : pcl::Min( fa/pcl::Max( EPSILON_D, 2*(1 - b) ), 1.0 ) );
3839  }
3840 
3846  template <typename T>
3847  static void LinearLight( sample& a, T b ) noexcept
3848  {
3849  float fa; FromSample( fa, a );
3850  float fb; FromSample( fb, ToSample( b ) );
3851  a = ToSample( pcl::Range( fa + 2*fb - 1, 0.0F, 1.0F ) );
3852  }
3853 
3854  static void LinearLight( sample& a, float b ) noexcept
3855  {
3856  float fa; FromSample( fa, a );
3857  a = ToSample( pcl::Range( fa + 2*b - 1, 0.0F, 1.0F ) );
3858  }
3859 
3860  static void LinearLight( sample& a, double b ) noexcept
3861  {
3862  double fa; FromSample( fa, a );
3863  a = ToSample( pcl::Range( fa + 2*b - 1, 0.0, 1.0 ) );
3864  }
3865 
3871  template <typename T>
3872  static void PinLight( sample& a, T b ) noexcept
3873  {
3874  float fa; FromSample( fa, a );
3875  float fb; FromSample( fb, ToSample( b ) );
3876  a = ToSample( (fb > 0.5F) ? pcl::Max( fa, 2*(fb - 0.5F) ) : pcl::Min( fa, 2*fb ) );
3877  }
3878 
3879  static void PinLight( sample& a, float b ) noexcept
3880  {
3881  float fa; FromSample( fa, a );
3882  a = ToSample( (b > 0.5F) ? pcl::Max( fa, 2*(b - 0.5F) ) : pcl::Min( fa, 2*b ) );
3883  }
3884 
3885  static void PinLight( sample& a, double b ) noexcept
3886  {
3887  double fa; FromSample( fa, a );
3888  a = ToSample( (b > 0.5) ? pcl::Max( fa, 2*(b - 0.5) ) : pcl::Min( fa, 2*b ) );
3889  }
3890 
3896  template <typename T>
3897  static void Exclusion( sample& a, T b ) noexcept
3898  {
3899  float fa; FromSample( fa, a );
3900  float fb; FromSample( fb, ToSample( b ) );
3901  a = ToSample( pcl::Range( 0.5F - 2*(fa - 0.5F)*(fb - 0.5F), 0.0F, 1.0F ) );
3902  }
3903 
3904  static void Exclusion( sample& a, float b ) noexcept
3905  {
3906  float fa; FromSample( fa, a );
3907  a = ToSample( pcl::Range( 0.5F - 2*(fa - 0.5F)*(b - 0.5F), 0.0F, 1.0F ) );
3908  }
3909 
3910  static void Exclusion( sample& a, double b ) noexcept
3911  {
3912  double fa; FromSample( fa, a );
3913  a = ToSample( pcl::Range( 0.5 - 2*(fa - 0.5)*(b - 0.5), 0.0, 1.0 ) );
3914  }
3915 
3916  // -------------------------------------------------------------------------
3917 
3918  IMPLEMENT_TRANSFER_OPERATIONS
3919 };
3920 
3921 // ----------------------------------------------------------------------------
3922 
3933 class PCL_CLASS UInt16PixelTraits : public GenericPixelTraits<uint16>
3934 {
3935 public:
3936 
3941 
3946 
3953 
3958  static constexpr bool IsFloatSample() noexcept
3959  {
3960  return false;
3961  }
3962 
3967  static constexpr bool IsComplexSample() noexcept
3968  {
3969  return false;
3970  }
3971 
3978  static constexpr const char* SampleFormat() noexcept
3979  {
3980  return "UInt16";
3981  }
3982 
3988  static constexpr sample MaxSampleValue() noexcept
3989  {
3990  return uint16_max;
3991  }
3992 
3998  static constexpr sample LowestSampleValue() noexcept
3999  {
4000  return sample( 0 );
4001  }
4002 
4008  static constexpr sample HighestSampleValue() noexcept
4009  {
4010  return uint16_max;
4011  }
4012 
4016  template <typename T>
4017  static sample FloatToSample( T x ) noexcept
4018  {
4019 #ifdef __PCL_ENFORCE_PIXTRAITS_FLOAT_RANGE
4020  return sample( pcl::Range( Round( x ), T( 0 ), T( uint16_max ) ) );
4021 #else
4022  // ### N.B.: x must be in the range [0,uint16_max].
4023  return sample( RoundInt( x ) );
4024 #endif
4025  }
4026 
4030  static sample ToSample( uint8 x ) noexcept
4031  {
4032 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
4033  return sample( x )*sample( uint8_to_uint16 );
4034 #else
4035  return p16LUT8[x];
4036 #endif
4037  }
4038 
4042  static sample ToSample( int8 x ) noexcept
4043  {
4044 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
4045  return sample( (int32( x ) - int32( int8_min ))*int32( uint8_to_uint16 ) );
4046 #else
4047  return p16LUT8[int( x ) - int( int8_min )];
4048 #endif
4049  }
4050 
4054  static constexpr sample ToSample( uint16 x ) noexcept
4055  {
4056  return sample( x );
4057  }
4058 
4062  static constexpr sample ToSample( int16 x ) noexcept
4063  {
4064  return sample( int32( x ) - int32( int16_min ) );
4065  }
4066 
4070  static sample ToSample( uint32 x ) noexcept
4071  {
4072  return sample( Round( double( x )*uint32_to_uint16 ) );
4073  }
4074 
4078  static sample ToSample( int32 x ) noexcept
4079  {
4080  return sample( Round( (double( x ) - int32_min)*uint32_to_uint16 ) );
4081  }
4082 
4086  static sample ToSample( float x ) noexcept
4087  {
4088  return FloatToSample( x*uint16_max );
4089  }
4090 
4096  static sample ToSampleConstrained( float x ) noexcept
4097  {
4098  return FloatToSample( pcl::Range( x, 0.0F, 1.0F )*uint16_max );
4099  }
4100 
4104  static sample ToSample( double x ) noexcept
4105  {
4106  return FloatToSample( x*uint16_max );
4107  }
4108 
4114  static sample ToSampleConstrained( double x ) noexcept
4115  {
4116  return FloatToSample( pcl::Range( x, 0.0, 1.0 )*uint16_max );
4117  }
4118 
4122  template <typename T>
4123  static constexpr sample ToSample( const Complex<T>& x ) noexcept
4124  {
4125  return ToSample( pcl::Abs( x ) );
4126  }
4127 
4131  static void FromSample( uint8& a, sample b ) noexcept
4132  {
4133 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
4134  a = uint8( Round( double( b )*uint16_to_uint8 ) );
4135 #else
4136  a = p8LUT16[b];
4137 #endif
4138  }
4139 
4143  static void FromSample( int8& a, sample b ) noexcept
4144  {
4145 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
4146  a = int8( Round( double( b )*uint16_to_uint8 ) + int8_min );
4147 #else
4148  a = int8( int( p8LUT16[b] ) + int( int8_min ) );
4149 #endif
4150  }
4151 
4155  static void FromSample( uint16& a, sample b ) noexcept
4156  {
4157  a = uint16( b );
4158  }
4159 
4163  static void FromSample( int16& a, sample b ) noexcept
4164  {
4165  a = int16( int32( b ) + int32( int16_min ) );
4166  }
4167 
4171  static void FromSample( uint32& a, sample b ) noexcept
4172  {
4173 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
4174  a = uint32( b )*uint16_to_uint32;
4175 #else
4176  a = p32LUT16[b];
4177 #endif
4178  }
4179 
4183  static void FromSample( int32& a, sample b ) noexcept
4184  {
4185 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
4186  a = int32( double( uint32( b )*uint16_to_uint32 ) + int32_min );
4187 #else
4188  a = int32( int64( p32LUT16[b] ) + int64( int32_min ) );
4189 #endif
4190  }
4191 
4195  static void FromSample( float& a, sample b ) noexcept
4196  {
4197 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
4198  a = float( b )/uint16_max;
4199 #else
4200  a = pFLUT16[b];
4201 #endif
4202  }
4203 
4207  static void FromSample( double& a, sample b ) noexcept
4208  {
4209 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
4210  a = double( b )/uint16_max;
4211 #else
4212  a = pDLUT16[b];
4213 #endif
4214  }
4215 
4219  template <typename T>
4220  static void FromSample( Complex<T>& a, sample b ) noexcept
4221  {
4222  typename Complex<T>::component c;
4223  FromSample( c, b );
4224  a = c;
4225  }
4226 
4231  template <typename T>
4232  static void Mov( sample& a, T b ) noexcept
4233  {
4234  a = ToSample( b );
4235  }
4236 
4241  template <typename T>
4242  static void Add( sample& a, T b ) noexcept
4243  {
4244  a = sample( pcl::Range( uint32( a ) + uint32( ToSample( b ) ),
4245  uint32( 0 ), uint32( uint16_max ) ) );
4246  }
4247 
4252  template <typename T>
4253  static void Sub( sample& a, T b ) noexcept
4254  {
4255  a = sample( pcl::Range( int32( a ) - int32( ToSample( b ) ),
4256  int32( 0 ), int32( uint16_max ) ) );
4257  }
4258 
4263  template <typename T>
4264  static void Mul( sample& a, T b ) noexcept
4265  {
4266  double fa; FromSample( fa, a );
4267  double fb; FromSample( fb, ToSample( b ) );
4268  a = ToSample( fa * fb );
4269  }
4270 
4273  static void Mul( sample& a, float b ) noexcept
4274  {
4275  double fa; FromSample( fa, a );
4276  a = ToSample( fa * b );
4277  }
4278 
4281  static void Mul( sample& a, double b ) noexcept
4282  {
4283  double fa; FromSample( fa, a );
4284  a = ToSample( fa * b );
4285  }
4286 
4289  static void Mul( sample& a, pcl::Complex<float> b ) noexcept
4290  {
4291  double fa; FromSample( fa, a );
4292  a = ToSample( fa * b );
4293  }
4294 
4297  static void Mul( sample& a, pcl::Complex<double> b ) noexcept
4298  {
4299  double fa; FromSample( fa, a );
4300  a = ToSample( fa * b );
4301  }
4302 
4307  template <typename T>
4308  static void Div( sample& a, T b ) noexcept
4309  {
4310  a = FloatToSample( double( a )/double( ToSample( b ) ) );
4311  }
4312 
4315  static void Div( sample& a, float b ) noexcept
4316  {
4317  double fa; FromSample( fa, a );
4318  a = ToSample( fa / b );
4319  }
4320 
4323  static void Div( sample& a, double b ) noexcept
4324  {
4325  double fa; FromSample( fa, a );
4326  a = ToSample( fa / b );
4327  }
4328 
4331  static void Div( sample& a, pcl::Complex<float> b ) noexcept
4332  {
4333  double fa; FromSample( fa, a );
4334  a = ToSample( fa / b );
4335  }
4336 
4339  static void Div( sample& a, pcl::Complex<double> b ) noexcept
4340  {
4341  double fa; FromSample( fa, a );
4342  a = ToSample( fa / b );
4343  }
4344 
4349  template <typename T>
4350  static void Pow( sample& a, T b ) noexcept
4351  {
4352  double fa; FromSample( fa, a );
4353  double fb; FromSample( fb, ToSample( b ) );
4354  a = ToSample( pcl::Pow( fa, fb ) );
4355  }
4356 
4359  static void Pow( sample& a, float b ) noexcept
4360  {
4361  double fa; FromSample( fa, a );
4362  a = ToSample( pcl::Pow( fa, double( b ) ) );
4363  }
4364 
4367  static void Pow( sample& a, double b ) noexcept
4368  {
4369  double fa; FromSample( fa, a );
4370  a = ToSample( pcl::Pow( fa, b ) );
4371  }
4372 
4375  static void Pow( sample& a, pcl::Complex<float> b ) noexcept
4376  {
4377  double fa; FromSample( fa, a );
4378  a = ToSample( pcl::Pow( fa, pcl::Complex<double>( b ) ) );
4379  }
4380 
4383  static void Pow( sample& a, pcl::Complex<double> b ) noexcept
4384  {
4385  double fa; FromSample( fa, a );
4386  a = ToSample( pcl::Pow( fa, b ) );
4387  }
4388 
4393  template <typename T>
4394  static void Dif( sample& a, T b ) noexcept
4395  {
4396  a = sample( pcl::Range( pcl::Abs( int32( a ) - int32( ToSample( b ) ) ),
4397  int32( 0 ), int32( uint16_max ) ) );
4398  }
4399 
4404  template <typename T>
4405  static void Min( sample& a, T b ) noexcept
4406  {
4407  a = pcl::Min( a, ToSample( b ) );
4408  }
4409 
4414  template <typename T>
4415  static void Max( sample& a, T b ) noexcept
4416  {
4417  a = pcl::Max( a, ToSample( b ) );
4418  }
4419 
4425  template <typename T>
4426  static void Or( sample& a, T b ) noexcept
4427  {
4428  a |= ToSample( b );
4429  }
4430 
4436  template <typename T>
4437  static void Nor( sample& a, T b ) noexcept
4438  {
4439  a = ~(a | ToSample( b ));
4440  }
4441 
4447  template <typename T>
4448  static void And( sample& a, T b ) noexcept
4449  {
4450  a &= ToSample( b );
4451  }
4452 
4456  static void Not( sample& a ) noexcept
4457  {
4458  a = sample( ~a );
4459  }
4460 
4466  template <typename T>
4467  static void Not( sample& a, T b ) noexcept
4468  {
4469  a = sample( ~ToSample( b ) );
4470  }
4471 
4477  template <typename T>
4478  static void Nand( sample& a, T b ) noexcept
4479  {
4480  a = sample( ~(a & ToSample( b )) );
4481  }
4482 
4488  template <typename T>
4489  static void Xor( sample& a, T b ) noexcept
4490  {
4491  a ^= ToSample( b );
4492  }
4493 
4499  template <typename T>
4500  static void Xnor( sample& a, T b ) noexcept
4501  {
4502  a = sample( ~(a ^ ToSample( b )) );
4503  }
4504 
4510  template <typename T>
4511  static void ColorBurn( sample& a, T b ) noexcept
4512  {
4513  float fa; FromSample( fa, a );
4514  float fb; FromSample( fb, ToSample( b ) );
4515  a = ToSample( 1 - pcl::Min( (1 - fa)/pcl::Max( EPSILON_F, fb ), 1.0F ) );
4516  }
4517 
4518  static void ColorBurn( sample& a, float b ) noexcept
4519  {
4520  float fa; FromSample( fa, a );
4521  a = ToSample( 1 - pcl::Min( (1 - fa)/pcl::Max( EPSILON_F, b ), 1.0F ) );
4522  }
4523 
4524  static void ColorBurn( sample& a, double b ) noexcept
4525  {
4526  double fa; FromSample( fa, a );
4527  a = ToSample( 1 - pcl::Min( (1 - fa)/pcl::Max( EPSILON_D, b ), 1.0 ) );
4528  }
4529 
4535  template <typename T>
4536  static void LinearBurn( sample& a, T b ) noexcept
4537  {
4538  float fa; FromSample( fa, a );
4539  float fb; FromSample( fb, ToSample( b ) );
4540  a = ToSample( fa + fb - 1 );
4541  }
4542 
4543  static void LinearBurn( sample& a, float b ) noexcept
4544  {
4545  float fa; FromSample( fa, a );
4546  a = ToSample( fa + b - 1 );
4547  }
4548 
4549  static void LinearBurn( sample& a, double b ) noexcept
4550  {
4551  double fa; FromSample( fa, a );
4552  a = ToSample( fa + b - 1 );
4553  }
4554 
4560  template <typename T>
4561  static void Screen( sample& a, T b ) noexcept
4562  {
4563  float fa; FromSample( fa, a );
4564  float fb; FromSample( fb, ToSample( b ) );
4565  a = ToSample( 1 - (1 - fa)*(1 - fb) );
4566  }
4567 
4568  static void Screen( sample& a, float b ) noexcept
4569  {
4570  float fa; FromSample( fa, a );
4571  a = ToSample( 1 - (1 - fa)*(1 - b) );
4572  }
4573 
4574  static void Screen( sample& a, double b ) noexcept
4575  {
4576  double fa; FromSample( fa, a );
4577  a = ToSample( 1 - (1 - fa)*(1 - b) );
4578  }
4579 
4585  template <typename T>
4586  static void ColorDodge( sample& a, T b ) noexcept
4587  {
4588  float fa; FromSample( fa, a );
4589  float fb; FromSample( fb, ToSample( b ) );
4590  a = ToSample( pcl::Min( fa/pcl::Max( EPSILON_F, 1 - fb ), 1.0F ) );
4591  }
4592 
4593  static void ColorDodge( sample& a, float b ) noexcept
4594  {
4595  float fa; FromSample( fa, a );
4596  a = ToSample( pcl::Min( fa/pcl::Max( EPSILON_F, 1 - b ), 1.0F ) );
4597  }
4598 
4599  static void ColorDodge( sample& a, double b ) noexcept
4600  {
4601  double fa; FromSample( fa, a );
4602  a = ToSample( pcl::Min( fa/pcl::Max( EPSILON_D, 1 - b ), 1.0 ) );
4603  }
4604 
4610  template <typename T>
4611  static void Overlay( sample& a, T b ) noexcept
4612  {
4613  float fa; FromSample( fa, a );
4614  float fb; FromSample( fb, ToSample( b ) );
4615  a = ToSample( (fa > 0.5F) ? 1 - ((1 - 2*(fa - 0.5F)) * (1 - fb)) : 2*a*fb );
4616  }
4617 
4618  static void Overlay( sample& a, float b ) noexcept
4619  {
4620  float fa; FromSample( fa, a );
4621  a = ToSample( (fa > 0.5F) ? 1 - ((1 - 2*(fa - 0.5F)) * (1 - b)) : 2*a*b );
4622  }
4623 
4624  static void Overlay( sample& a, double b ) noexcept
4625  {
4626  double fa; FromSample( fa, a );
4627  a = ToSample( (fa > 0.5) ? 1 - ((1 - 2*(fa - 0.5)) * (1 - b)) : 2*a*b );
4628  }
4629 
4635  template <typename T>
4636  static void SoftLight( sample& a, T b ) noexcept
4637  {
4638  float fa; FromSample( fa, a );
4639  float fb; FromSample( fb, ToSample( b ) );
4640  a = ToSample( (1 - 2*fb)*fa*fa + 2*fa*fb ); // Pegtop's formula
4641  }
4642 
4643  static void SoftLight( sample& a, float b ) noexcept
4644  {
4645  float fa; FromSample( fa, a );
4646  a = ToSample( (1 - 2*b)*fa*fa + 2*fa*b );
4647  }
4648 
4649  static void SoftLight( sample& a, double b ) noexcept
4650  {
4651  double fa; FromSample( fa, a );
4652  a = ToSample( (1 - 2*b)*fa*fa + 2*fa*b );
4653  }
4654 
4660  template <typename T>
4661  static void HardLight( sample& a, T b ) noexcept
4662  {
4663  float fa; FromSample( fa, a );
4664  float fb; FromSample( fb, ToSample( b ) );
4665  a = ToSample( (fb > 0.5F) ? 1 - (1 - fa)*(1 - 2*(fb - 0.5F)) : 2*fa*fb );
4666  }
4667 
4668  static void HardLight( sample& a, float b ) noexcept
4669  {
4670  float fa; FromSample( fa, a );
4671  a = ToSample( (b > 0.5F) ? 1 - (1 - fa)*(1 - 2*(b - 0.5F)) : 2*fa*b );
4672  }
4673 
4674  static void HardLight( sample& a, double b ) noexcept
4675  {
4676  double fa; FromSample( fa, a );
4677  a = ToSample( (b > 0.5) ? 1 - (1 - fa)*(1 - 2*(b - 0.5)) : 2*fa*b );
4678  }
4679 
4685  template <typename T>
4686  static void VividLight( sample& a, T b ) noexcept
4687  {
4688  float fa; FromSample( fa, a );
4689  float fb; FromSample( fb, ToSample( b ) );
4690  a = ToSample( (fb < 0.5F) ? pcl::Max( 0.0F, 1 - (1 - fa)/pcl::Max( EPSILON_F, 2*fb ) ) : pcl::Min( fa/pcl::Max( EPSILON_F, 2*(1 - fb) ), 1.0F ) );
4691  }
4692 
4693  static void VividLight( sample& a, float b ) noexcept
4694  {
4695  float fa; FromSample( fa, a );
4696  a = ToSample( (b < 0.5F) ? pcl::Max( 0.0F, 1 - (1 - fa)/pcl::Max( EPSILON_F, 2*b ) ) : pcl::Min( fa/pcl::Max( EPSILON_F, 2*(1 - b) ), 1.0F ) );
4697  }
4698 
4699  static void VividLight( sample& a, double b ) noexcept
4700  {
4701  double fa; FromSample( fa, a );
4702  a = ToSample( (b < 0.5) ? pcl::Max( 0.0, 1 - (1 - fa)/pcl::Max( EPSILON_D, 2*b ) ) : pcl::Min( fa/pcl::Max( EPSILON_D, 2*(1 - b) ), 1.0 ) );
4703  }
4704 
4710  template <typename T>
4711  static void LinearLight( sample& a, T b ) noexcept
4712  {
4713  float fa; FromSample( fa, a );
4714  float fb; FromSample( fb, ToSample( b ) );
4715  a = ToSample( pcl::Range( fa + 2*fb - 1, 0.0F, 1.0F ) );
4716  }
4717 
4718  static void LinearLight( sample& a, float b ) noexcept
4719  {
4720  float fa; FromSample( fa, a );
4721  a = ToSample( pcl::Range( fa + 2*b - 1, 0.0F, 1.0F ) );
4722  }
4723 
4724  static void LinearLight( sample& a, double b ) noexcept
4725  {
4726  double fa; FromSample( fa, a );
4727  a = ToSample( pcl::Range( fa + 2*b - 1, 0.0, 1.0 ) );
4728  }
4729 
4735  template <typename T>
4736  static void PinLight( sample& a, T b ) noexcept
4737  {
4738  float fa; FromSample( fa, a );
4739  float fb; FromSample( fb, ToSample( b ) );
4740  a = ToSample( (fb > 0.5F) ? pcl::Max( fa, 2*(fb - 0.5F) ) : pcl::Min( fa, 2*fb ) );
4741  }
4742 
4743  static void PinLight( sample& a, float b ) noexcept
4744  {
4745  float fa; FromSample( fa, a );
4746  a = ToSample( (b > 0.5F) ? pcl::Max( fa, 2*(b - 0.5F) ) : pcl::Min( fa, 2*b ) );
4747  }
4748 
4749  static void PinLight( sample& a, double b ) noexcept
4750  {
4751  double fa; FromSample( fa, a );
4752  a = ToSample( (b > 0.5) ? pcl::Max( fa, 2*(b - 0.5) ) : pcl::Min( fa, 2*b ) );
4753  }
4754 
4760  template <typename T>
4761  static void Exclusion( sample& a, T b ) noexcept
4762  {
4763  float fa; FromSample( fa, a );
4764  float fb; FromSample( fb, ToSample( b ) );
4765  a = ToSample( pcl::Range( 0.5F - 2*(fa - 0.5F)*(fb - 0.5F), 0.0F, 1.0F ) );
4766  }
4767 
4768  static void Exclusion( sample& a, float b ) noexcept
4769  {
4770  float fa; FromSample( fa, a );
4771  a = ToSample( pcl::Range( 0.5F - 2*(fa - 0.5F)*(b - 0.5F), 0.0F, 1.0F ) );
4772  }
4773 
4774  static void Exclusion( sample& a, double b ) noexcept
4775  {
4776  double fa; FromSample( fa, a );
4777  a = ToSample( pcl::Range( 0.5 - 2*(fa - 0.5)*(b - 0.5), 0.0, 1.0 ) );
4778  }
4779 
4780  // -------------------------------------------------------------------------
4781 
4782  IMPLEMENT_TRANSFER_OPERATIONS
4783 };
4784 
4785 // ----------------------------------------------------------------------------
4786 
4797 class PCL_CLASS UInt32PixelTraits : public GenericPixelTraits<uint32>
4798 {
4799 public:
4800 
4805 
4810 
4817 
4822  static constexpr bool IsFloatSample() noexcept
4823  {
4824  return false;
4825  }
4826 
4831  static constexpr bool IsComplexSample() noexcept
4832  {
4833  return false;
4834  }
4835 
4842  static constexpr const char* SampleFormat() noexcept
4843  {
4844  return "UInt32";
4845  }
4846 
4852  static constexpr sample MaxSampleValue() noexcept
4853  {
4854  return uint32_max;
4855  }
4856 
4862  static constexpr sample LowestSampleValue() noexcept
4863  {
4864  return sample( 0 );
4865  }
4866 
4872  static constexpr sample HighestSampleValue() noexcept
4873  {
4874  return uint32_max;
4875  }
4876 
4880  template <typename T>
4881  static sample FloatToSample( T x ) noexcept
4882  {
4883 #ifdef __PCL_ENFORCE_PIXTRAITS_FLOAT_RANGE
4884  return sample( pcl::Range( Round( x ), T( 0 ), T( uint32_max ) ) );
4885 #else
4886  // ### N.B.: x must be in the range [0,uint32_max].
4887  return sample( RoundI64( x ) );
4888 #endif
4889  }
4890 
4894  static sample ToSample( uint8 x ) noexcept
4895  {
4896 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
4897  return sample( x )*sample( uint8_to_uint32 );
4898 #else
4899  return p32LUT8[x];
4900 #endif
4901  }
4902 
4906  static sample ToSample( int8 x ) noexcept
4907  {
4908 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
4909  return sample( uint32( int32( x ) - int32( int8_min ) )*uint8_to_uint32 );
4910 #else
4911  return p32LUT8[int( x ) - int( int8_min )];
4912 #endif
4913  }
4914 
4918  static sample ToSample( uint16 x ) noexcept
4919  {
4920 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
4921  return sample( x )*sample( uint16_to_uint32 );
4922 #else
4923  return p32LUT16[x];
4924 #endif
4925  }
4926 
4930  static sample ToSample( int16 x ) noexcept
4931  {
4932 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
4933  return sample( uint32( int32( x ) - int32( int16_min ) )*uint16_to_uint32 );
4934 #else
4935  return p32LUT16[int( x ) - int( int16_min )];
4936 #endif
4937  }
4938 
4942  static constexpr sample ToSample( uint32 x ) noexcept
4943  {
4944  return sample( x );
4945  }
4946 
4950  static constexpr sample ToSample( int32 x ) noexcept
4951  {
4952  return sample( double( x ) - double( int32_min ) );
4953  }
4954 
4958  static sample ToSample( float x ) noexcept
4959  {
4960  return FloatToSample( double( x )*uint32_max );
4961  }
4962 
4968  static sample ToSampleConstrained( float x ) noexcept
4969  {
4970  return FloatToSample( pcl::Range( double( x ), 0.0, 1.0 )*uint32_max );
4971  }
4972 
4976  static sample ToSample( double x ) noexcept
4977  {
4978  return FloatToSample( x*uint32_max );
4979  }
4980 
4986  static sample ToSampleConstrained( double x ) noexcept
4987  {
4988  return FloatToSample( pcl::Range( x, 0.0, 1.0 )*uint32_max );
4989  }
4990 
4994  template <typename T>
4995  static sample ToSample( const Complex<T>& x ) noexcept
4996  {
4997  return ToSample( pcl::Abs( x ) );
4998  }
4999 
5003  static void FromSample( uint8& a, sample b ) noexcept
5004  {
5005  a = uint8( RoundInt( double( b )*uint32_to_uint8 ) );
5006  }
5007 
5011  static void FromSample( int8& a, sample b ) noexcept
5012  {
5013  a = int8( RoundInt( double( b )*uint32_to_uint8 ) + int8_min );
5014  }
5015 
5019  static void FromSample( uint16& a, sample b ) noexcept
5020  {
5021  a = uint16( RoundInt( double( b )*uint32_to_uint16 ) );
5022  }
5023 
5027  static void FromSample( int16& a, sample b ) noexcept
5028  {
5029  a = int16( RoundInt( double( b )*uint32_to_uint16 ) + int16_min );
5030  }
5031 
5035  static void FromSample( uint32& a, sample b ) noexcept
5036  {
5037  a = uint32( b );
5038  }
5039 
5043  static void FromSample( int32& a, sample b ) noexcept
5044  {
5045  a = TruncInt( double( b ) + int32_min );
5046  }
5047 
5051  static void FromSample( float& a, sample b ) noexcept
5052  {
5053  a = float( double( b )/uint32_max );
5054  }
5055 
5059  static void FromSample( double& a, sample b ) noexcept
5060  {
5061  a = double( b )/uint32_max;
5062  }
5063 
5067  template <typename T>
5068  static void FromSample( Complex<T>& a, sample b ) noexcept
5069  {
5070  typename Complex<T>::component c;
5071  FromSample( c, b );
5072  a = c;
5073  }
5074 
5079  template <typename T>
5080  static void Mov( sample& a, T b ) noexcept
5081  {
5082  a = ToSample( b );
5083  }
5084 
5089  template <typename T>
5090  static void Add( sample& a, T b ) noexcept
5091  {
5092  a = sample( pcl::Range( double( a ) + double( ToSample( b ) ),
5093  0.0, double( uint32_max ) ) );
5094  }
5095 
5100  template <typename T>
5101  static void Sub( sample& a, T b ) noexcept
5102  {
5103  a = sample( pcl::Range( double( a ) - double( ToSample( b ) ),
5104  0.0, double( uint32_max ) ) );
5105  }
5106 
5111  template <typename T>
5112  static void Mul( sample& a, T b ) noexcept
5113  {
5114  double fa; FromSample( fa, a );
5115  double fb; FromSample( fb, ToSample( b ) );
5116  a = ToSample( fa * fb );
5117  }
5118 
5121  static void Mul( sample& a, float b ) noexcept
5122  {
5123  double fa; FromSample( fa, a );
5124  a = ToSample( fa * b );
5125  }
5126 
5129  static void Mul( sample& a, double b ) noexcept
5130  {
5131  double fa; FromSample( fa, a );
5132  a = ToSample( fa * b );
5133  }
5134 
5137  static void Mul( sample& a, pcl::Complex<float> b ) noexcept
5138  {
5139  double fa; FromSample( fa, a );
5140  a = ToSample( fa * b );
5141  }
5142 
5145  static void Mul( sample& a, pcl::Complex<double> b ) noexcept
5146  {
5147  double fa; FromSample( fa, a );
5148  a = ToSample( fa * b );
5149  }
5150 
5155  template <typename T>
5156  static void Div( sample& a, T b ) noexcept
5157  {
5158  a = FloatToSample( double( a )/double( ToSample( b ) ) );
5159  }
5160 
5163  static void Div( sample& a, float b ) noexcept
5164  {
5165  double fa; FromSample( fa, a );
5166  a = ToSample( fa / b );
5167  }
5168 
5171  static void Div( sample& a, double b ) noexcept
5172  {
5173  double fa; FromSample( fa, a );
5174  a = ToSample( fa / b );
5175  }
5176 
5179  static void Div( sample& a, pcl::Complex<float> b ) noexcept
5180  {
5181  double fa; FromSample( fa, a );
5182  a = ToSample( fa / b );
5183  }
5184 
5187  static void Div( sample& a, pcl::Complex<double> b ) noexcept
5188  {
5189  double fa; FromSample( fa, a );
5190  a = ToSample( fa / b );
5191  }
5192 
5197  template <typename T>
5198  static void Pow( sample& a, T b ) noexcept
5199  {
5200  double fa; FromSample( fa, a );
5201  double fb; FromSample( fb, ToSample( b ) );
5202  a = ToSample( pcl::Pow( fa, fb ) );
5203  }
5204 
5207  static void Pow( sample& a, float b ) noexcept
5208  {
5209  double fa; FromSample( fa, a );
5210  a = ToSample( pcl::Pow( fa, double( b ) ) );
5211  }
5212 
5215  static void Pow( sample& a, double b ) noexcept
5216  {
5217  double fa; FromSample( fa, a );
5218  a = ToSample( pcl::Pow( fa, b ) );
5219  }
5220 
5223  static void Pow( sample& a, pcl::Complex<float> b ) noexcept
5224  {
5225  double fa; FromSample( fa, a );
5226  a = ToSample( pcl::Pow( fa, pcl::Complex<double>( b ) ) );
5227  }
5228 
5231  static void Pow( sample& a, pcl::Complex<double> b ) noexcept
5232  {
5233  double fa; FromSample( fa, a );
5234  a = ToSample( pcl::Pow( fa, b ) );
5235  }
5236 
5241  template <typename T>
5242  static void Dif( sample& a, T b ) noexcept
5243  {
5244  a = sample( pcl::Range( pcl::Abs( double( a ) - double( ToSample( b ) ) ),
5245  0.0, double( uint32_max ) ) );
5246  }
5247 
5252  template <typename T>
5253  static void Min( sample& a, T b ) noexcept
5254  {
5255  a = sample( pcl::Min( a, ToSample( b ) ) );
5256  }
5257 
5262  template <typename T>
5263  static void Max( sample& a, T b ) noexcept
5264  {
5265  a = sample( pcl::Max( a, ToSample( b ) ) );
5266  }
5267 
5273  template <typename T>
5274  static void Or( sample& a, T b ) noexcept
5275  {
5276  a |= ToSample( b );
5277  }
5278 
5284  template <typename T>
5285  static void Nor( sample& a, T b ) noexcept
5286  {
5287  a = ~(a | ToSample( b ));
5288  }
5289 
5295  template <typename T>
5296  static void And( sample& a, T b ) noexcept
5297  {
5298  a &= ToSample( b );
5299  }
5300 
5304  static void Not( sample& a ) noexcept
5305  {
5306  a = sample( ~a );
5307  }
5308 
5314  template <typename T>
5315  static void Not( sample& a, T b ) noexcept
5316  {
5317  a = sample( ~ToSample( b ) );
5318  }
5319 
5325  template <typename T>
5326  static void Nand( sample& a, T b ) noexcept
5327  {
5328  a = sample( ~(a & ToSample( b )) );
5329  }
5330 
5336  template <typename T>
5337  static void Xor( sample& a, T b ) noexcept
5338  {
5339  a ^= ToSample( b );
5340  }
5341 
5347  template <typename T>
5348  static void Xnor( sample& a, T b ) noexcept
5349  {
5350  a = sample( ~(a ^ ToSample( b )) );
5351  }
5352 
5358  template <typename T>
5359  static void ColorBurn( sample& a, T b ) noexcept
5360  {
5361  double fa; FromSample( fa, a );
5362  double fb; FromSample( fb, ToSample( b ) );
5363  a = ToSample( 1 - pcl::Min( (1 - fa)/pcl::Max( EPSILON_D, fb ), 1.0 ) );
5364  }
5365 
5366  static void ColorBurn( sample& a, float b ) noexcept
5367  {
5368  double fa; FromSample( fa, a );
5369  a = ToSample( 1 - pcl::Min( (1 - fa)/pcl::Max( EPSILON_D, double( b ) ), 1.0 ) );
5370  }
5371 
5372  static void ColorBurn( sample& a, double b ) noexcept
5373  {
5374  double fa; FromSample( fa, a );
5375  a = ToSample( 1 - pcl::Min( (1 - fa)/pcl::Max( EPSILON_D, b ), 1.0 ) );
5376  }
5377 
5383  template <typename T>
5384  static void LinearBurn( sample& a, T b ) noexcept
5385  {
5386  double fa; FromSample( fa, a );
5387  double fb; FromSample( fb, ToSample( b ) );
5388  a = ToSample( fa + fb - 1 );
5389  }
5390 
5391  static void LinearBurn( sample& a, float b ) noexcept
5392  {
5393  double fa; FromSample( fa, a );
5394  a = ToSample( fa + double( b ) - 1 );
5395  }
5396 
5397  static void LinearBurn( sample& a, double b ) noexcept
5398  {
5399  double fa; FromSample( fa, a );
5400  a = ToSample( fa + b - 1 );
5401  }
5402 
5408  template <typename T>
5409  static void Screen( sample& a, T b ) noexcept
5410  {
5411  double fa; FromSample( fa, a );
5412  double fb; FromSample( fb, ToSample( b ) );
5413  a = ToSample( 1 - (1 - fa)*(1 - fb) );
5414  }
5415 
5416  static void Screen( sample& a, float b ) noexcept
5417  {
5418  double fa; FromSample( fa, a );
5419  a = ToSample( 1 - (1 - fa)*(1 - double( b )) );
5420  }
5421 
5422  static void Screen( sample& a, double b ) noexcept
5423  {
5424  double fa; FromSample( fa, a );
5425  a = ToSample( 1 - (1 - fa)*(1 - b) );
5426  }
5427 
5433  template <typename T>
5434  static void ColorDodge( sample& a, T b ) noexcept
5435  {
5436  double fa; FromSample( fa, a );
5437  double fb; FromSample( fb, ToSample( b ) );
5438  a = ToSample( pcl::Min( fa/pcl::Max( EPSILON_D, 1 - fb ), 1.0 ) );
5439  }
5440 
5441  static void ColorDodge( sample& a, float b ) noexcept
5442  {
5443  double fa; FromSample( fa, a );
5444  a = ToSample( pcl::Min( fa/pcl::Max( EPSILON_D, 1 - double( b ) ), 1.0 ) );
5445  }
5446 
5447  static void ColorDodge( sample& a, double b ) noexcept
5448  {
5449  double fa; FromSample( fa, a );
5450  a = ToSample( pcl::Min( fa/pcl::Max( EPSILON_D, 1 - b ), 1.0 ) );
5451  }
5452 
5458  template <typename T>
5459  static void Overlay( sample& a, T b ) noexcept
5460  {
5461  double fa; FromSample( fa, a );
5462  double fb; FromSample( fb, ToSample( b ) );
5463  a = ToSample( (fa > 0.5) ? 1 - ((1 - 2*(fa - 0.5)) * (1 - fb)) : 2*a*fb );
5464  }
5465 
5466  static void Overlay( sample& a, float b ) noexcept
5467  {
5468  double fa; FromSample( fa, a );
5469  a = ToSample( (fa > 0.5) ? 1 - ((1 - 2*(fa - 0.5)) * (1 - double( b ))) : 2*a*double( b ) );
5470  }
5471 
5472  static void Overlay( sample& a, double b ) noexcept
5473  {
5474  double fa; FromSample( fa, a );
5475  a = ToSample( (fa > 0.5) ? 1 - ((1 - 2*(fa - 0.5)) * (1 - b)) : 2*a*b );
5476  }
5477 
5483  template <typename T>
5484  static void SoftLight( sample& a, T b ) noexcept
5485  {
5486  double fa; FromSample( fa, a );
5487  double fb; FromSample( fb, ToSample( b ) );
5488  a = ToSample( (1 - 2*fb)*fa*fa + 2*fa*fb ); // Pegtop's formula
5489  }
5490 
5491  static void SoftLight( sample& a, float b ) noexcept
5492  {
5493  double fa; FromSample( fa, a );
5494  double fb = double( b );
5495  a = ToSample( (1 - 2*fb)*fa*fa + 2*fa*fb );
5496  }
5497 
5498  static void SoftLight( sample& a, double b ) noexcept
5499  {
5500  double fa; FromSample( fa, a );
5501  a = ToSample( (1 - 2*b)*fa*fa + 2*fa*b );
5502  }
5503 
5509  template <typename T>
5510  static void HardLight( sample& a, T b ) noexcept
5511  {
5512  double fa; FromSample( fa, a );
5513  double fb; FromSample( fb, ToSample( b ) );
5514  a = ToSample( (fb > 0.5) ? 1 - (1 - fa)*(1 - 2*(fb - 0.5)) : 2*fa*fb );
5515  }
5516 
5517  static void HardLight( sample& a, float b ) noexcept
5518  {
5519  double fa; FromSample( fa, a );
5520  double fb = double( b );
5521  a = ToSample( (fb > 0.5) ? 1 - (1 - fa)*(1 - 2*(fb - 0.5)) : 2*fa*fb );
5522  }
5523 
5524  static void HardLight( sample& a, double b ) noexcept
5525  {
5526  double fa; FromSample( fa, a );
5527  a = ToSample( (b > 0.5) ? 1 - (1 - fa)*(1 - 2*(b - 0.5)) : 2*fa*b );
5528  }
5529 
5535  template <typename T>
5536  static void VividLight( sample& a, T b ) noexcept
5537  {
5538  double fa; FromSample( fa, a );
5539  double fb; FromSample( fb, ToSample( b ) );
5540  a = ToSample( (fb < 0.5) ? pcl::Max( 0.0, 1 - (1 - fa)/pcl::Max( EPSILON_D, 2*fb ) ) : pcl::Min( fa/pcl::Max( EPSILON_D, 2*(1 - fb) ), 1.0 ) );
5541  }
5542 
5543  static void VividLight( sample& a, float b ) noexcept
5544  {
5545  double fa; FromSample( fa, a );
5546  double fb = double( b );
5547  a = ToSample( (fb < 0.5) ? pcl::Max( 0.0, 1 - (1 - fa)/pcl::Max( EPSILON_D, 2*fb ) ) : pcl::Min( fa/pcl::Max( EPSILON_D, 2*(1 - fb) ), 1.0 ) );
5548  }
5549 
5550  static void VividLight( sample& a, double b ) noexcept
5551  {
5552  double fa; FromSample( fa, a );
5553  a = ToSample( (b < 0.5) ? pcl::Max( 0.0, 1 - (1 - fa)/pcl::Max( EPSILON_D, 2*b ) ) : pcl::Min( fa/pcl::Max( EPSILON_D, 2*(1 - b) ), 1.0 ) );
5554  }
5555 
5561  template <typename T>
5562  static void LinearLight( sample& a, T b ) noexcept
5563  {
5564  double fa; FromSample( fa, a );
5565  double fb; FromSample( fb, ToSample( b ) );
5566  a = ToSample( pcl::Range( fa + 2*fb - 1, 0.0, 1.0 ) );
5567  }
5568 
5569  static void LinearLight( sample& a, float b ) noexcept
5570  {
5571  double fa; FromSample( fa, a );
5572  double fb = double( b );
5573  a = ToSample( pcl::Range( fa + 2*fb - 1, 0.0, 1.0 ) );
5574  }
5575 
5576  static void LinearLight( sample& a, double b ) noexcept
5577  {
5578  double fa; FromSample( fa, a );
5579  a = ToSample( pcl::Range( fa + 2*b - 1, 0.0, 1.0 ) );
5580  }
5581 
5587  template <typename T>
5588  static void PinLight( sample& a, T b ) noexcept
5589  {
5590  double fa; FromSample( fa, a );
5591  double fb; FromSample( fb, ToSample( b ) );
5592  a = ToSample( (fb > 0.5) ? pcl::Max( fa, 2*(fb - 0.5) ) : pcl::Min( fa, 2*fb ) );
5593  }
5594 
5595  static void PinLight( sample& a, float b ) noexcept
5596  {
5597  double fa; FromSample( fa, a );
5598  double fb = double( b );
5599  a = ToSample( (fb > 0.5) ? pcl::Max( fa, 2*(fb - 0.5) ) : pcl::Min( fa, 2*fb ) );
5600  }
5601 
5602  static void PinLight( sample& a, double b ) noexcept
5603  {
5604  double fa; FromSample( fa, a );
5605  a = ToSample( (b > 0.5) ? pcl::Max( fa, 2*(b - 0.5) ) : pcl::Min( fa, 2*b ) );
5606  }
5607 
5613  template <typename T>
5614  static void Exclusion( sample& a, T b ) noexcept
5615  {
5616  double fa; FromSample( fa, a );
5617  double fb; FromSample( fb, ToSample( b ) );
5618  a = ToSample( pcl::Range( 0.5 - 2*(fa - 0.5)*(fb - 0.5), 0.0, 1.0 ) );
5619  }
5620 
5621  static void Exclusion( sample& a, float b ) noexcept
5622  {
5623  double fa; FromSample( fa, a );
5624  a = ToSample( pcl::Range( 0.5 - 2*(fa - 0.5)*(double( b ) - 0.5), 0.0, 1.0 ) );
5625  }
5626 
5627  static void Exclusion( sample& a, double b ) noexcept
5628  {
5629  double fa; FromSample( fa, a );
5630  a = ToSample( pcl::Range( 0.5 - 2*(fa - 0.5)*(b - 0.5), 0.0, 1.0 ) );
5631  }
5632 
5633  // -------------------------------------------------------------------------
5634 
5635  IMPLEMENT_TRANSFER_OPERATIONS
5636 };
5637 
5638 // ----------------------------------------------------------------------------
5639 
5652 class PCL_CLASS UInt20PixelTraits : public GenericPixelTraits<uint32>
5653 {
5654 public:
5655 
5660 
5665 
5672 
5677  static constexpr bool IsFloatSample() noexcept
5678  {
5679  return false;
5680  }
5681 
5686  static constexpr bool IsComplexSample() noexcept
5687  {
5688  return false;
5689  }
5690 
5697  static constexpr const char* SampleFormat() noexcept
5698  {
5699  return "UInt20";
5700  }
5701 
5707  static constexpr sample MaxSampleValue() noexcept
5708  {
5709  return uint20_max;
5710  }
5711 
5717  static constexpr sample LowestSampleValue() noexcept
5718  {
5719  return sample( 0 );
5720  }
5721 
5727  static constexpr sample HighestSampleValue() noexcept
5728  {
5729  return uint20_max;
5730  }
5731 
5735  template <typename T>
5736  static sample FloatToSample( T x ) noexcept
5737  {
5738 #ifdef __PCL_ENFORCE_PIXTRAITS_FLOAT_RANGE
5739  return sample( pcl::Range( Round( x ), T( 0 ), T( uint20_max ) ) );
5740 #else
5741  // ### N.B.: x must be in the range [0,uint20_max].
5742  return sample( RoundInt( x ) );
5743 #endif
5744  }
5745 
5749  static sample ToSample( uint8 x ) noexcept
5750  {
5751 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
5752  return sample( RoundInt( x * uint8_to_uint20 ) );
5753 #else
5754  return p20LUT8[x];
5755 #endif
5756  }
5757 
5761  static sample ToSample( int8 x ) noexcept
5762  {
5763 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
5764  return sample( RoundInt( (int32( x ) - int32( int8_min ))*uint8_to_uint20 ) );
5765 #else
5766  return p20LUT8[int( x ) - int( int8_min )];
5767 #endif
5768  }
5769 
5773  static sample ToSample( uint16 x ) noexcept
5774  {
5775 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
5776  return sample( RoundInt( x * uint16_to_uint20 ) );
5777 #else
5778  return p20LUT16[x];
5779 #endif
5780  }
5781 
5785  static sample ToSample( int16 x ) noexcept
5786  {
5787 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
5788  return sample( RoundInt( (int32( x ) - int32( int16_min ))*uint16_to_uint20 ) );
5789 #else
5790  return p20LUT16[int( x ) - int( int16_min )];
5791 #endif
5792  }
5793 
5797  static sample ToSample( uint32 x ) noexcept
5798  {
5799  return sample( RoundInt( x * uint32_to_uint20 ) );
5800  }
5801 
5805  static sample ToSample( int32 x ) noexcept
5806  {
5807  return sample( RoundInt( (double( x ) - int32_min)*uint32_to_uint20 ) );
5808  }
5809 
5813  static sample ToSample( float x ) noexcept
5814  {
5815  return FloatToSample( x*uint20_max );
5816  }
5817 
5823  static sample ToSampleConstrained( float x ) noexcept
5824  {
5825  return FloatToSample( pcl::Range( x, 0.0F, 1.0F )*uint20_max );
5826  }
5827 
5831  static sample ToSample( double x ) noexcept
5832  {
5833  return FloatToSample( x*uint20_max );
5834  }
5835 
5841  static sample ToSampleConstrained( double x ) noexcept
5842  {
5843  return FloatToSample( pcl::Range( x, 0.0, 1.0 )*uint20_max );
5844  }
5845 
5849  template <typename T>
5850  static constexpr sample ToSample( const Complex<T>& x ) noexcept
5851  {
5852  return ToSample( pcl::Abs( x ) );
5853  }
5854 
5858  static void FromSample( uint8& a, sample b ) noexcept
5859  {
5860 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
5861  a = uint8( RoundInt( b * uint20_to_uint8 ) );
5862 #else
5863  a = p8LUT20[b];
5864 #endif
5865  }
5866 
5870  static void FromSample( int8& a, sample b ) noexcept
5871  {
5872 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
5873  a = int8( RoundInt( b * uint20_to_uint8 ) + int8_min );
5874 #else
5875  a = int8( int( p8LUT20[b] ) + int( int8_min ) );
5876 #endif
5877  }
5878 
5882  static void FromSample( uint16& a, sample b ) noexcept
5883  {
5884 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
5885  a = uint16( RoundInt( b * uint20_to_uint16 ) );
5886 #else
5887  a = p16LUT20[b];
5888 #endif
5889  }
5890 
5894  static void FromSample( int16& a, sample b ) noexcept
5895  {
5896 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
5897  a = int16( RoundInt( b * uint20_to_uint16 ) + int16_min );
5898 #else
5899  a = int16( int( p16LUT20[b] ) + int( int16_min ) );
5900 #endif
5901  }
5902 
5906  static void FromSample( uint32& a, sample b ) noexcept
5907  {
5908 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
5909  a = uint32( RoundInt( b * uint20_to_uint32 ) );
5910 #else
5911  a = p32LUT20[b];
5912 #endif
5913  }
5914 
5918  static void FromSample( int32& a, sample b ) noexcept
5919  {
5920 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
5921  a = int32( RoundInt( b * uint20_to_uint32 ) + int32_min );
5922 #else
5923  a = int32( int64( p32LUT20[b] ) + int64( int32_min ) );
5924 #endif
5925  }
5926 
5930  static void FromSample( float& a, sample b ) noexcept
5931  {
5932 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
5933  a = float( b )/uint20_max;
5934 #else
5935  a = pFLUT20[b];
5936 #endif
5937  }
5938 
5942  static void FromSample( double& a, sample b ) noexcept
5943  {
5944 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
5945  a = double( b )/uint20_max;
5946 #else
5947  a = pDLUT20[b];
5948 #endif
5949  }
5950 
5954  template <typename T>
5955  static void FromSample( Complex<T>& a, sample b ) noexcept
5956  {
5957  typename Complex<T>::component c;
5958  FromSample( c, b );
5959  a = c;
5960  }
5961 };
5962 
5963 // ----------------------------------------------------------------------------
5964 
5977 class PCL_CLASS UInt24PixelTraits : public GenericPixelTraits<uint32>
5978 {
5979 public:
5980 
5985 
5990 
5997 
6002  static constexpr bool IsFloatSample() noexcept
6003  {
6004  return false;
6005  }
6006 
6011  static constexpr bool IsComplexSample() noexcept
6012  {
6013  return false;
6014  }
6015 
6022  static constexpr const char* SampleFormat() noexcept
6023  {
6024  return "UInt24";
6025  }
6026 
6032  static constexpr sample MaxSampleValue() noexcept
6033  {
6034  return uint24_max;
6035  }
6036 
6042  static constexpr sample LowestSampleValue() noexcept
6043  {
6044  return sample( 0 );
6045  }
6046 
6052  static constexpr sample HighestSampleValue() noexcept
6053  {
6054  return uint24_max;
6055  }
6056 
6060  template <typename T>
6061  static sample FloatToSample( T x ) noexcept
6062  {
6063 #ifdef __PCL_ENFORCE_PIXTRAITS_FLOAT_RANGE
6064  return sample( pcl::Range( Round( x ), T( 0 ), T( uint24_max ) ) );
6065 #else
6066  // ### N.B.: x must be in the range [0,uint24_max].
6067  return sample( RoundInt( x ) );
6068 #endif
6069  }
6070 
6074  static sample ToSample( uint8 x ) noexcept
6075  {
6076 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
6077  return sample( x * uint8_to_uint24 );
6078 #else
6079  return p24LUT8[x];
6080 #endif
6081  }
6082 
6086  static sample ToSample( int8 x ) noexcept
6087  {
6088 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
6089  return sample( RoundInt( (int32( x ) - int32( int8_min ))*uint8_to_uint24 ) );
6090 #else
6091  return p24LUT8[int( x ) - int( int8_min )];
6092 #endif
6093  }
6094 
6098  static sample ToSample( uint16 x ) noexcept
6099  {
6100 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
6101  return sample( RoundInt( x * uint16_to_uint24 ) );
6102 #else
6103  return p24LUT16[x];
6104 #endif
6105  }
6106 
6110  static sample ToSample( int16 x ) noexcept
6111  {
6112 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
6113  return sample( RoundInt( (int32( x ) - int32( int16_min ))*uint16_to_uint24 ) );
6114 #else
6115  return p24LUT16[int( x ) - int( int16_min )];
6116 #endif
6117  }
6118 
6122  static sample ToSample( uint32 x ) noexcept
6123  {
6124  return sample( RoundInt( x * uint32_to_uint24 ) );
6125  }
6126 
6130  static sample ToSample( int32 x ) noexcept
6131  {
6132  return sample( RoundInt( (double( x ) - int32_min)*uint32_to_uint24 ) );
6133  }
6134 
6138  static sample ToSample( float x ) noexcept
6139  {
6140  return FloatToSample( double( x )*uint24_max );
6141  }
6142 
6148  static sample ToSampleConstrained( float x ) noexcept
6149  {
6150  return FloatToSample( pcl::Range( double( x ), 0.0, 1.0 )*uint24_max );
6151  }
6152 
6156  static sample ToSample( double x ) noexcept
6157  {
6158  return FloatToSample( x*uint24_max );
6159  }
6160 
6166  static sample ToSampleConstrained( double x ) noexcept
6167  {
6168  return FloatToSample( pcl::Range( x, 0.0, 1.0 )*uint24_max );
6169  }
6170 
6174  template <typename T>
6175  static sample ToSample( const Complex<T>& x ) noexcept
6176  {
6177  return ToSample( pcl::Abs( x ) );
6178  }
6179 
6183  static void FromSample( uint8& a, sample b ) noexcept
6184  {
6185  a = uint8( RoundInt( b * uint24_to_uint8 ) );
6186  }
6187 
6191  static void FromSample( int8& a, sample b ) noexcept
6192  {
6193  a = int8( RoundInt( b * uint24_to_uint8 ) + int8_min );
6194  }
6195 
6199  static void FromSample( uint16& a, sample b ) noexcept
6200  {
6201  a = uint16( RoundInt( b * uint24_to_uint16 ) );
6202  }
6203 
6207  static void FromSample( int16& a, sample b ) noexcept
6208  {
6209  a = int16( RoundInt( b * uint24_to_uint16 ) + int16_min );
6210  }
6211 
6215  static void FromSample( uint32& a, sample b ) noexcept
6216  {
6217  a = uint32( RoundInt( b * uint24_to_uint32 ) );
6218  }
6219 
6223  static void FromSample( int32& a, sample b ) noexcept
6224  {
6225  a = int32( RoundInt( b * uint24_to_uint32 ) + int32_min );
6226  }
6227 
6231  static void FromSample( float& a, sample b ) noexcept
6232  {
6233  a = float( b )/uint24_max;
6234  }
6235 
6239  static void FromSample( double& a, sample b ) noexcept
6240  {
6241  a = double( b )/uint24_max;
6242  }
6243 
6247  template <typename T>
6248  static void FromSample( Complex<T>& a, sample b ) noexcept
6249  {
6250  typename Complex<T>::component c;
6251  FromSample( c, b );
6252  a = c;
6253  }
6254 };
6255 
6256 // ----------------------------------------------------------------------------
6257 
6258 #undef IMPLEMENT_TRANSFER_OPERATIONS
6259 
6260 #undef EPSILON_D
6261 #undef EPSILON_F
6262 
6263 #ifndef __PCL_DONT_USE_PIXTRAITS_LUT
6264 #undef pFLUT8
6265 #undef pFLUTA
6266 #undef p1FLUT8
6267 #undef pFLUT16
6268 #undef pFLUT20
6269 #undef pDLUT8
6270 #undef pDLUTA
6271 #undef p1DLUT8
6272 #undef pDLUT16
6273 #undef pDLUT20
6274 #undef p8LUT16
6275 #undef p8LUT20
6276 #undef p16LUT8
6277 #undef p16LUT20
6278 #undef p20LUT8
6279 #undef p20LUT16
6280 #undef p24LUT8
6281 #undef p24LUT16
6282 #undef p32LUT8
6283 #undef p32LUT16
6284 #undef p32LUT20
6285 #endif
6286 
6287 // ----------------------------------------------------------------------------
6288 
6289 } // pcl
6290 
6291 #endif // __PCL_PixelTraits_h
6292 
6293 // ----------------------------------------------------------------------------
6294 // EOF pcl/PixelTraits.h - Released 2024-06-18T15:48:54Z
32-bit IEEE 754 normalized floating point complex pixel traits.
Definition: PixelTraits.h:1557
static void Max(sample &a, T b) noexcept
Definition: PixelTraits.h:1904
static void Nand(sample &a, T b) noexcept
Definition: PixelTraits.h:1982
static void Mov(sample &a, T b) noexcept
Definition: PixelTraits.h:1824
static void PinLight(sample &a, T b) noexcept
Definition: PixelTraits.h:2248
static void Sub(sample &a, T b) noexcept
Definition: PixelTraits.h:1844
static sample ToSample(uint16 x) noexcept
Definition: PixelTraits.h:1684
static void Mul(sample &a, T b) noexcept
Definition: PixelTraits.h:1854
static sample ToSample(uint8 x) noexcept
Definition: PixelTraits.h:1660
static void Or(sample &a, T b) noexcept
Definition: PixelTraits.h:1916
static void Add(sample &a, T b) noexcept
Definition: PixelTraits.h:1834
static void LinearLight(sample &a, T b) noexcept
Definition: PixelTraits.h:2223
static constexpr const char * SampleFormat() noexcept
Definition: PixelTraits.h:1605
static void FromSample(int32 &a, sample b) noexcept
Definition: PixelTraits.h:1789
static void FromSample(uint32 &a, sample b) noexcept
Definition: PixelTraits.h:1781
static void Xor(sample &a, T b) noexcept
Definition: PixelTraits.h:1996
static constexpr bool IsFloatSample() noexcept
Definition: PixelTraits.h:1585
static void ColorDodge(sample &a, T b) noexcept
Definition: PixelTraits.h:2098
static void FromSample(uint8 &a, sample b) noexcept
Definition: PixelTraits.h:1749
static sample ToSample(double x) noexcept
Definition: PixelTraits.h:1732
static void FromSample(float &a, sample b) noexcept
Definition: PixelTraits.h:1797
sample::component component
Definition: PixelTraits.h:1574
static sample ToSample(const Complex< T > &x) noexcept
Definition: PixelTraits.h:1741
static sample ToSample(int8 x) noexcept
Definition: PixelTraits.h:1672
static void Overlay(sample &a, T b) noexcept
Definition: PixelTraits.h:2123
static void FromSample(double &a, sample b) noexcept
Definition: PixelTraits.h:1805
static sample ToSample(uint32 x) noexcept
Definition: PixelTraits.h:1708
static void FromSample(uint16 &a, sample b) noexcept
Definition: PixelTraits.h:1765
static void And(sample &a, T b) noexcept
Definition: PixelTraits.h:1944
static void VividLight(sample &a, T b) noexcept
Definition: PixelTraits.h:2198
static void Exclusion(sample &a, T b) noexcept
Definition: PixelTraits.h:2273
static sample MaxSampleValue() noexcept
Definition: PixelTraits.h:1615
static void Xnor(sample &a, T b) noexcept
Definition: PixelTraits.h:2010
static void Min(sample &a, T b) noexcept
Definition: PixelTraits.h:1894
static void HardLight(sample &a, T b) noexcept
Definition: PixelTraits.h:2173
static void LinearBurn(sample &a, T b) noexcept
Definition: PixelTraits.h:2048
static sample ToSample(float x) noexcept
Definition: PixelTraits.h:1724
static constexpr bool IsComplexSample() noexcept
Definition: PixelTraits.h:1594
static void FromSample(Complex< T > &a, sample b) noexcept
Definition: PixelTraits.h:1814
static void SoftLight(sample &a, T b) noexcept
Definition: PixelTraits.h:2148
static void Not(sample &a, T b) noexcept
Definition: PixelTraits.h:1969
static sample LowestSampleValue() noexcept
Definition: PixelTraits.h:1626
static void FromSampl(int8 &a, sample b) noexcept
Definition: PixelTraits.h:1757
static sample ToSample(int16 x) noexcept
Definition: PixelTraits.h:1696
static sample FloatToSample(T x) noexcept
Definition: PixelTraits.h:1646
static void Screen(sample &a, T b) noexcept
Definition: PixelTraits.h:2073
static sample HighestSampleValue() noexcept
Definition: PixelTraits.h:1637
static void ColorBurn(sample &a, T b) noexcept
Definition: PixelTraits.h:2023
static sample ToSample(int32 x) noexcept
Definition: PixelTraits.h:1716
static void Div(sample &a, T b) noexcept
Definition: PixelTraits.h:1864
static void FromSample(int16 &a, sample b) noexcept
Definition: PixelTraits.h:1773
static void Pow(sample &a, T b) noexcept
Definition: PixelTraits.h:1874
static void Not(sample &a) noexcept
Definition: PixelTraits.h:1956
static void Nor(sample &a, T b) noexcept
Definition: PixelTraits.h:1930
static void Dif(sample &a, T b) noexcept
Definition: PixelTraits.h:1884
Generic complex number.
Definition: Complex.h:84
64-bit IEEE 754 normalized floating point complex pixel traits.
Definition: PixelTraits.h:2310
static sample ToSample(int32 x) noexcept
Definition: PixelTraits.h:2471
static sample ToSample(int16 x) noexcept
Definition: PixelTraits.h:2451
static void Screen(sample &a, T b) noexcept
Definition: PixelTraits.h:2828
static sample ToSample(const Complex< T > &x) noexcept
Definition: PixelTraits.h:2496
static void PinLight(sample &a, T b) noexcept
Definition: PixelTraits.h:3007
static void Mov(sample &a, T b) noexcept
Definition: PixelTraits.h:2579
static void Mul(sample &a, T b) noexcept
Definition: PixelTraits.h:2609
static void Nor(sample &a, T b) noexcept
Definition: PixelTraits.h:2685
static void FromSample(int8 &a, sample b) noexcept
Definition: PixelTraits.h:2512
static constexpr const char * SampleFormat() noexcept
Definition: PixelTraits.h:2360
static void FromSample(int16 &a, sample b) noexcept
Definition: PixelTraits.h:2528
static sample ToSample(double x) noexcept
Definition: PixelTraits.h:2487
static sample ToSample(int8 x) noexcept
Definition: PixelTraits.h:2427
static void FromSample(uint8 &a, sample b) noexcept
Definition: PixelTraits.h:2504
static void Not(sample &a) noexcept
Definition: PixelTraits.h:2711
static void LinearLight(sample &a, T b) noexcept
Definition: PixelTraits.h:2981
static void Exclusion(sample &a, T b) noexcept
Definition: PixelTraits.h:3033
static void LinearBurn(sample &a, T b) noexcept
Definition: PixelTraits.h:2803
static sample ToSample(uint8 x) noexcept
Definition: PixelTraits.h:2415
static void And(sample &a, T b) noexcept
Definition: PixelTraits.h:2699
static void Max(sample &a, T b) noexcept
Definition: PixelTraits.h:2659
static void ColorBurn(sample &a, T b) noexcept
Definition: PixelTraits.h:2778
static sample LowestSampleValue() noexcept
Definition: PixelTraits.h:2381
static void VividLight(sample &a, T b) noexcept
Definition: PixelTraits.h:2955
static constexpr bool IsFloatSample() noexcept
Definition: PixelTraits.h:2340
static sample FloatToSample(T x) noexcept
Definition: PixelTraits.h:2401
static void FromSample(uint32 &a, sample b) noexcept
Definition: PixelTraits.h:2536
static void SoftLight(sample &a, T b) noexcept
Definition: PixelTraits.h:2903
static sample ToSample(uint32 x) noexcept
Definition: PixelTraits.h:2463
static void Nand(sample &a, T b) noexcept
Definition: PixelTraits.h:2737
static void FromSample(double &a, sample b) noexcept
Definition: PixelTraits.h:2560
static void Dif(sample &a, T b) noexcept
Definition: PixelTraits.h:2639
static constexpr bool IsComplexSample() noexcept
Definition: PixelTraits.h:2349
static void Or(sample &a, T b) noexcept
Definition: PixelTraits.h:2671
static void Not(sample &a, T b) noexcept
Definition: PixelTraits.h:2724
static void FromSample(uint16 &a, sample b) noexcept
Definition: PixelTraits.h:2520
static void Overlay(sample &a, T b) noexcept
Definition: PixelTraits.h:2878
static sample HighestSampleValue() noexcept
Definition: PixelTraits.h:2392
static void FromSample(int32 &a, sample b) noexcept
Definition: PixelTraits.h:2544
static void ColorDodge(sample &a, T b) noexcept
Definition: PixelTraits.h:2853
static sample ToSample(float x) noexcept
Definition: PixelTraits.h:2479
sample::component component
Definition: PixelTraits.h:2327
static void Min(sample &a, T b) noexcept
Definition: PixelTraits.h:2649
static void Pow(sample &a, T b) noexcept
Definition: PixelTraits.h:2629
static void HardLight(sample &a, T b) noexcept
Definition: PixelTraits.h:2929
static void Div(sample &a, T b) noexcept
Definition: PixelTraits.h:2619
static void Sub(sample &a, T b) noexcept
Definition: PixelTraits.h:2599
static void Xor(sample &a, T b) noexcept
Definition: PixelTraits.h:2751
static sample ToSample(uint16 x) noexcept
Definition: PixelTraits.h:2439
static void FromSample(Complex< T > &a, sample b) noexcept
Definition: PixelTraits.h:2569
static sample MaxSampleValue() noexcept
Definition: PixelTraits.h:2370
static void Add(sample &a, T b) noexcept
Definition: PixelTraits.h:2589
static void FromSample(float &a, sample b) noexcept
Definition: PixelTraits.h:2552
static void Xnor(sample &a, T b) noexcept
Definition: PixelTraits.h:2765
64-bit IEEE 754 normalized floating point real pixel traits.
Definition: PixelTraits.h:963
static void LinearBurn(sample &a, T b) noexcept
Definition: PixelTraits.h:1430
static void FromSample(int8 &a, sample b) noexcept
Definition: PixelTraits.h:1153
static constexpr sample FloatToSample(T x) noexcept
Definition: PixelTraits.h:1048
static void LinearLight(sample &a, T b) noexcept
Definition: PixelTraits.h:1510
static void FromSample(uint8 &a, sample b) noexcept
Definition: PixelTraits.h:1145
static sample ToSample(uint16 x) noexcept
Definition: PixelTraits.h:1080
static void Not(sample &a) noexcept
Definition: PixelTraits.h:1352
static void Overlay(sample &a, T b) noexcept
Definition: PixelTraits.h:1463
static void Pow(sample &a, T b) noexcept
Definition: PixelTraits.h:1270
static void Max(sample &a, T b) noexcept
Definition: PixelTraits.h:1300
static constexpr bool IsFloatSample() noexcept
Definition: PixelTraits.h:987
static constexpr sample MaxSampleValue() noexcept
Definition: PixelTraits.h:1017
static constexpr sample ToSample(int32 x) noexcept
Definition: PixelTraits.h:1112
static void ColorBurn(sample &a, T b) noexcept
Definition: PixelTraits.h:1419
static void FromSample(uint16 &a, sample b) noexcept
Definition: PixelTraits.h:1161
static void Nor(sample &a, T b) noexcept
Definition: PixelTraits.h:1326
static void Sub(sample &a, T b) noexcept
Definition: PixelTraits.h:1240
static void FromSample(uint32 &a, sample b) noexcept
Definition: PixelTraits.h:1177
static void Xnor(sample &a, T b) noexcept
Definition: PixelTraits.h:1406
static void Mul(sample &a, T b) noexcept
Definition: PixelTraits.h:1250
static void Exclusion(sample &a, T b) noexcept
Definition: PixelTraits.h:1534
static constexpr bool IsComplexSample() noexcept
Definition: PixelTraits.h:996
static void Mov(sample &a, T b) noexcept
Definition: PixelTraits.h:1220
static void PinLight(sample &a, T b) noexcept
Definition: PixelTraits.h:1522
static constexpr sample ToSample(float x) noexcept
Definition: PixelTraits.h:1120
static void SoftLight(sample &a, T b) noexcept
Definition: PixelTraits.h:1474
traits_type::sample sample
Definition: PixelTraits.h:974
static constexpr sample ToSample(double x) noexcept
Definition: PixelTraits.h:1128
static void Min(sample &a, T b) noexcept
Definition: PixelTraits.h:1290
static void FromSample(int16 &a, sample b) noexcept
Definition: PixelTraits.h:1169
static constexpr sample LowestSampleValue() noexcept
Definition: PixelTraits.h:1028
static sample ToSample(int8 x) noexcept
Definition: PixelTraits.h:1068
static void Screen(sample &a, T b) noexcept
Definition: PixelTraits.h:1441
static sample ToSample(int16 x) noexcept
Definition: PixelTraits.h:1092
static void HardLight(sample &a, T b) noexcept
Definition: PixelTraits.h:1486
static void Not(sample &a, T b) noexcept
Definition: PixelTraits.h:1365
static void And(sample &a, T b) noexcept
Definition: PixelTraits.h:1340
static void Xor(sample &a, T b) noexcept
Definition: PixelTraits.h:1392
static void VividLight(sample &a, T b) noexcept
Definition: PixelTraits.h:1498
static void Dif(sample &a, T b) noexcept
Definition: PixelTraits.h:1280
static void Div(sample &a, T b) noexcept
Definition: PixelTraits.h:1260
static void FromSample(double &a, sample b) noexcept
Definition: PixelTraits.h:1201
static void FromSample(int32 &a, sample b) noexcept
Definition: PixelTraits.h:1185
static void Nand(sample &a, T b) noexcept
Definition: PixelTraits.h:1378
static constexpr sample HighestSampleValue() noexcept
Definition: PixelTraits.h:1039
static void FromSample(float &a, sample b) noexcept
Definition: PixelTraits.h:1193
static void ColorDodge(sample &a, T b) noexcept
Definition: PixelTraits.h:1452
static constexpr const char * SampleFormat() noexcept
Definition: PixelTraits.h:1007
static sample ToSample(uint8 x) noexcept
Definition: PixelTraits.h:1056
static constexpr sample ToSample(uint32 x) noexcept
Definition: PixelTraits.h:1104
static constexpr sample ToSample(const Complex< T > &x) noexcept
Definition: PixelTraits.h:1137
static void Or(sample &a, T b) noexcept
Definition: PixelTraits.h:1312
static void FromSample(Complex< T > &a, sample b) noexcept
Definition: PixelTraits.h:1210
static void Add(sample &a, T b) noexcept
Definition: PixelTraits.h:1230
32-bit IEEE 754 normalized floating point real pixel traits.
Definition: PixelTraits.h:369
static void Min(sample &a, T b) noexcept
Definition: PixelTraits.h:696
static void Or(sample &a, T b) noexcept
Definition: PixelTraits.h:718
static sample ToSample(int8 x) noexcept
Definition: PixelTraits.h:474
static constexpr sample ToSample(const Complex< T > &x) noexcept
Definition: PixelTraits.h:543
static constexpr bool IsComplexSample() noexcept
Definition: PixelTraits.h:402
static void HardLight(sample &a, T b) noexcept
Definition: PixelTraits.h:892
static void ColorDodge(sample &a, T b) noexcept
Definition: PixelTraits.h:858
static constexpr sample ToSample(uint32 x) noexcept
Definition: PixelTraits.h:510
static sample ToSample(int16 x) noexcept
Definition: PixelTraits.h:498
traits_type::sample sample
Definition: PixelTraits.h:380
static void Sub(sample &a, T b) noexcept
Definition: PixelTraits.h:646
static void And(sample &a, T b) noexcept
Definition: PixelTraits.h:746
static void FromSample(int8 &a, sample b) noexcept
Definition: PixelTraits.h:559
static void Xnor(sample &a, T b) noexcept
Definition: PixelTraits.h:812
static void Not(sample &a) noexcept
Definition: PixelTraits.h:758
static sample ToSample(uint8 x) noexcept
Definition: PixelTraits.h:462
static void FromSample(uint32 &a, sample b) noexcept
Definition: PixelTraits.h:583
static void SoftLight(sample &a, T b) noexcept
Definition: PixelTraits.h:880
static void FromSample(uint8 &a, sample b) noexcept
Definition: PixelTraits.h:551
static constexpr sample FloatToSample(T x) noexcept
Definition: PixelTraits.h:454
static void Xor(sample &a, T b) noexcept
Definition: PixelTraits.h:798
static constexpr sample ToSample(int32 x) noexcept
Definition: PixelTraits.h:518
static void Exclusion(sample &a, T b) noexcept
Definition: PixelTraits.h:940
static void Overlay(sample &a, T b) noexcept
Definition: PixelTraits.h:869
static constexpr sample MaxSampleValue() noexcept
Definition: PixelTraits.h:423
static constexpr sample LowestSampleValue() noexcept
Definition: PixelTraits.h:434
static void Div(sample &a, T b) noexcept
Definition: PixelTraits.h:666
static void PinLight(sample &a, T b) noexcept
Definition: PixelTraits.h:928
static void FromSample(int16 &a, sample b) noexcept
Definition: PixelTraits.h:575
static constexpr sample ToSample(float x) noexcept
Definition: PixelTraits.h:526
static constexpr const char * SampleFormat() noexcept
Definition: PixelTraits.h:413
static constexpr sample HighestSampleValue() noexcept
Definition: PixelTraits.h:445
static void Screen(sample &a, T b) noexcept
Definition: PixelTraits.h:847
static void Dif(sample &a, T b) noexcept
Definition: PixelTraits.h:686
static constexpr sample ToSample(double x) noexcept
Definition: PixelTraits.h:534
static void Mul(sample &a, T b) noexcept
Definition: PixelTraits.h:656
static void Nor(sample &a, T b) noexcept
Definition: PixelTraits.h:732
static void Add(sample &a, T b) noexcept
Definition: PixelTraits.h:636
static void LinearBurn(sample &a, T b) noexcept
Definition: PixelTraits.h:836
static void VividLight(sample &a, T b) noexcept
Definition: PixelTraits.h:904
static void FromSample(int32 &a, sample b) noexcept
Definition: PixelTraits.h:591
static void Not(sample &a, T b) noexcept
Definition: PixelTraits.h:771
static void Max(sample &a, T b) noexcept
Definition: PixelTraits.h:706
static void FromSample(double &a, sample b) noexcept
Definition: PixelTraits.h:607
static void FromSample(uint16 &a, sample b) noexcept
Definition: PixelTraits.h:567
static sample ToSample(uint16 x) noexcept
Definition: PixelTraits.h:486
static void Pow(sample &a, T b) noexcept
Definition: PixelTraits.h:676
static constexpr bool IsFloatSample() noexcept
Definition: PixelTraits.h:393
static void LinearLight(sample &a, T b) noexcept
Definition: PixelTraits.h:916
static void ColorBurn(sample &a, T b) noexcept
Definition: PixelTraits.h:825
static void FromSample(float &a, sample b) noexcept
Definition: PixelTraits.h:599
static void Nand(sample &a, T b) noexcept
Definition: PixelTraits.h:784
static void FromSample(Complex< T > &a, sample b) noexcept
Definition: PixelTraits.h:616
static void Mov(sample &a, T b) noexcept
Definition: PixelTraits.h:626
Base class of all pixel traits classes.
Definition: PixelTraits.h:177
static constexpr int BytesPerSample() noexcept
Definition: PixelTraits.h:191
static constexpr sample MinSampleValue() noexcept
Definition: PixelTraits.h:208
static constexpr int BitsPerSample() noexcept
Definition: PixelTraits.h:199
16-bit unsigned integer pixel traits.
Definition: PixelTraits.h:3934
static void FromSample(uint32 &a, sample b) noexcept
Definition: PixelTraits.h:4171
static void Div(sample &a, pcl::Complex< float > b) noexcept
Definition: PixelTraits.h:4331
static constexpr sample MaxSampleValue() noexcept
Definition: PixelTraits.h:3988
static void VividLight(sample &a, T b) noexcept
Definition: PixelTraits.h:4686
traits_type::sample sample
Definition: PixelTraits.h:3945
static void Pow(sample &a, T b) noexcept
Definition: PixelTraits.h:4350
static void SoftLight(sample &a, T b) noexcept
Definition: PixelTraits.h:4636
static void Not(sample &a) noexcept
Definition: PixelTraits.h:4456
static void Div(sample &a, float b) noexcept
Definition: PixelTraits.h:4315
static void Min(sample &a, T b) noexcept
Definition: PixelTraits.h:4405
static void FromSample(int16 &a, sample b) noexcept
Definition: PixelTraits.h:4163
static constexpr sample ToSample(uint16 x) noexcept
Definition: PixelTraits.h:4054
static void Div(sample &a, pcl::Complex< double > b) noexcept
Definition: PixelTraits.h:4339
static void Xor(sample &a, T b) noexcept
Definition: PixelTraits.h:4489
static void Nor(sample &a, T b) noexcept
Definition: PixelTraits.h:4437
static void FromSample(float &a, sample b) noexcept
Definition: PixelTraits.h:4195
static void Screen(sample &a, T b) noexcept
Definition: PixelTraits.h:4561
static void Pow(sample &a, float b) noexcept
Definition: PixelTraits.h:4359
static void PinLight(sample &a, T b) noexcept
Definition: PixelTraits.h:4736
static constexpr sample LowestSampleValue() noexcept
Definition: PixelTraits.h:3998
static sample ToSample(uint8 x) noexcept
Definition: PixelTraits.h:4030
static void Div(sample &a, T b) noexcept
Definition: PixelTraits.h:4308
static constexpr const char * SampleFormat() noexcept
Definition: PixelTraits.h:3978
static void Max(sample &a, T b) noexcept
Definition: PixelTraits.h:4415
static sample ToSample(double x) noexcept
Definition: PixelTraits.h:4104
static void Mul(sample &a, pcl::Complex< float > b) noexcept
Definition: PixelTraits.h:4289
static void Dif(sample &a, T b) noexcept
Definition: PixelTraits.h:4394
static void Pow(sample &a, double b) noexcept
Definition: PixelTraits.h:4367
static sample ToSample(float x) noexcept
Definition: PixelTraits.h:4086
static void FromSample(uint16 &a, sample b) noexcept
Definition: PixelTraits.h:4155
static void ColorDodge(sample &a, T b) noexcept
Definition: PixelTraits.h:4586
static void Mul(sample &a, T b) noexcept
Definition: PixelTraits.h:4264
static constexpr bool IsComplexSample() noexcept
Definition: PixelTraits.h:3967
static void Pow(sample &a, pcl::Complex< float > b) noexcept
Definition: PixelTraits.h:4375
static void Div(sample &a, double b) noexcept
Definition: PixelTraits.h:4323
static sample ToSampleConstrained(float x) noexcept
Definition: PixelTraits.h:4096
static void Nand(sample &a, T b) noexcept
Definition: PixelTraits.h:4478
static void FromSample(int32 &a, sample b) noexcept
Definition: PixelTraits.h:4183
static constexpr sample HighestSampleValue() noexcept
Definition: PixelTraits.h:4008
static sample ToSample(uint32 x) noexcept
Definition: PixelTraits.h:4070
static void Overlay(sample &a, T b) noexcept
Definition: PixelTraits.h:4611
static void LinearLight(sample &a, T b) noexcept
Definition: PixelTraits.h:4711
static sample ToSample(int8 x) noexcept
Definition: PixelTraits.h:4042
static void Mov(sample &a, T b) noexcept
Definition: PixelTraits.h:4232
static void HardLight(sample &a, T b) noexcept
Definition: PixelTraits.h:4661
static constexpr sample ToSample(int16 x) noexcept
Definition: PixelTraits.h:4062
static void Mul(sample &a, double b) noexcept
Definition: PixelTraits.h:4281
static void And(sample &a, T b) noexcept
Definition: PixelTraits.h:4448
static void FromSample(Complex< T > &a, sample b) noexcept
Definition: PixelTraits.h:4220
static void FromSample(double &a, sample b) noexcept
Definition: PixelTraits.h:4207
static void Add(sample &a, T b) noexcept
Definition: PixelTraits.h:4242
static void FromSample(uint8 &a, sample b) noexcept
Definition: PixelTraits.h:4131
static void ColorBurn(sample &a, T b) noexcept
Definition: PixelTraits.h:4511
static void FromSample(int8 &a, sample b) noexcept
Definition: PixelTraits.h:4143
static void Xnor(sample &a, T b) noexcept
Definition: PixelTraits.h:4500
static void Mul(sample &a, float b) noexcept
Definition: PixelTraits.h:4273
static constexpr bool IsFloatSample() noexcept
Definition: PixelTraits.h:3958
static void Or(sample &a, T b) noexcept
Definition: PixelTraits.h:4426
static constexpr sample ToSample(const Complex< T > &x) noexcept
Definition: PixelTraits.h:4123
static void Pow(sample &a, pcl::Complex< double > b) noexcept
Definition: PixelTraits.h:4383
static void Exclusion(sample &a, T b) noexcept
Definition: PixelTraits.h:4761
static void LinearBurn(sample &a, T b) noexcept
Definition: PixelTraits.h:4536
static sample ToSample(int32 x) noexcept
Definition: PixelTraits.h:4078
static void Sub(sample &a, T b) noexcept
Definition: PixelTraits.h:4253
static sample ToSampleConstrained(double x) noexcept
Definition: PixelTraits.h:4114
static void Mul(sample &a, pcl::Complex< double > b) noexcept
Definition: PixelTraits.h:4297
static sample FloatToSample(T x) noexcept
Definition: PixelTraits.h:4017
static void Not(sample &a, T b) noexcept
Definition: PixelTraits.h:4467
20-bit unsigned integer pixel traits.
Definition: PixelTraits.h:5653
static constexpr sample LowestSampleValue() noexcept
Definition: PixelTraits.h:5717
static sample ToSample(double x) noexcept
Definition: PixelTraits.h:5831
static sample ToSample(int32 x) noexcept
Definition: PixelTraits.h:5805
static sample ToSampleConstrained(float x) noexcept
Definition: PixelTraits.h:5823
static void FromSample(int8 &a, sample b) noexcept
Definition: PixelTraits.h:5870
static sample ToSample(int16 x) noexcept
Definition: PixelTraits.h:5785
static constexpr sample MaxSampleValue() noexcept
Definition: PixelTraits.h:5707
static void FromSample(uint16 &a, sample b) noexcept
Definition: PixelTraits.h:5882
static sample ToSampleConstrained(double x) noexcept
Definition: PixelTraits.h:5841
static sample ToSample(uint8 x) noexcept
Definition: PixelTraits.h:5749
static constexpr sample ToSample(const Complex< T > &x) noexcept
Definition: PixelTraits.h:5850
static sample ToSample(float x) noexcept
Definition: PixelTraits.h:5813
static void FromSample(Complex< T > &a, sample b) noexcept
Definition: PixelTraits.h:5955
static constexpr sample HighestSampleValue() noexcept
Definition: PixelTraits.h:5727
static sample FloatToSample(T x) noexcept
Definition: PixelTraits.h:5736
static constexpr const char * SampleFormat() noexcept
Definition: PixelTraits.h:5697
static void FromSample(uint32 &a, sample b) noexcept
Definition: PixelTraits.h:5906
static void FromSample(uint8 &a, sample b) noexcept
Definition: PixelTraits.h:5858
static constexpr bool IsComplexSample() noexcept
Definition: PixelTraits.h:5686
traits_type::sample sample
Definition: PixelTraits.h:5664
static void FromSample(int32 &a, sample b) noexcept
Definition: PixelTraits.h:5918
static sample ToSample(uint32 x) noexcept
Definition: PixelTraits.h:5797
static void FromSample(int16 &a, sample b) noexcept
Definition: PixelTraits.h:5894
static constexpr bool IsFloatSample() noexcept
Definition: PixelTraits.h:5677
static void FromSample(float &a, sample b) noexcept
Definition: PixelTraits.h:5930
static sample ToSample(uint16 x) noexcept
Definition: PixelTraits.h:5773
static sample ToSample(int8 x) noexcept
Definition: PixelTraits.h:5761
static void FromSample(double &a, sample b) noexcept
Definition: PixelTraits.h:5942
24-bit unsigned integer pixel traits.
Definition: PixelTraits.h:5978
static sample ToSampleConstrained(double x) noexcept
Definition: PixelTraits.h:6166
static sample FloatToSample(T x) noexcept
Definition: PixelTraits.h:6061
static constexpr sample MaxSampleValue() noexcept
Definition: PixelTraits.h:6032
static sample ToSample(uint32 x) noexcept
Definition: PixelTraits.h:6122
traits_type::sample sample
Definition: PixelTraits.h:5989
static void FromSample(float &a, sample b) noexcept
Definition: PixelTraits.h:6231
static constexpr const char * SampleFormat() noexcept
Definition: PixelTraits.h:6022
static sample ToSample(int16 x) noexcept
Definition: PixelTraits.h:6110
static sample ToSample(int8 x) noexcept
Definition: PixelTraits.h:6086
static void FromSample(int8 &a, sample b) noexcept
Definition: PixelTraits.h:6191
static sample ToSampleConstrained(float x) noexcept
Definition: PixelTraits.h:6148
static void FromSample(double &a, sample b) noexcept
Definition: PixelTraits.h:6239
static sample ToSample(uint8 x) noexcept
Definition: PixelTraits.h:6074
static void FromSample(uint32 &a, sample b) noexcept
Definition: PixelTraits.h:6215
static void FromSample(Complex< T > &a, sample b) noexcept
Definition: PixelTraits.h:6248
static void FromSample(int16 &a, sample b) noexcept
Definition: PixelTraits.h:6207
static constexpr bool IsFloatSample() noexcept
Definition: PixelTraits.h:6002
static void FromSample(uint16 &a, sample b) noexcept
Definition: PixelTraits.h:6199
static constexpr sample LowestSampleValue() noexcept
Definition: PixelTraits.h:6042
static sample ToSample(double x) noexcept
Definition: PixelTraits.h:6156
static sample ToSample(float x) noexcept
Definition: PixelTraits.h:6138
static sample ToSample(int32 x) noexcept
Definition: PixelTraits.h:6130
static void FromSample(int32 &a, sample b) noexcept
Definition: PixelTraits.h:6223
static sample ToSample(uint16 x) noexcept
Definition: PixelTraits.h:6098
static constexpr bool IsComplexSample() noexcept
Definition: PixelTraits.h:6011
static constexpr sample HighestSampleValue() noexcept
Definition: PixelTraits.h:6052
static sample ToSample(const Complex< T > &x) noexcept
Definition: PixelTraits.h:6175
static void FromSample(uint8 &a, sample b) noexcept
Definition: PixelTraits.h:6183
32-bit unsigned integer pixel traits.
Definition: PixelTraits.h:4798
static void And(sample &a, T b) noexcept
Definition: PixelTraits.h:5296
static void FromSample(uint8 &a, sample b) noexcept
Definition: PixelTraits.h:5003
static void Pow(sample &a, T b) noexcept
Definition: PixelTraits.h:5198
static constexpr bool IsComplexSample() noexcept
Definition: PixelTraits.h:4831
static constexpr sample MaxSampleValue() noexcept
Definition: PixelTraits.h:4852
static void Screen(sample &a, T b) noexcept
Definition: PixelTraits.h:5409
static constexpr sample LowestSampleValue() noexcept
Definition: PixelTraits.h:4862
static constexpr sample HighestSampleValue() noexcept
Definition: PixelTraits.h:4872
static void FromSample(int32 &a, sample b) noexcept
Definition: PixelTraits.h:5043
static void Max(sample &a, T b) noexcept
Definition: PixelTraits.h:5263
static void ColorBurn(sample &a, T b) noexcept
Definition: PixelTraits.h:5359
static constexpr bool IsFloatSample() noexcept
Definition: PixelTraits.h:4822
static constexpr sample ToSample(uint32 x) noexcept
Definition: PixelTraits.h:4942
static void Mul(sample &a, pcl::Complex< float > b) noexcept
Definition: PixelTraits.h:5137
static void ColorDodge(sample &a, T b) noexcept
Definition: PixelTraits.h:5434
static void Mov(sample &a, T b) noexcept
Definition: PixelTraits.h:5080
static sample ToSample(const Complex< T > &x) noexcept
Definition: PixelTraits.h:4995
static sample ToSampleConstrained(double x) noexcept
Definition: PixelTraits.h:4986
static void Min(sample &a, T b) noexcept
Definition: PixelTraits.h:5253
static sample ToSample(uint8 x) noexcept
Definition: PixelTraits.h:4894
static void Pow(sample &a, double b) noexcept
Definition: PixelTraits.h:5215
static constexpr sample ToSample(int32 x) noexcept
Definition: PixelTraits.h:4950
static sample ToSample(double x) noexcept
Definition: PixelTraits.h:4976
static void Mul(sample &a, pcl::Complex< double > b) noexcept
Definition: PixelTraits.h:5145
static void Div(sample &a, pcl::Complex< double > b) noexcept
Definition: PixelTraits.h:5187
static void Add(sample &a, T b) noexcept
Definition: PixelTraits.h:5090
static sample ToSample(int16 x) noexcept
Definition: PixelTraits.h:4930
static void Div(sample &a, float b) noexcept
Definition: PixelTraits.h:5163
static void FromSample(double &a, sample b) noexcept
Definition: PixelTraits.h:5059
static void Div(sample &a, T b) noexcept
Definition: PixelTraits.h:5156
static void Pow(sample &a, pcl::Complex< float > b) noexcept
Definition: PixelTraits.h:5223
static void Mul(sample &a, double b) noexcept
Definition: PixelTraits.h:5129
static void FromSample(uint32 &a, sample b) noexcept
Definition: PixelTraits.h:5035
traits_type::sample sample
Definition: PixelTraits.h:4809
static void Not(sample &a, T b) noexcept
Definition: PixelTraits.h:5315
static sample FloatToSample(T x) noexcept
Definition: PixelTraits.h:4881
static void Or(sample &a, T b) noexcept
Definition: PixelTraits.h:5274
static void FromSample(uint16 &a, sample b) noexcept
Definition: PixelTraits.h:5019
static void Sub(sample &a, T b) noexcept
Definition: PixelTraits.h:5101
static void PinLight(sample &a, T b) noexcept
Definition: PixelTraits.h:5588
static void Nand(sample &a, T b) noexcept
Definition: PixelTraits.h:5326
static void Mul(sample &a, float b) noexcept
Definition: PixelTraits.h:5121
static sample ToSampleConstrained(float x) noexcept
Definition: PixelTraits.h:4968
static void Exclusion(sample &a, T b) noexcept
Definition: PixelTraits.h:5614
static void Xnor(sample &a, T b) noexcept
Definition: PixelTraits.h:5348
static void Mul(sample &a, T b) noexcept
Definition: PixelTraits.h:5112
static void HardLight(sample &a, T b) noexcept
Definition: PixelTraits.h:5510
static void Div(sample &a, double b) noexcept
Definition: PixelTraits.h:5171
static sample ToSample(int8 x) noexcept
Definition: PixelTraits.h:4906
static void Not(sample &a) noexcept
Definition: PixelTraits.h:5304
static void Nor(sample &a, T b) noexcept
Definition: PixelTraits.h:5285
static void LinearBurn(sample &a, T b) noexcept
Definition: PixelTraits.h:5384
static void Overlay(sample &a, T b) noexcept
Definition: PixelTraits.h:5459
static sample ToSample(uint16 x) noexcept
Definition: PixelTraits.h:4918
static void Pow(sample &a, pcl::Complex< double > b) noexcept
Definition: PixelTraits.h:5231
static void FromSample(Complex< T > &a, sample b) noexcept
Definition: PixelTraits.h:5068
static void SoftLight(sample &a, T b) noexcept
Definition: PixelTraits.h:5484
static void Pow(sample &a, float b) noexcept
Definition: PixelTraits.h:5207
static void Div(sample &a, pcl::Complex< float > b) noexcept
Definition: PixelTraits.h:5179
static void LinearLight(sample &a, T b) noexcept
Definition: PixelTraits.h:5562
static void FromSample(int16 &a, sample b) noexcept
Definition: PixelTraits.h:5027
static void Dif(sample &a, T b) noexcept
Definition: PixelTraits.h:5242
static void FromSample(int8 &a, sample b) noexcept
Definition: PixelTraits.h:5011
static sample ToSample(float x) noexcept
Definition: PixelTraits.h:4958
static void FromSample(float &a, sample b) noexcept
Definition: PixelTraits.h:5051
static void Xor(sample &a, T b) noexcept
Definition: PixelTraits.h:5337
static constexpr const char * SampleFormat() noexcept
Definition: PixelTraits.h:4842
static void VividLight(sample &a, T b) noexcept
Definition: PixelTraits.h:5536
8-bit unsigned integer pixel traits.
Definition: PixelTraits.h:3070
static void FromSample(int8 &a, sample b) noexcept
Definition: PixelTraits.h:3275
static sample ToSample(int16 x) noexcept
Definition: PixelTraits.h:3194
static void FromSample(uint8 &a, sample b) noexcept
Definition: PixelTraits.h:3267
static void Pow(sample &a, pcl::Complex< float > b) noexcept
Definition: PixelTraits.h:3511
static void Add(sample &a, T b) noexcept
Definition: PixelTraits.h:3378
static void Div(sample &a, float b) noexcept
Definition: PixelTraits.h:3451
static sample ToSample(uint16 x) noexcept
Definition: PixelTraits.h:3182
static void Min(sample &a, T b) noexcept
Definition: PixelTraits.h:3541
static void Exclusion(sample &a, T b) noexcept
Definition: PixelTraits.h:3897
static void Mov(sample &a, T b) noexcept
Definition: PixelTraits.h:3368
static void Div(sample &a, pcl::Complex< double > b) noexcept
Definition: PixelTraits.h:3475
static void LinearLight(sample &a, T b) noexcept
Definition: PixelTraits.h:3847
static void FromSample(int16 &a, sample b) noexcept
Definition: PixelTraits.h:3295
static void Overlay(sample &a, T b) noexcept
Definition: PixelTraits.h:3747
static void And(sample &a, T b) noexcept
Definition: PixelTraits.h:3584
static sample ToSample(const Complex< T > &x) noexcept
Definition: PixelTraits.h:3259
static void Mul(sample &a, float b) noexcept
Definition: PixelTraits.h:3409
static constexpr sample ToSample(uint8 x) noexcept
Definition: PixelTraits.h:3166
static void Sub(sample &a, T b) noexcept
Definition: PixelTraits.h:3389
static void FromSample(double &a, sample b) noexcept
Definition: PixelTraits.h:3343
static sample ToSample(double x) noexcept
Definition: PixelTraits.h:3240
static void Xnor(sample &a, T b) noexcept
Definition: PixelTraits.h:3636
static constexpr bool IsComplexSample() noexcept
Definition: PixelTraits.h:3103
static void Nand(sample &a, T b) noexcept
Definition: PixelTraits.h:3614
static void FromSample(Complex< T > &a, sample b) noexcept
Definition: PixelTraits.h:3356
static void Div(sample &a, double b) noexcept
Definition: PixelTraits.h:3459
static void Mul(sample &a, pcl::Complex< double > b) noexcept
Definition: PixelTraits.h:3433
static void FromSample(float &a, sample b) noexcept
Definition: PixelTraits.h:3331
static void Mul(sample &a, pcl::Complex< float > b) noexcept
Definition: PixelTraits.h:3425
static void Div(sample &a, T b) noexcept
Definition: PixelTraits.h:3444
static void Pow(sample &a, pcl::Complex< double > b) noexcept
Definition: PixelTraits.h:3519
static constexpr const char * SampleFormat() noexcept
Definition: PixelTraits.h:3114
static void ColorBurn(sample &a, T b) noexcept
Definition: PixelTraits.h:3647
static void VividLight(sample &a, T b) noexcept
Definition: PixelTraits.h:3822
static void Not(sample &a, T b) noexcept
Definition: PixelTraits.h:3603
static void Div(sample &a, pcl::Complex< float > b) noexcept
Definition: PixelTraits.h:3467
static void Screen(sample &a, T b) noexcept
Definition: PixelTraits.h:3697
static void ColorDodge(sample &a, T b) noexcept
Definition: PixelTraits.h:3722
static void Xor(sample &a, T b) noexcept
Definition: PixelTraits.h:3625
static sample ToSampleConstrained(float x) noexcept
Definition: PixelTraits.h:3232
static void HardLight(sample &a, T b) noexcept
Definition: PixelTraits.h:3797
static void Mul(sample &a, double b) noexcept
Definition: PixelTraits.h:3417
static void Or(sample &a, T b) noexcept
Definition: PixelTraits.h:3562
static sample ToSample(int32 x) noexcept
Definition: PixelTraits.h:3214
static void FromSample(uint16 &a, sample b) noexcept
Definition: PixelTraits.h:3283
static sample ToSample(float x) noexcept
Definition: PixelTraits.h:3222
static constexpr sample HighestSampleValue() noexcept
Definition: PixelTraits.h:3144
traits_type::sample sample
Definition: PixelTraits.h:3081
static void LinearBurn(sample &a, T b) noexcept
Definition: PixelTraits.h:3672
static void Pow(sample &a, T b) noexcept
Definition: PixelTraits.h:3486
static void Nor(sample &a, T b) noexcept
Definition: PixelTraits.h:3573
static constexpr sample LowestSampleValue() noexcept
Definition: PixelTraits.h:3134
static void Dif(sample &a, T b) noexcept
Definition: PixelTraits.h:3530
static constexpr sample MaxSampleValue() noexcept
Definition: PixelTraits.h:3124
static void SoftLight(sample &a, T b) noexcept
Definition: PixelTraits.h:3772
static constexpr bool IsFloatSample() noexcept
Definition: PixelTraits.h:3094
static sample ToSample(uint32 x) noexcept
Definition: PixelTraits.h:3206
static void FromSample(int32 &a, sample b) noexcept
Definition: PixelTraits.h:3319
static sample FloatToSample(T x) noexcept
Definition: PixelTraits.h:3153
static void FromSample(uint32 &a, sample b) noexcept
Definition: PixelTraits.h:3307
static void Pow(sample &a, double b) noexcept
Definition: PixelTraits.h:3503
static void Not(sample &a) noexcept
Definition: PixelTraits.h:3592
static void Max(sample &a, T b) noexcept
Definition: PixelTraits.h:3551
static constexpr sample ToSample(int8 x) noexcept
Definition: PixelTraits.h:3174
static void PinLight(sample &a, T b) noexcept
Definition: PixelTraits.h:3872
static void Pow(sample &a, float b) noexcept
Definition: PixelTraits.h:3495
static void Mul(sample &a, T b) noexcept
Definition: PixelTraits.h:3400
static sample ToSampleConstrained(double x) noexcept
Definition: PixelTraits.h:3250
Complex< T1 > Pow(const Complex< T1 > &c, T2 x) noexcept
Definition: Complex.h:747
T Abs(const Complex< T > &c) noexcept
Definition: Complex.h:429
Complex< T > Round(const Complex< T > &c) noexcept
Definition: Complex.h:938
#define uint20_to_uint32
Definition: Defs.h:982
#define uint8_to_uint16
Definition: Defs.h:904
#define uint16_to_uint8
Definition: Defs.h:934
#define uint20_to_uint16
Definition: Defs.h:970
#define uint16_to_uint20
Definition: Defs.h:940
#define uint32_to_uint24
Definition: Defs.h:1042
#define uint32_to_uint16
Definition: Defs.h:1030
#define uint32_to_uint20
Definition: Defs.h:1036
#define uint24_to_uint8
Definition: Defs.h:994
#define uint16_to_uint32
Definition: Defs.h:952
#define uint8_to_uint20
Definition: Defs.h:910
#define uint20_to_uint8
Definition: Defs.h:964
#define uint32_to_uint8
Definition: Defs.h:1024
#define uint24_to_uint32
Definition: Defs.h:1012
#define uint8_to_uint24
Definition: Defs.h:916
#define uint16_to_uint24
Definition: Defs.h:946
#define uint24_to_uint16
Definition: Defs.h:1000
#define uint8_to_uint32
Definition: Defs.h:922
#define int8_min
Definition: Defs.h:799
#define int16_min
Definition: Defs.h:820
#define uint16_max
Definition: Defs.h:835
#define uint20_max
Definition: Defs.h:842
#define int32_min
Definition: Defs.h:860
#define uint24_max
Definition: Defs.h:854
#define uint32_max
Definition: Defs.h:875
#define uint8_max
Definition: Defs.h:814
int RoundInt(T x) noexcept
Definition: Math.h:1503
int TruncInt(T x) noexcept
Definition: Math.h:1132
signed char int8
Definition: Defs.h:636
unsigned short uint16
Definition: Defs.h:654
unsigned char uint8
Definition: Defs.h:642
signed short int16
Definition: Defs.h:648
signed long long int64
Definition: Defs.h:676
signed int int32
Definition: Defs.h:660
unsigned int uint32
Definition: Defs.h:666
constexpr const T & Min(const T &a, const T &b) noexcept
Definition: Utility.h:90
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
int64 RoundI64(double x) noexcept
Definition: Math.h:1654