PCL
PixelTraits.h
Go to the documentation of this file.
1 // ____ ______ __
2 // / __ \ / ____// /
3 // / /_/ // / / /
4 // / ____// /___ / /___ PixInsight Class Library
5 // /_/ \____//_____/ PCL 2.1.19
6 // ----------------------------------------------------------------------------
7 // pcl/PixelTraits.h - Released 2019-11-07T10:59:34Z
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-2019 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 (http://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  typedef S sample;
184 
185  enum { bytesPerSample = sizeof( sample ) };
186  enum { bitsPerSample = bytesPerSample << 3 };
187 
191  static constexpr int BytesPerSample()
192  {
193  return bytesPerSample;
194  }
195 
199  static constexpr int BitsPerSample()
200  {
201  return bitsPerSample;
202  }
203 
208  static constexpr sample MinSampleValue()
209  {
210  return sample( 0 );
211  }
212 };
213 
214 #define IMPLEMENT_TRANSFER_OPERATIONS \
215  \
216  template <typename T> \
217  static void Fill( sample* f, T x, size_type n ) \
218  { \
219  PCL_PRECONDITION( f != 0 ) \
220  sample v = ToSample( x ); \
221  for ( sample* fn = f+n; f != fn; ++f ) \
222  *f = v; \
223  } \
224  \
225  static void Fill( sample* f, sample x, size_type n ) \
226  { \
227  PCL_PRECONDITION( f != 0 ) \
228  for ( sample* fn = f+n; f < fn; ++f ) \
229  *f = x; \
230  } \
231  \
232  template <typename T> \
233  static void Get( T* f, const sample* g, size_type n ) \
234  { \
235  PCL_PRECONDITION( f != 0 && g != 0 ) \
236  for ( T* fn = f+n; f < fn; ++f, ++g ) \
237  FromSample( *f, *g ); \
238  } \
239  \
240  static void Get( sample* f, const sample* g, size_type n ) \
241  { \
242  PCL_PRECONDITION( f != 0 && g != 0 ) \
243  ::memcpy( f, g, n*BytesPerSample() ); \
244  } \
245  \
246  template <typename T> \
247  static void Copy( sample* f, const T* g, size_type n ) \
248  { \
249  PCL_PRECONDITION( f != 0 && g != 0 ) \
250  for ( sample* fn = f+n; f < fn; ++f, ++g ) \
251  *f = ToSample( *g ); \
252  } \
253  \
254  static void Copy( sample* f, const sample* g, size_type n ) \
255  { \
256  PCL_PRECONDITION( f != 0 && g != 0 ) \
257  ::memcpy( f, g, n*BytesPerSample() ); \
258  } \
259  \
260  template <typename T> \
261  static void GetMin( T* f, const sample* g, size_type n ) \
262  { \
263  PCL_PRECONDITION( f != 0 && g != 0 ) \
264  for ( T* fn = f+n; f < fn; ++f, ++g ) \
265  { \
266  T h; FromSample( h, *g ); \
267  if ( h < *f ) \
268  *f = h; \
269  } \
270  } \
271  \
272  static void GetMin( sample* f, const sample* g, size_type n ) \
273  { \
274  PCL_PRECONDITION( f != 0 && g != 0 ) \
275  for ( sample* fn = f+n; f < fn; ++f, ++g ) \
276  if ( *g < *f ) \
277  *f = *g; \
278  } \
279  \
280  template <typename T> \
281  static void CopyMin( sample* f, const T* g, size_type n ) \
282  { \
283  PCL_PRECONDITION( f != 0 && g != 0 ) \
284  for ( sample* fn = f+n; f < fn; ++f, ++g ) \
285  { \
286  sample h = ToSample( *g ); \
287  if ( h < *f ) \
288  *f = h; \
289  } \
290  } \
291  \
292  static void CopyMin( sample* f, const sample* g, size_type n ) \
293  { \
294  PCL_PRECONDITION( f != 0 && g != 0 ) \
295  for ( sample* fn = f+n; f < fn; ++f, ++g ) \
296  if ( *g < *f ) \
297  *f = *g; \
298  } \
299  \
300  template <typename T> \
301  static void GetMax( T* f, const sample* g, size_type n ) \
302  { \
303  PCL_PRECONDITION( f != 0 && g != 0 ) \
304  for ( T* fn = f+n; f < fn; ++f, ++g ) \
305  { \
306  T h; FromSample( h, *g ); \
307  if ( *f < h ) \
308  *f = h; \
309  } \
310  } \
311  \
312  static void GetMax( sample* f, const sample* g, size_type n ) \
313  { \
314  PCL_PRECONDITION( f != 0 && g != 0 ) \
315  for ( sample* fn = f+n; f < fn; ++f, ++g ) \
316  if ( *f < *g ) \
317  *f = *g; \
318  } \
319  \
320  template <typename T> \
321  static void CopyMax( sample* f, const T* g, size_type n ) \
322  { \
323  PCL_PRECONDITION( f != 0 && g != 0 ) \
324  for ( sample* fn = f+n; f < fn; ++f, ++g ) \
325  { \
326  sample h = ToSample( *g ); \
327  if ( *f < h ) \
328  *f = h; \
329  } \
330  } \
331  \
332  static void CopyMax( sample* f, const sample* g, size_type n ) \
333  { \
334  PCL_PRECONDITION( f != 0 && g != 0 ) \
335  for ( sample* fn = f+n; f < fn; ++f, ++g ) \
336  if ( *f < *g ) \
337  *f = *g; \
338  }
339 
340 // ----------------------------------------------------------------------------
341 
352 class PCL_CLASS FloatPixelTraits : public GenericPixelTraits<float>
353 {
354 public:
355 
360 
365 
370  static constexpr bool IsFloatSample()
371  {
372  return true;
373  }
374 
379  static constexpr bool IsComplexSample()
380  {
381  return false;
382  }
383 
390  static constexpr const char* SampleFormat()
391  {
392  return "Float32";
393  }
394 
400  static constexpr sample MaxSampleValue()
401  {
402  return 1.0F;
403  }
404 
408  template <typename T>
409  static constexpr sample FloatToSample( T x )
410  {
411  return sample( x );
412  }
413 
417  static sample ToSample( uint8 x )
418  {
419 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
420  return sample( x )/uint8_max;
421 #else
422  return pFLUT8[x];
423 #endif
424  }
425 
429  static sample ToSample( int8 x )
430  {
431 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
432  return (sample( x ) - int8_min)/uint8_max;
433 #else
434  return pFLUT8[int( x ) - int8_min];
435 #endif
436  }
437 
441  static sample ToSample( uint16 x )
442  {
443 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
444  return sample( x )/uint16_max;
445 #else
446  return pFLUT16[x];
447 #endif
448  }
449 
453  static sample ToSample( int16 x )
454  {
455 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
456  return (sample( x ) - int16_min)/uint16_max;
457 #else
458  return pFLUT16[int( x ) - int16_min];
459 #endif
460  }
461 
465  static constexpr sample ToSample( uint32 x )
466  {
467  return sample( double( x )/uint32_max );
468  }
469 
473  static constexpr sample ToSample( int32 x )
474  {
475  return sample( (double( x ) - int32_min)/uint32_max );
476  }
477 
481  static constexpr sample ToSample( float x )
482  {
483  return sample( x );
484  }
485 
489  static constexpr sample ToSample( double x )
490  {
491  return sample( x );
492  }
493 
497  template <typename T>
498  static constexpr sample ToSample( const Complex<T>& x )
499  {
500  return sample( pcl::Abs( x ) );
501  }
502 
506  static void FromSample( uint8& a, sample b )
507  {
508  a = uint8( RoundInt( b*uint8_max ) );
509  }
510 
514  static void FromSample( int8& a, sample b )
515  {
516  a = int8( RoundInt( b*uint8_max ) + int8_min );
517  }
518 
522  static void FromSample( uint16& a, sample b )
523  {
524  a = uint16( RoundInt( b*uint16_max ) );
525  }
526 
530  static void FromSample( int16& a, sample b )
531  {
532  a = int16( RoundInt( b*uint16_max ) + int16_min );
533  }
534 
538  static void FromSample( uint32& a, sample b )
539  {
540  a = uint32( Round( double( b )*uint32_max ) );
541  }
542 
546  static void FromSample( int32& a, sample b )
547  {
548  a = int32( Round( double( b )*uint32_max ) + int32_min );
549  }
550 
554  static void FromSample( float& a, sample b )
555  {
556  a = float( b );
557  }
558 
562  static void FromSample( double& a, sample b )
563  {
564  a = double( b );
565  }
566 
570  template <typename T>
571  static void FromSample( Complex<T>& a, sample b )
572  {
573  a = typename Complex<T>::component( b );
574  }
575 
580  template <typename T>
581  static void Mov( sample& a, T b )
582  {
583  a = ToSample( b );
584  }
585 
590  template <typename T>
591  static void Add( sample& a, T b )
592  {
593  a += ToSample( b );
594  }
595 
600  template <typename T>
601  static void Sub( sample& a, T b )
602  {
603  a -= ToSample( b );
604  }
605 
610  template <typename T>
611  static void Mul( sample& a, T b )
612  {
613  a *= ToSample( b );
614  }
615 
620  template <typename T>
621  static void Div( sample& a, T b )
622  {
623  a /= ToSample( b );
624  }
625 
630  template <typename T>
631  static void Pow( sample& a, T b )
632  {
633  a = pcl::Pow( a, ToSample( b ) );
634  }
635 
640  template <typename T>
641  static void Dif( sample& a, T b )
642  {
643  a = pcl::Abs( a - ToSample( b ) );
644  }
645 
650  template <typename T>
651  static void Min( sample& a, T b )
652  {
653  a = pcl::Min( a, ToSample( b ) );
654  }
655 
660  template <typename T>
661  static void Max( sample& a, T b )
662  {
663  a = pcl::Max( a, ToSample( b ) );
664  }
665 
672  template <typename T>
673  static void Or( sample& a, T b )
674  {
675  uint8 ia; FromSample( ia, a );
676  uint8 ib; FromSample( ib, ToSample( b ) );
677  a = ToSample( uint8( ia | ib ) );
678  }
679 
686  template <typename T>
687  static void Nor( sample& a, T b )
688  {
689  uint8 ia; FromSample( ia, a );
690  uint8 ib; FromSample( ib, ToSample( b ) );
691  a = ToSample( uint8( ~(ia | ib) ) );
692  }
693 
700  template <typename T>
701  static void And( sample& a, T b )
702  {
703  uint8 ia; FromSample( ia, a );
704  uint8 ib; FromSample( ib, ToSample( b ) );
705  a = ToSample( uint8( ia & ib ) );
706  }
707 
713  static void Not( sample& a )
714  {
715  uint8 ia; FromSample( ia, a );
716  a = ToSample( uint8( ~ia ) );
717  }
718 
725  template <typename T>
726  static void Not( sample& a, T b )
727  {
728  uint8 ib; FromSample( ib, ToSample( b ) );
729  a = ToSample( uint8( ~ib ) );
730  }
731 
738  template <typename T>
739  static void Nand( sample& a, T b )
740  {
741  uint8 ia; FromSample( ia, a );
742  uint8 ib; FromSample( ib, ToSample( b ) );
743  a = ToSample( uint8( ~(ia & ib) ) );
744  }
745 
752  template <typename T>
753  static void Xor( sample& a, T b )
754  {
755  uint8 ia; FromSample( ia, a );
756  uint8 ib; FromSample( ib, ToSample( b ) );
757  a = ToSample( uint8( ia ^ ib ) );
758  }
759 
766  template <typename T>
767  static void Xnor( sample& a, T b )
768  {
769  uint8 ia; FromSample( ia, a );
770  uint8 ib; FromSample( ib, ToSample( b ) );
771  a = ToSample( uint8( ~(ia ^ ib) ) );
772  }
773 
779  template <typename T>
780  static void ColorBurn( sample& a, T b )
781  {
782  a = 1 - pcl::Min( (1 - a)/pcl::Max( EPSILON_F, ToSample( b ) ), 1.0F );
783  }
784 
790  template <typename T>
791  static void LinearBurn( sample& a, T b )
792  {
793  a = a + ToSample( b ) - 1;
794  }
795 
801  template <typename T>
802  static void Screen( sample& a, T b )
803  {
804  a = 1 - (1 - a)*(1 - ToSample( b ));
805  }
806 
812  template <typename T>
813  static void ColorDodge( sample& a, T b )
814  {
815  a = pcl::Min( a/pcl::Max( EPSILON_F, (1 - ToSample( b )) ), 1.0F );
816  }
817 
823  template <typename T>
824  static void Overlay( sample& a, T b )
825  {
826  a = (a > 0.5F) ? 1 - ((1 - 2*(a - 0.5F)) * (1 - ToSample( b ))) : 2*a*ToSample( b );
827  }
828 
834  template <typename T>
835  static void SoftLight( sample& a, T b )
836  {
837  sample fb = ToSample( b );
838  a = (fb > 0.5F) ? 1 - (1 - a)*(1 - fb - 0.5F) : a*(fb + 0.5F);
839  }
840 
846  template <typename T>
847  static void HardLight( sample& a, T b )
848  {
849  sample fb = ToSample( b );
850  a = (fb > 0.5F) ? 1 - (1 - a)*(1 - 2*(fb - 0.5F)) : 2*a*fb;
851  }
852 
858  template <typename T>
859  static void VividLight( sample& a, T b )
860  {
861  sample fb = ToSample( b );
862  a = (fb > 0.5F) ? 1 - pcl::Max( (1 - a)/(fb - 0.5F)/2, 1.0F ) : pcl::Min( a/pcl::Max( EPSILON_F, 1 - 2*fb ), 1.0F );
863  }
864 
870  template <typename T>
871  static void LinearLight( sample& a, T b )
872  {
873  sample fb = ToSample( b );
874  a = (fb > 0.5F) ? pcl::Max( a + 2*(fb - 0.5F), 1.0F ) : pcl::Max( a + 2*fb - 1, 1.0F );
875  }
876 
882  template <typename T>
883  static void PinLight( sample& a, T b )
884  {
885  sample fb = ToSample( b );
886  a = (fb > 0.5F) ? pcl::Max( a, 2*(fb - 0.5F) ) : pcl::Min( a, 2*fb );
887  }
888 
894  template <typename T>
895  static void Exclusion( sample& a, T b )
896  {
897  a = pcl::Range( 0.5F - 2*(a - 0.5F)*(ToSample( b ) - 0.5F), 0.0F, 1.0F );
898  }
899 
900  // -------------------------------------------------------------------------
901 
902  IMPLEMENT_TRANSFER_OPERATIONS
903 };
904 
905 // ----------------------------------------------------------------------------
906 
917 class PCL_CLASS DoublePixelTraits : public GenericPixelTraits<double>
918 {
919 public:
920 
925 
930 
935  static constexpr bool IsFloatSample()
936  {
937  return true;
938  }
939 
944  static constexpr bool IsComplexSample()
945  {
946  return false;
947  }
948 
955  static constexpr const char* SampleFormat()
956  {
957  return "Float64";
958  }
959 
965  static constexpr sample MaxSampleValue()
966  {
967  return 1.0;
968  }
969 
973  template <typename T>
974  static constexpr sample FloatToSample( T x )
975  {
976  return sample( x );
977  }
978 
982  static sample ToSample( uint8 x )
983  {
984 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
985  return sample( x )/uint8_max;
986 #else
987  return pDLUT8[x];
988 #endif
989  }
990 
994  static sample ToSample( int8 x )
995  {
996 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
997  return (sample( x ) - int8_min)/uint8_max;
998 #else
999  return pDLUT8[int( x ) - int8_min];
1000 #endif
1001  }
1002 
1006  static sample ToSample( uint16 x )
1007  {
1008 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
1009  return sample( x )/uint16_max;
1010 #else
1011  return pDLUT16[x];
1012 #endif
1013  }
1014 
1018  static sample ToSample( int16 x )
1019  {
1020 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
1021  return (sample( x ) - int16_min)/uint16_max;
1022 #else
1023  return pDLUT16[int( x ) - int16_min];
1024 #endif
1025  }
1026 
1030  static constexpr sample ToSample( uint32 x )
1031  {
1032  return sample( x )/uint32_max;
1033  }
1034 
1038  static constexpr sample ToSample( int32 x )
1039  {
1040  return (sample( x ) - int32_min)/uint32_max;
1041  }
1042 
1046  static constexpr sample ToSample( float x )
1047  {
1048  return sample( x );
1049  }
1050 
1054  static constexpr sample ToSample( double x )
1055  {
1056  return sample( x );
1057  }
1058 
1062  template <typename T>
1063  static constexpr sample ToSample( const Complex<T>& x )
1064  {
1065  return sample( pcl::Abs( x ) );
1066  }
1067 
1071  static void FromSample( uint8& a, sample b )
1072  {
1073  a = uint8( RoundInt( b*uint8_max ) );
1074  }
1075 
1079  static void FromSample( int8& a, sample b )
1080  {
1081  a = int8( RoundInt( b*uint8_max ) + int8_min );
1082  }
1083 
1087  static void FromSample( uint16& a, sample b )
1088  {
1089  a = uint16( RoundInt( b*uint16_max ) );
1090  }
1091 
1095  static void FromSample( int16& a, sample b )
1096  {
1097  a = int16( RoundInt( b*uint16_max ) + int16_min );
1098  }
1099 
1103  static void FromSample( uint32& a, sample b )
1104  {
1105  a = uint32( Round( sample( b )*uint32_max ) );
1106  }
1107 
1111  static void FromSample( int32& a, sample b )
1112  {
1113  a = int32( Round( sample( b )*uint32_max ) + int32_min );
1114  }
1115 
1119  static void FromSample( float& a, sample b )
1120  {
1121  a = float( b );
1122  }
1123 
1127  static void FromSample( double& a, sample b )
1128  {
1129  a = double( b );
1130  }
1131 
1135  template <typename T>
1136  static void FromSample( Complex<T>& a, sample b )
1137  {
1138  a = typename Complex<T>::component( b );
1139  }
1140 
1145  template <typename T>
1146  static void Mov( sample& a, T b )
1147  {
1148  a = ToSample( b );
1149  }
1150 
1155  template <typename T>
1156  static void Add( sample& a, T b )
1157  {
1158  a += ToSample( b );
1159  }
1160 
1165  template <typename T>
1166  static void Sub( sample& a, T b )
1167  {
1168  a -= ToSample( b );
1169  }
1170 
1175  template <typename T>
1176  static void Mul( sample& a, T b )
1177  {
1178  a *= ToSample( b );
1179  }
1180 
1185  template <typename T>
1186  static void Div( sample& a, T b )
1187  {
1188  a /= ToSample( b );
1189  }
1190 
1195  template <typename T>
1196  static void Pow( sample& a, T b )
1197  {
1198  a = pcl::Pow( a, ToSample( b ) );
1199  }
1200 
1205  template <typename T>
1206  static void Dif( sample& a, T b )
1207  {
1208  a = pcl::Abs( a - ToSample( b ) );
1209  }
1210 
1215  template <typename T>
1216  static void Min( sample& a, T b )
1217  {
1218  a = pcl::Min( a, ToSample( b ) );
1219  }
1220 
1225  template <typename T>
1226  static void Max( sample& a, T b )
1227  {
1228  a = pcl::Max( a, ToSample( b ) );
1229  }
1230 
1237  template <typename T>
1238  static void Or( sample& a, T b )
1239  {
1240  uint8 ia; FromSample( ia, a );
1241  uint8 ib; FromSample( ib, ToSample( b ) );
1242  a = ToSample( uint8( ia | ib ) );
1243  }
1244 
1251  template <typename T>
1252  static void Nor( sample& a, T b )
1253  {
1254  uint8 ia; FromSample( ia, a );
1255  uint8 ib; FromSample( ib, ToSample( b ) );
1256  a = ToSample( uint8( ~(ia | ib) ) );
1257  }
1258 
1265  template <typename T>
1266  static void And( sample& a, T b )
1267  {
1268  uint8 ia; FromSample( ia, a );
1269  uint8 ib; FromSample( ib, ToSample( b ) );
1270  a = ToSample( uint8( ia & ib ) );
1271  }
1272 
1278  static void Not( sample& a )
1279  {
1280  uint8 ia; FromSample( ia, a );
1281  a = ToSample( uint8( ~ia ) );
1282  }
1283 
1290  template <typename T>
1291  static void Not( sample& a, T b )
1292  {
1293  uint8 ib; FromSample( ib, ToSample( b ) );
1294  a = ToSample( uint8( ~ib ) );
1295  }
1296 
1303  template <typename T>
1304  static void Nand( sample& a, T b )
1305  {
1306  uint8 ia; FromSample( ia, a );
1307  uint8 ib; FromSample( ib, ToSample( b ) );
1308  a = ToSample( uint8( ~(ia & ib) ) );
1309  }
1310 
1317  template <typename T>
1318  static void Xor( sample& a, T b )
1319  {
1320  uint8 ia; FromSample( ia, a );
1321  uint8 ib; FromSample( ib, ToSample( b ) );
1322  a = ToSample( uint8( ia ^ ib ) );
1323  }
1324 
1331  template <typename T>
1332  static void Xnor( sample& a, T b )
1333  {
1334  uint8 ia; FromSample( ia, a );
1335  uint8 ib; FromSample( ib, ToSample( b ) );
1336  a = ToSample( uint8( ~(ia ^ ib) ) );
1337  }
1338 
1344  template <typename T>
1345  static void ColorBurn( sample& a, T b )
1346  {
1347  a = 1 - pcl::Min( (1 - a)/pcl::Max( EPSILON_D, ToSample( b ) ), 1.0 );
1348  }
1349 
1355  template <typename T>
1356  static void LinearBurn( sample& a, T b )
1357  {
1358  a = a + ToSample( b ) - 1;
1359  }
1360 
1366  template <typename T>
1367  static void Screen( sample& a, T b )
1368  {
1369  a = 1 - (1 - a)*(1 - ToSample( b ));
1370  }
1371 
1377  template <typename T>
1378  static void ColorDodge( sample& a, T b )
1379  {
1380  a = pcl::Min( a/pcl::Max( EPSILON_D, (1 - ToSample( b )) ), 1.0 );
1381  }
1382 
1388  template <typename T>
1389  static void Overlay( sample& a, T b )
1390  {
1391  a = (a > 0.5) ? 1 - ((1 - 2*(a - 0.5)) * (1 - ToSample( b ))) : 2*a*ToSample( b );
1392  }
1393 
1399  template <typename T>
1400  static void SoftLight( sample& a, T b )
1401  {
1402  sample fb = ToSample( b );
1403  a = (fb > 0.5) ? 1 - (1 - a)*(1 - fb - 0.5) : a*(fb + 0.5);
1404  }
1405 
1411  template <typename T>
1412  static void HardLight( sample& a, T b )
1413  {
1414  sample fb = ToSample( b );
1415  a = (fb > 0.5) ? 1 - (1 - a)*(1 - 2*(fb - 0.5)) : 2*a*fb;
1416  }
1417 
1423  template <typename T>
1424  static void VividLight( sample& a, T b )
1425  {
1426  sample fb = ToSample( b );
1427  a = (fb > 0.5) ? 1 - pcl::Max( (1 - a)/(fb - 0.5)/2, 1.0 ) : pcl::Min( a/pcl::Max( EPSILON_D, 1 - 2*fb ), 1.0 );
1428  }
1429 
1435  template <typename T>
1436  static void LinearLight( sample& a, T b )
1437  {
1438  sample fb = ToSample( b );
1439  a = (fb > 0.5) ? pcl::Max( a + 2*(fb - 0.5), 1.0 ) : pcl::Max( a + 2*fb - 1, 1.0 );
1440  }
1441 
1447  template <typename T>
1448  static void PinLight( sample& a, T b )
1449  {
1450  sample fb = ToSample( b );
1451  a = (fb > 0.5) ? pcl::Max( a, 2*(fb - 0.5) ) : pcl::Min( a, 2*fb );
1452  }
1453 
1459  template <typename T>
1460  static void Exclusion( sample& a, T b )
1461  {
1462  a = pcl::Range( 0.5 - 2*(a - 0.5)*(ToSample( b ) - 0.5), 0.0, 1.0 );
1463  }
1464 
1465  // -------------------------------------------------------------------------
1466 
1467  IMPLEMENT_TRANSFER_OPERATIONS
1468 };
1469 
1470 // ----------------------------------------------------------------------------
1471 
1482 class PCL_CLASS ComplexPixelTraits : public GenericPixelTraits<Complex<float> >
1483 {
1484 public:
1485 
1490 
1495 
1500 
1501  static constexpr int BitsPerSample()
1502  {
1503  return sizeof( component ) << 3;
1504  }
1505 
1510  static constexpr bool IsFloatSample()
1511  {
1512  return false;
1513  }
1514 
1519  static constexpr bool IsComplexSample()
1520  {
1521  return true;
1522  }
1523 
1530  static constexpr const char* SampleFormat()
1531  {
1532  return "Complex32";
1533  }
1534 
1540  static sample MaxSampleValue()
1541  {
1542  return sample( component( 1 ) );
1543  }
1544 
1548  template <typename T>
1549  static sample FloatToSample( T x )
1550  {
1551  return sample( component( x ) );
1552  }
1553 
1554  template <typename T>
1555  static sample FloatToSample( sample x )
1556  {
1557  return sample( x );
1558  }
1559 
1563  static sample ToSample( uint8 x )
1564  {
1565 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
1566  return sample( component( x )/uint8_max );
1567 #else
1568  return sample( component( pFLUT8[x] ) );
1569 #endif
1570  }
1571 
1575  static sample ToSample( int8 x )
1576  {
1577 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
1578  return sample( (component( x ) - int8_min)/uint8_max );
1579 #else
1580  return sample( component( pFLUT8[int( x ) - int8_min] ) );
1581 #endif
1582  }
1583 
1587  static sample ToSample( uint16 x )
1588  {
1589 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
1590  return sample( component( x )/uint16_max );
1591 #else
1592  return sample( component( pFLUT16[x] ) );
1593 #endif
1594  }
1595 
1599  static sample ToSample( int16 x )
1600  {
1601 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
1602  return sample( (component( x ) - int16_min)/uint16_max );
1603 #else
1604  return sample( component( pFLUT16[int( x ) - int16_min] ) );
1605 #endif
1606  }
1607 
1611  static sample ToSample( uint32 x )
1612  {
1613  return sample( component( double( x )/uint32_max ) );
1614  }
1615 
1619  static sample ToSample( int32 x )
1620  {
1621  return sample( component( (double( x ) - int32_min)/uint32_max ) );
1622  }
1623 
1627  static sample ToSample( float x )
1628  {
1629  return sample( component( x ) );
1630  }
1631 
1635  static sample ToSample( double x )
1636  {
1637  return sample( component( x ) );
1638  }
1639 
1643  template <typename T>
1644  static sample ToSample( const Complex<T>& x )
1645  {
1646  return sample( x );
1647  }
1648 
1652  static void FromSample( uint8& a, sample b )
1653  {
1654  a = uint8( RoundInt( pcl::Abs( b )*uint8_max ) );
1655  }
1656 
1660  static void FromSampl( int8& a, sample b )
1661  {
1662  a = int8( RoundInt( pcl::Abs( b )*uint8_max ) + int8_min );
1663  }
1664 
1668  static void FromSample( uint16& a, sample b )
1669  {
1670  a = uint16( RoundInt( pcl::Abs( b )*uint16_max ) );
1671  }
1672 
1676  static void FromSample( int16& a, sample b )
1677  {
1678  a = int16( RoundInt( pcl::Abs( b )*uint16_max ) + int16_min );
1679  }
1680 
1684  static void FromSample( uint32& a, sample b )
1685  {
1686  a = uint32( Round( double( pcl::Abs( b ) )*uint32_max ) );
1687  }
1688 
1692  static void FromSample( int32& a, sample b )
1693  {
1694  a = int32( Round( double( pcl::Abs( b ) )*uint32_max ) + int32_min );
1695  }
1696 
1700  static void FromSample( float& a, sample b )
1701  {
1702  a = float( pcl::Abs( b ) );
1703  }
1704 
1708  static void FromSample( double& a, sample b )
1709  {
1710  a = double( pcl::Abs( b ) );
1711  }
1712 
1716  template <typename T>
1717  static void FromSample( Complex<T>& a, sample b )
1718  {
1719  a = Complex<T>( b );
1720  }
1721 
1726  template <typename T>
1727  static void Mov( sample& a, T b )
1728  {
1729  a = ToSample( b );
1730  }
1731 
1736  template <typename T>
1737  static void Add( sample& a, T b )
1738  {
1739  a += ToSample( b );
1740  }
1741 
1746  template <typename T>
1747  static void Sub( sample& a, T b )
1748  {
1749  a -= ToSample( b );
1750  }
1751 
1756  template <typename T>
1757  static void Mul( sample& a, T b )
1758  {
1759  a *= ToSample( b );
1760  }
1761 
1766  template <typename T>
1767  static void Div( sample& a, T b )
1768  {
1769  a /= ToSample( b );
1770  }
1771 
1776  template <typename T>
1777  static void Pow( sample& a, T b )
1778  {
1779  a = pcl::Pow( a, ToSample( b ) );
1780  }
1781 
1786  template <typename T>
1787  static void Dif( sample& a, T b )
1788  {
1789  a = pcl::Abs( a - ToSample( b ) );
1790  }
1791 
1796  template <typename T>
1797  static void Min( sample& a, T b )
1798  {
1799  a = pcl::Min( a, ToSample( b ) );
1800  }
1801 
1806  template <typename T>
1807  static void Max( sample& a, T b )
1808  {
1809  a = pcl::Max( a, ToSample( b ) );
1810  }
1811 
1818  template <typename T>
1819  static void Or( sample& a, T b )
1820  {
1821  uint8 ia; FromSample( ia, a );
1822  uint8 ib; FromSample( ib, ToSample( b ) );
1823  a = ToSample( uint8( ia | ib ) );
1824  }
1825 
1832  template <typename T>
1833  static void Nor( sample& a, T b )
1834  {
1835  uint8 ia; FromSample( ia, a );
1836  uint8 ib; FromSample( ib, ToSample( b ) );
1837  a = ToSample( uint8( ~(ia | ib) ) );
1838  }
1839 
1846  template <typename T>
1847  static void And( sample& a, T b )
1848  {
1849  uint8 ia; FromSample( ia, a );
1850  uint8 ib; FromSample( ib, ToSample( b ) );
1851  a = ToSample( uint8( ia & ib ) );
1852  }
1853 
1859  static void Not( sample& a )
1860  {
1861  uint8 ia; FromSample( ia, a );
1862  a = ToSample( uint8( ~ia ) );
1863  }
1864 
1871  template <typename T>
1872  static void Not( sample& a, T b )
1873  {
1874  uint8 ib; FromSample( ib, ToSample( b ) );
1875  a = ToSample( uint8( ~ib ) );
1876  }
1877 
1884  template <typename T>
1885  static void Nand( sample& a, T b )
1886  {
1887  uint8 ia; FromSample( ia, a );
1888  uint8 ib; FromSample( ib, ToSample( b ) );
1889  a = ToSample( uint8( ~(ia & ib) ) );
1890  }
1891 
1898  template <typename T>
1899  static void Xor( sample& a, T b )
1900  {
1901  uint8 ia; FromSample( ia, a );
1902  uint8 ib; FromSample( ib, ToSample( b ) );
1903  a = ToSample( uint8( ia ^ ib ) );
1904  }
1905 
1912  template <typename T>
1913  static void Xnor( sample& a, T b )
1914  {
1915  uint8 ia; FromSample( ia, a );
1916  uint8 ib; FromSample( ib, ToSample( b ) );
1917  a = ToSample( uint8( ~(ia ^ ib) ) );
1918  }
1919 
1925  template <typename T>
1926  static void ColorBurn( sample& a, T b )
1927  {
1928  float fa; FromSample( fa, a );
1929  float fb; FromSample( fb, ToSample( b ) );
1930  a = ToSample( 1 - pcl::Min( (1 - fa)/pcl::Max( EPSILON_F, fb ), 1.0F ) );
1931  }
1932 
1933  static void ColorBurn( sample& a, float b )
1934  {
1935  float fa; FromSample( fa, a );
1936  a = ToSample( 1 - pcl::Min( (1 - fa)/pcl::Max( EPSILON_F, b ), 1.0F ) );
1937  }
1938 
1939  static void ColorBurn( sample& a, double b )
1940  {
1941  double fa; FromSample( fa, a );
1942  a = ToSample( 1 - pcl::Min( (1 - fa)/pcl::Max( EPSILON_D, b ), 1.0 ) );
1943  }
1944 
1950  template <typename T>
1951  static void LinearBurn( sample& a, T b )
1952  {
1953  float fa; FromSample( fa, a );
1954  float fb; FromSample( fb, ToSample( b ) );
1955  a = ToSample( fa + fb - 1 );
1956  }
1957 
1958  static void LinearBurn( sample& a, float b )
1959  {
1960  float fa; FromSample( fa, a );
1961  a = ToSample( fa + b - 1 );
1962  }
1963 
1964  static void LinearBurn( sample& a, double b )
1965  {
1966  double fa; FromSample( fa, a );
1967  a = ToSample( fa + b - 1 );
1968  }
1969 
1975  template <typename T>
1976  static void Screen( sample& a, T b )
1977  {
1978  float fa; FromSample( fa, a );
1979  float fb; FromSample( fb, ToSample( b ) );
1980  a = ToSample( 1 - (1 - fa)*(1 - fb) );
1981  }
1982 
1983  static void Screen( sample& a, float b )
1984  {
1985  float fa; FromSample( fa, a );
1986  a = ToSample( 1 - (1 - fa)*(1 - b) );
1987  }
1988 
1989  static void Screen( sample& a, double b )
1990  {
1991  double fa; FromSample( fa, a );
1992  a = ToSample( 1 - (1 - fa)*(1 - b) );
1993  }
1994 
2000  template <typename T>
2001  static void ColorDodge( sample& a, T b )
2002  {
2003  float fa; FromSample( fa, a );
2004  float fb; FromSample( fb, ToSample( b ) );
2005  a = ToSample( pcl::Min( fa/pcl::Max( EPSILON_F, 1 - fb ), 1.0F ) );
2006  }
2007 
2008  static void ColorDodge( sample& a, float b )
2009  {
2010  float fa; FromSample( fa, a );
2011  a = ToSample( pcl::Min( fa/pcl::Max( EPSILON_F, 1 - b ), 1.0F ) );
2012  }
2013 
2014  static void ColorDodge( sample& a, double b )
2015  {
2016  double fa; FromSample( fa, a );
2017  a = ToSample( pcl::Min( fa/pcl::Max( EPSILON_D, 1 - b ), 1.0 ) );
2018  }
2019 
2025  template <typename T>
2026  static void Overlay( sample& a, T b )
2027  {
2028  float fa; FromSample( fa, a );
2029  float fb; FromSample( fb, ToSample( b ) );
2030  a = ToSample( (fa > 0.5F) ? 1 - ((1 - 2*(fa - 0.5F)) * (1 - fb)) : 2*a*fb );
2031  }
2032 
2033  static void Overlay( sample& a, float b )
2034  {
2035  float fa; FromSample( fa, a );
2036  a = ToSample( (fa > 0.5F) ? 1 - ((1 - 2*(fa - 0.5F)) * (1 - b)) : 2*a*b );
2037  }
2038 
2039  static void Overlay( sample& a, double b )
2040  {
2041  double fa; FromSample( fa, a );
2042  a = ToSample( (fa > 0.5) ? 1 - ((1 - 2*(fa - 0.5)) * (1 - b)) : 2*a*b );
2043  }
2044 
2050  template <typename T>
2051  static void SoftLight( sample& a, T b )
2052  {
2053  float fa; FromSample( fa, a );
2054  float fb; FromSample( fb, ToSample( b ) );
2055  a = ToSample( (fb > 0.5F) ? 1 - (1 - fa)*(1 - fb - 0.5F) : a*(fb + 0.5F) );
2056  }
2057 
2058  static void SoftLight( sample& a, float b )
2059  {
2060  float fa; FromSample( fa, a );
2061  a = ToSample( (b > 0.5F) ? 1 - (1 - fa)*(1 - b - 0.5F) : a*(b + 0.5F) );
2062  }
2063 
2064  static void SoftLight( sample& a, double b )
2065  {
2066  double fa; FromSample( fa, a );
2067  a = ToSample( (b > 0.5) ? 1 - (1 - fa)*(1 - b - 0.5) : a*(b + 0.5) );
2068  }
2069 
2075  template <typename T>
2076  static void HardLight( sample& a, T b )
2077  {
2078  float fa; FromSample( fa, a );
2079  float fb; FromSample( fb, ToSample( b ) );
2080  a = ToSample( (fb > 0.5F) ? 1 - (1 - fa)*(1 - 2*(fb - 0.5F)) : 2*fa*fb );
2081  }
2082 
2083  static void HardLight( sample& a, float b )
2084  {
2085  float fa; FromSample( fa, a );
2086  a = ToSample( (b > 0.5F) ? 1 - (1 - fa)*(1 - 2*(b - 0.5F)) : 2*fa*b );
2087  }
2088 
2089  static void HardLight( sample& a, double b )
2090  {
2091  double fa; FromSample( fa, a );
2092  a = ToSample( (b > 0.5) ? 1 - (1 - fa)*(1 - 2*(b - 0.5)) : 2*fa*b );
2093  }
2094 
2100  template <typename T>
2101  static void VividLight( sample& a, T b )
2102  {
2103  float fa; FromSample( fa, a );
2104  float fb; FromSample( fb, ToSample( b ) );
2105  a = ToSample( (fb > 0.5F) ? 1 - pcl::Max( (1 - fa)/(fb - 0.5F)/2, 1.0F ) : pcl::Min( fa/pcl::Max( EPSILON_F, 1 - 2*fb ), 1.0F ) );
2106  }
2107 
2108  static void VividLight( sample& a, float b )
2109  {
2110  float fa; FromSample( fa, a );
2111  a = ToSample( (b > 0.5F) ? 1 - pcl::Max( (1 - fa)/(b - 0.5F)/2, 1.0F ) : pcl::Min( fa/pcl::Max( EPSILON_F, 1 - 2*b ), 1.0F ) );
2112  }
2113 
2114  static void VividLight( sample& a, double b )
2115  {
2116  double fa; FromSample( fa, a );
2117  a = ToSample( (b > 0.5) ? 1 - pcl::Max( (1 - fa)/(b - 0.5)/2, 1.0 ) : pcl::Min( fa/pcl::Max( EPSILON_D, 1 - 2*b ), 1.0 ) );
2118  }
2119 
2125  template <typename T>
2126  static void LinearLight( sample& a, T b )
2127  {
2128  float fa; FromSample( fa, a );
2129  float fb; FromSample( fb, ToSample( b ) );
2130  a = ToSample( (fb > 0.5F) ? pcl::Max( fa + 2*(fb - 0.5F), 1.0F ) : pcl::Max( fa + 2*fb - 1, 1.0F ) );
2131  }
2132 
2133  static void LinearLight( sample& a, float b )
2134  {
2135  float fa; FromSample( fa, a );
2136  a = ToSample( (b > 0.5F) ? pcl::Max( fa + 2*(b - 0.5F), 1.0F ) : pcl::Max( fa + 2*b - 1, 1.0F ) );
2137  }
2138 
2139  static void LinearLight( sample& a, double b )
2140  {
2141  double fa; FromSample( fa, a );
2142  a = ToSample( (b > 0.5) ? pcl::Max( fa + 2*(b - 0.5), 1.0 ) : pcl::Max( fa + 2*b - 1, 1.0 ) );
2143  }
2144 
2150  template <typename T>
2151  static void PinLight( sample& a, T b )
2152  {
2153  float fa; FromSample( fa, a );
2154  float fb; FromSample( fb, ToSample( b ) );
2155  a = ToSample( (fb > 0.5F) ? pcl::Max( fa, 2*(fb - 0.5F) ) : pcl::Min( fa, 2*fb ) );
2156  }
2157 
2158  static void PinLight( sample& a, float b )
2159  {
2160  float fa; FromSample( fa, a );
2161  a = ToSample( (b > 0.5F) ? pcl::Max( fa, 2*(b - 0.5F) ) : pcl::Min( fa, 2*b ) );
2162  }
2163 
2164  static void PinLight( sample& a, double b )
2165  {
2166  double fa; FromSample( fa, a );
2167  a = ToSample( (b > 0.5) ? pcl::Max( fa, 2*(b - 0.5) ) : pcl::Min( fa, 2*b ) );
2168  }
2169 
2175  template <typename T>
2176  static void Exclusion( sample& a, T b )
2177  {
2178  float fa; FromSample( fa, a );
2179  float fb; FromSample( fb, ToSample( b ) );
2180  a = ToSample( pcl::Range( 0.5F - 2*(fa - 0.5F)*(fb - 0.5F), 0.0F, 1.0F ) );
2181  }
2182 
2183  static void Exclusion( sample& a, float b )
2184  {
2185  float fa; FromSample( fa, a );
2186  a = ToSample( pcl::Range( 0.5F - 2*(fa - 0.5F)*(b - 0.5F), 0.0F, 1.0F ) );
2187  }
2188 
2189  static void Exclusion( sample& a, double b )
2190  {
2191  double fa; FromSample( fa, a );
2192  a = ToSample( pcl::Range( 0.5 - 2*(fa - 0.5)*(b - 0.5), 0.0, 1.0 ) );
2193  }
2194 
2195  // -------------------------------------------------------------------------
2196 
2197  IMPLEMENT_TRANSFER_OPERATIONS
2198 };
2199 
2200 // ----------------------------------------------------------------------------
2201 
2212 class PCL_CLASS DComplexPixelTraits : public GenericPixelTraits<Complex<double> >
2213 {
2214 public:
2215 
2220 
2225 
2230 
2233  static constexpr int BitsPerSample()
2234  {
2235  return sizeof( component ) << 3;
2236  }
2237 
2242  static constexpr bool IsFloatSample()
2243  {
2244  return false;
2245  }
2246 
2251  static constexpr bool IsComplexSample()
2252  {
2253  return true;
2254  }
2255 
2262  static constexpr const char* SampleFormat()
2263  {
2264  return "Complex64";
2265  }
2266 
2272  static sample MaxSampleValue()
2273  {
2274  return sample( component( 1 ) );
2275  }
2276 
2280  template <typename T>
2281  static sample FloatToSample( T x )
2282  {
2283  return sample( component( x ) );
2284  }
2285 
2286  template <typename T>
2287  static sample FloatToSample( sample x )
2288  {
2289  return sample( x );
2290  }
2291 
2295  static sample ToSample( uint8 x )
2296  {
2297 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
2298  return sample( component( x )/uint8_max );
2299 #else
2300  return sample( component( pDLUT8[x] ) );
2301 #endif
2302  }
2303 
2307  static sample ToSample( int8 x )
2308  {
2309 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
2310  return sample( (component( x ) - int8_min)/uint8_max );
2311 #else
2312  return sample( component( pDLUT8[int( x ) - int8_min] ) );
2313 #endif
2314  }
2315 
2319  static sample ToSample( uint16 x )
2320  {
2321 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
2322  return sample( component( x )/uint16_max );
2323 #else
2324  return sample( component( pDLUT16[x] ) );
2325 #endif
2326  }
2327 
2331  static sample ToSample( int16 x )
2332  {
2333 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
2334  return sample( (component( x ) - int16_min)/uint16_max );
2335 #else
2336  return sample( component( pDLUT16[int( x ) - int16_min] ) );
2337 #endif
2338  }
2339 
2343  static sample ToSample( uint32 x )
2344  {
2345  return sample( component( x )/uint32_max );
2346  }
2347 
2351  static sample ToSample( int32 x )
2352  {
2353  return sample( (component( x ) - int32_min)/uint32_max );
2354  }
2355 
2359  static sample ToSample( float x )
2360  {
2361  return sample( component( x ) );
2362  }
2363 
2367  static sample ToSample( double x )
2368  {
2369  return sample( component( x ) );
2370  }
2371 
2375  template <typename T>
2376  static sample ToSample( const Complex<T>& x )
2377  {
2378  return sample( x );
2379  }
2380 
2384  static void FromSample( uint8& a, sample b )
2385  {
2386  a = uint8( RoundInt( pcl::Abs( b )*uint8_max ) );
2387  }
2388 
2392  static void FromSample( int8& a, sample b )
2393  {
2394  a = int8( RoundInt( pcl::Abs( b )*uint8_max ) + int8_min );
2395  }
2396 
2400  static void FromSample( uint16& a, sample b )
2401  {
2402  a = uint16( RoundInt( pcl::Abs( b )*uint16_max ) );
2403  }
2404 
2408  static void FromSample( int16& a, sample b )
2409  {
2410  a = int16( RoundInt( pcl::Abs( b )*uint16_max ) + int16_min );
2411  }
2412 
2416  static void FromSample( uint32& a, sample b )
2417  {
2418  a = uint32( Round( component( pcl::Abs( b ) )*uint32_max ) );
2419  }
2420 
2424  static void FromSample( int32& a, sample b )
2425  {
2426  a = int32( Round( component( pcl::Abs( b ) )*uint32_max ) + int32_min );
2427  }
2428 
2432  static void FromSample( float& a, sample b )
2433  {
2434  a = float( pcl::Abs( b ) );
2435  }
2436 
2440  static void FromSample( double& a, sample b )
2441  {
2442  a = double( pcl::Abs( b ) );
2443  }
2444 
2448  template <typename T>
2449  static void FromSample( Complex<T>& a, sample b )
2450  {
2451  a = Complex<T>( b );
2452  }
2453 
2458  template <typename T>
2459  static void Mov( sample& a, T b )
2460  {
2461  a = ToSample( b );
2462  }
2463 
2468  template <typename T>
2469  static void Add( sample& a, T b )
2470  {
2471  a += ToSample( b );
2472  }
2473 
2478  template <typename T>
2479  static void Sub( sample& a, T b )
2480  {
2481  a -= ToSample( b );
2482  }
2483 
2488  template <typename T>
2489  static void Mul( sample& a, T b )
2490  {
2491  a *= ToSample( b );
2492  }
2493 
2498  template <typename T>
2499  static void Div( sample& a, T b )
2500  {
2501  a /= ToSample( b );
2502  }
2503 
2508  template <typename T>
2509  static void Pow( sample& a, T b )
2510  {
2511  a = pcl::Pow( a, ToSample( b ) );
2512  }
2513 
2518  template <typename T>
2519  static void Dif( sample& a, T b )
2520  {
2521  a = pcl::Abs( a - ToSample( b ) );
2522  }
2523 
2528  template <typename T>
2529  static void Min( sample& a, T b )
2530  {
2531  a = pcl::Min( a, ToSample( b ) );
2532  }
2533 
2538  template <typename T>
2539  static void Max( sample& a, T b )
2540  {
2541  a = pcl::Max( a, ToSample( b ) );
2542  }
2543 
2550  template <typename T>
2551  static void Or( sample& a, T b )
2552  {
2553  uint8 ia; FromSample( ia, a );
2554  uint8 ib; FromSample( ib, ToSample( b ) );
2555  a = ToSample( uint8( ia | ib ) );
2556  }
2557 
2564  template <typename T>
2565  static void Nor( sample& a, T b )
2566  {
2567  uint8 ia; FromSample( ia, a );
2568  uint8 ib; FromSample( ib, ToSample( b ) );
2569  a = ToSample( uint8( ~(ia | ib) ) );
2570  }
2571 
2578  template <typename T>
2579  static void And( sample& a, T b )
2580  {
2581  uint8 ia; FromSample( ia, a );
2582  uint8 ib; FromSample( ib, ToSample( b ) );
2583  a = ToSample( uint8( ia & ib ) );
2584  }
2585 
2591  static void Not( sample& a )
2592  {
2593  uint8 ia; FromSample( ia, a );
2594  a = ToSample( uint8( ~ia ) );
2595  }
2596 
2603  template <typename T>
2604  static void Not( sample& a, T b )
2605  {
2606  uint8 ib; FromSample( ib, ToSample( b ) );
2607  a = ToSample( uint8( ~ib ) );
2608  }
2609 
2616  template <typename T>
2617  static void Nand( sample& a, T b )
2618  {
2619  uint8 ia; FromSample( ia, a );
2620  uint8 ib; FromSample( ib, ToSample( b ) );
2621  a = ToSample( uint8( ~(ia & ib) ) );
2622  }
2623 
2630  template <typename T>
2631  static void Xor( sample& a, T b )
2632  {
2633  uint8 ia; FromSample( ia, a );
2634  uint8 ib; FromSample( ib, ToSample( b ) );
2635  a = ToSample( uint8( ia ^ ib ) );
2636  }
2637 
2644  template <typename T>
2645  static void Xnor( sample& a, T b )
2646  {
2647  uint8 ia; FromSample( ia, a );
2648  uint8 ib; FromSample( ib, ToSample( b ) );
2649  a = ToSample( uint8( ~(ia ^ ib) ) );
2650  }
2651 
2657  template <typename T>
2658  static void ColorBurn( sample& a, T b )
2659  {
2660  double fa; FromSample( fa, a );
2661  double fb; FromSample( fb, ToSample( b ) );
2662  a = ToSample( 1 - pcl::Min( (1 - fa)/pcl::Max( EPSILON_D, fb ), 1.0 ) );
2663  }
2664 
2665  static void ColorBurn( sample& a, float b )
2666  {
2667  double fa; FromSample( fa, a );
2668  a = ToSample( 1 - pcl::Min( (1 - fa)/pcl::Max( EPSILON_D, double( b ) ), 1.0 ) );
2669  }
2670 
2671  static void ColorBurn( sample& a, double b )
2672  {
2673  double fa; FromSample( fa, a );
2674  a = ToSample( 1 - pcl::Min( (1 - fa)/pcl::Max( EPSILON_D, b ), 1.0 ) );
2675  }
2676 
2682  template <typename T>
2683  static void LinearBurn( sample& a, T b )
2684  {
2685  double fa; FromSample( fa, a );
2686  double fb; FromSample( fb, ToSample( b ) );
2687  a = ToSample( fa + fb - 1 );
2688  }
2689 
2690  static void LinearBurn( sample& a, float b )
2691  {
2692  double fa; FromSample( fa, a );
2693  a = ToSample( fa + double( b ) - 1 );
2694  }
2695 
2696  static void LinearBurn( sample& a, double b )
2697  {
2698  double fa; FromSample( fa, a );
2699  a = ToSample( fa + b - 1 );
2700  }
2701 
2707  template <typename T>
2708  static void Screen( sample& a, T b )
2709  {
2710  double fa; FromSample( fa, a );
2711  double fb; FromSample( fb, ToSample( b ) );
2712  a = ToSample( 1 - (1 - fa)*(1 - fb) );
2713  }
2714 
2715  static void Screen( sample& a, float b )
2716  {
2717  double fa; FromSample( fa, a );
2718  a = ToSample( 1 - (1 - fa)*(1 - double( b )) );
2719  }
2720 
2721  static void Screen( sample& a, double b )
2722  {
2723  double fa; FromSample( fa, a );
2724  a = ToSample( 1 - (1 - fa)*(1 - b) );
2725  }
2726 
2732  template <typename T>
2733  static void ColorDodge( sample& a, T b )
2734  {
2735  double fa; FromSample( fa, a );
2736  double fb; FromSample( fb, ToSample( b ) );
2737  a = ToSample( pcl::Min( fa/pcl::Max( EPSILON_D, 1 - fb ), 1.0 ) );
2738  }
2739 
2740  static void ColorDodge( sample& a, float b )
2741  {
2742  double fa; FromSample( fa, a );
2743  a = ToSample( pcl::Min( fa/pcl::Max( EPSILON_D, 1 - double( b ) ), 1.0 ) );
2744  }
2745 
2746  static void ColorDodge( sample& a, double b )
2747  {
2748  double fa; FromSample( fa, a );
2749  a = ToSample( pcl::Min( fa/pcl::Max( EPSILON_D, 1 - b ), 1.0 ) );
2750  }
2751 
2757  template <typename T>
2758  static void Overlay( sample& a, T b )
2759  {
2760  double fa; FromSample( fa, a );
2761  double fb; FromSample( fb, ToSample( b ) );
2762  a = ToSample( (fa > 0.5) ? 1 - ((1 - 2*(fa - 0.5)) * (1 - fb)) : 2*a*fb );
2763  }
2764 
2765  static void Overlay( sample& a, float b )
2766  {
2767  double fa; FromSample( fa, a );
2768  a = ToSample( (fa > 0.5) ? 1 - ((1 - 2*(fa - 0.5)) * (1 - double( b ))) : 2*a*double( b ) );
2769  }
2770 
2771  static void Overlay( sample& a, double b )
2772  {
2773  double fa; FromSample( fa, a );
2774  a = ToSample( (fa > 0.5) ? 1 - ((1 - 2*(fa - 0.5)) * (1 - b)) : 2*a*b );
2775  }
2776 
2782  template <typename T>
2783  static void SoftLight( sample& a, T b )
2784  {
2785  double fa; FromSample( fa, a );
2786  double fb; FromSample( fb, ToSample( b ) );
2787  a = ToSample( (fb > 0.5) ? 1 - (1 - fa)*(1 - fb - 0.5) : a*(fb + 0.5) );
2788  }
2789 
2790  static void SoftLight( sample& a, float b )
2791  {
2792  double fa; FromSample( fa, a );
2793  double fb = double( b );
2794  a = ToSample( (fb > 0.5) ? 1 - (1 - fa)*(1 - fb - 0.5) : a*(fb + 0.5) );
2795  }
2796 
2797  static void SoftLight( sample& a, double b )
2798  {
2799  double fa; FromSample( fa, a );
2800  a = ToSample( (b > 0.5) ? 1 - (1 - fa)*(1 - b - 0.5) : a*(b + 0.5) );
2801  }
2802 
2808  template <typename T>
2809  static void HardLight( sample& a, T b )
2810  {
2811  double fa; FromSample( fa, a );
2812  double fb; FromSample( fb, ToSample( b ) );
2813  a = ToSample( (fb > 0.5) ? 1 - (1 - fa)*(1 - 2*(fb - 0.5)) : 2*fa*fb );
2814  }
2815 
2816  static void HardLight( sample& a, float b )
2817  {
2818  double fa; FromSample( fa, a );
2819  double fb = double( b );
2820  a = ToSample( (fb > 0.5) ? 1 - (1 - fa)*(1 - 2*(fb - 0.5)) : 2*fa*fb );
2821  }
2822 
2823  static void HardLight( sample& a, double b )
2824  {
2825  double fa; FromSample( fa, a );
2826  a = ToSample( (b > 0.5) ? 1 - (1 - fa)*(1 - 2*(b - 0.5)) : 2*fa*b );
2827  }
2828 
2834  template <typename T>
2835  static void VividLight( sample& a, T b )
2836  {
2837  double fa; FromSample( fa, a );
2838  double fb; FromSample( fb, ToSample( b ) );
2839  a = ToSample( (fb > 0.5) ? 1 - pcl::Max( (1 - fa)/(fb - 0.5)/2, 1.0 ) : pcl::Min( fa/pcl::Max( EPSILON_D, 1 - 2*fb ), 1.0 ) );
2840  }
2841 
2842  static void VividLight( sample& a, float b )
2843  {
2844  double fa; FromSample( fa, a );
2845  double fb = double( b );
2846  a = ToSample( (fb > 0.5) ? 1 - pcl::Max( (1 - fa)/(fb - 0.5)/2, 1.0 ) : pcl::Min( fa/pcl::Max( EPSILON_D, 1 - 2*fb ), 1.0 ) );
2847  }
2848 
2849  static void VividLight( sample& a, double b )
2850  {
2851  double fa; FromSample( fa, a );
2852  a = ToSample( (b > 0.5) ? 1 - pcl::Max( (1 - fa)/(b - 0.5)/2, 1.0 ) : pcl::Min( fa/pcl::Max( EPSILON_D, 1 - 2*b ), 1.0 ) );
2853  }
2854 
2860  template <typename T>
2861  static void LinearLight( sample& a, T b )
2862  {
2863  double fa; FromSample( fa, a );
2864  double fb; FromSample( fb, ToSample( b ) );
2865  a = ToSample( (fb > 0.5) ? pcl::Max( fa + 2*(fb - 0.5), 1.0 ) : pcl::Max( fa + 2*fb - 1, 1.0 ) );
2866  }
2867 
2868  static void LinearLight( sample& a, float b )
2869  {
2870  double fa; FromSample( fa, a );
2871  double fb = double( b );
2872  a = ToSample( (fb > 0.5) ? pcl::Max( fa + 2*(fb - 0.5), 1.0 ) : pcl::Max( fa + 2*fb - 1, 1.0 ) );
2873  }
2874 
2875  static void LinearLight( sample& a, double b )
2876  {
2877  double fa; FromSample( fa, a );
2878  a = ToSample( (b > 0.5) ? pcl::Max( fa + 2*(b - 0.5), 1.0 ) : pcl::Max( fa + 2*b - 1, 1.0 ) );
2879  }
2880 
2886  template <typename T>
2887  static void PinLight( sample& a, T b )
2888  {
2889  double fa; FromSample( fa, a );
2890  double fb; FromSample( fb, ToSample( b ) );
2891  a = ToSample( (fb > 0.5) ? pcl::Max( fa, 2*(fb - 0.5) ) : pcl::Min( fa, 2*fb ) );
2892  }
2893 
2894  static void PinLight( sample& a, float b )
2895  {
2896  double fa; FromSample( fa, a );
2897  double fb = double( b );
2898  a = ToSample( (fb > 0.5) ? pcl::Max( fa, 2*(fb - 0.5) ) : pcl::Min( fa, 2*fb ) );
2899  }
2900 
2901  static void PinLight( sample& a, double b )
2902  {
2903  double fa; FromSample( fa, a );
2904  a = ToSample( (b > 0.5) ? pcl::Max( fa, 2*(b - 0.5) ) : pcl::Min( fa, 2*b ) );
2905  }
2906 
2912  template <typename T>
2913  static void Exclusion( sample& a, T b )
2914  {
2915  double fa; FromSample( fa, a );
2916  double fb; FromSample( fb, ToSample( b ) );
2917  a = ToSample( pcl::Range( 0.5 - 2*(fa - 0.5)*(fb - 0.5), 0.0, 1.0 ) );
2918  }
2919 
2920  static void Exclusion( sample& a, float b )
2921  {
2922  double fa; FromSample( fa, a );
2923  a = ToSample( pcl::Range( 0.5 - 2*(fa - 0.5)*(double( b ) - 0.5), 0.0, 1.0 ) );
2924  }
2925 
2926  static void Exclusion( sample& a, double b )
2927  {
2928  double fa; FromSample( fa, a );
2929  a = ToSample( pcl::Range( 0.5 - 2*(fa - 0.5)*(b - 0.5), 0.0, 1.0 ) );
2930  }
2931 
2932  // -------------------------------------------------------------------------
2933 
2934  IMPLEMENT_TRANSFER_OPERATIONS
2935 };
2936 
2937 // ----------------------------------------------------------------------------
2938 
2949 class PCL_CLASS UInt8PixelTraits : public GenericPixelTraits<uint8>
2950 {
2951 public:
2952 
2957 
2962 
2967  static constexpr bool IsFloatSample()
2968  {
2969  return false;
2970  }
2971 
2976  static constexpr bool IsComplexSample()
2977  {
2978  return false;
2979  }
2980 
2987  static constexpr const char* SampleFormat()
2988  {
2989  return "UInt8";
2990  }
2991 
2997  static constexpr sample MaxSampleValue()
2998  {
2999  return uint8_max;
3000  }
3001 
3005  template <typename T>
3006  static sample FloatToSample( T x )
3007  {
3008 #ifdef __PCL_ENFORCE_PIXTRAITS_FLOAT_RANGE
3009  return sample( pcl::Range( Round( x ), T( 0 ), T( uint8_max ) ) );
3010 #else
3011  // ### N.B.: x must be in the range [0,uint8_max].
3012  return sample( RoundInt( x ) );
3013 #endif
3014  }
3015 
3019  static constexpr sample ToSample( uint8 x )
3020  {
3021  return sample( x );
3022  }
3023 
3027  static constexpr sample ToSample( int8 x )
3028  {
3029  return sample( int32( x ) - int32( int8_min ) );
3030  }
3031 
3035  static sample ToSample( uint16 x )
3036  {
3037 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
3038  return sample( Round( double( x )*uint16_to_uint8 ) );
3039 #else
3040  return p8LUT16[x];
3041 #endif
3042  }
3043 
3047  static sample ToSample( int16 x )
3048  {
3049 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
3050  return sample( Round( (double( x ) - int16_min)*uint16_to_uint8 ) );
3051 #else
3052  return p8LUT16[int( x ) - int16_min];
3053 #endif
3054  }
3055 
3059  static sample ToSample( uint32 x )
3060  {
3061  return sample( Round( double( x )*uint32_to_uint8 ) );
3062  }
3063 
3067  static sample ToSample( int32 x )
3068  {
3069  return sample( Round( (double( x ) - int32_min)*uint32_to_uint8 ) );
3070  }
3071 
3075  static sample ToSample( float x )
3076  {
3077  return FloatToSample( x*uint8_max );
3078  }
3079 
3085  static sample ToSampleConstrained( float x )
3086  {
3087  return FloatToSample( pcl::Range( x, 0.0F, 1.0F )*uint8_max );
3088  }
3089 
3093  static sample ToSample( double x )
3094  {
3095  return FloatToSample( x*uint8_max );
3096  }
3097 
3103  static sample ToSampleConstrained( double x )
3104  {
3105  return FloatToSample( pcl::Range( x, 0.0, 1.0 )*uint8_max );
3106  }
3107 
3111  template <typename T>
3112  static sample ToSample( const Complex<T>& x )
3113  {
3114  return ToSample( pcl::Abs( x ) );
3115  }
3116 
3120  static void FromSample( uint8& a, sample b )
3121  {
3122  a = uint8( b );
3123  }
3124 
3128  static void FromSample( int8& a, sample b )
3129  {
3130  a = int8( int32( b ) + int32( int8_min ) );
3131  }
3132 
3136  static void FromSample( uint16& a, sample b )
3137  {
3138 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
3139  a = uint16( b )*uint8_to_uint16;
3140 #else
3141  a = p16LUT8[b];
3142 #endif
3143  }
3144 
3148  static void FromSample( int16& a, sample b )
3149  {
3150 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
3151  a = int16( int32( uint16( b )*uint8_to_uint16 ) + int32( int16_min ) );
3152 #else
3153  a = int16( int32( p16LUT8[b] ) + int32( int16_min ) );
3154 #endif
3155  }
3156 
3160  static void FromSample( uint32& a, sample b )
3161  {
3162 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
3163  a = uint32( b )*uint8_to_uint32;
3164 #else
3165  a = p32LUT8[b];
3166 #endif
3167  }
3168 
3172  static void FromSample( int32& a, sample b )
3173  {
3174 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
3175  a = int32( double( uint32( b )*uint8_to_uint32 ) + int32_min );
3176 #else
3177  a = int32( int64( p32LUT8[b] ) + int64( int32_min ) );
3178 #endif
3179  }
3180 
3184  static void FromSample( float& a, sample b )
3185  {
3186 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
3187  a = float( b )/uint8_max;
3188 #else
3189  a = pFLUT8[b];
3190 #endif
3191  }
3192 
3196  static void FromSample( double& a, sample b )
3197  {
3198 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
3199  a = double( b )/uint8_max;
3200 #else
3201  a = pDLUT8[b];
3202 #endif
3203  }
3204 
3208  template <typename T>
3209  static void FromSample( Complex<T>& a, sample b )
3210  {
3211  typename Complex<T>::component c;
3212  FromSample( c, b );
3213  a = c;
3214  }
3215 
3220  template <typename T>
3221  static void Mov( sample& a, T b )
3222  {
3223  a = ToSample( b );
3224  }
3225 
3230  template <typename T>
3231  static void Add( sample& a, T b )
3232  {
3233  a = sample( pcl::Range( uint32( a ) + uint32( ToSample( b ) ),
3234  uint32( 0 ), uint32( uint8_max ) ) );
3235  }
3236 
3241  template <typename T>
3242  static void Sub( sample& a, T b )
3243  {
3244  a = sample( pcl::Range( int32( a ) - int32( ToSample( b ) ),
3245  int32( 0 ), int32( uint8_max ) ) );
3246  }
3247 
3252  template <typename T>
3253  static void Mul( sample& a, T b )
3254  {
3255  float fa; FromSample( fa, a );
3256  float fb; FromSample( fb, ToSample( b ) );
3257  a = ToSample( fa * fb );
3258  }
3259 
3262  static void Mul( sample& a, float b )
3263  {
3264  float fa; FromSample( fa, a );
3265  a = ToSample( fa * b );
3266  }
3267 
3270  static void Mul( sample& a, double b )
3271  {
3272  double fa; FromSample( fa, a );
3273  a = ToSample( fa * b );
3274  }
3275 
3278  static void Mul( sample& a, pcl::Complex<float> b )
3279  {
3280  float fa; FromSample( fa, a );
3281  a = ToSample( fa * b );
3282  }
3283 
3286  static void Mul( sample& a, pcl::Complex<double> b )
3287  {
3288  double fa; FromSample( fa, a );
3289  a = ToSample( fa * b );
3290  }
3291 
3296  template <typename T>
3297  static void Div( sample& a, T b )
3298  {
3299  a = FloatToSample( float( a )/float( ToSample( b ) ) );
3300  }
3301 
3304  static void Div( sample& a, float b )
3305  {
3306  float fa; FromSample( fa, a );
3307  a = ToSample( fa / b );
3308  }
3309 
3312  static void Div( sample& a, double b )
3313  {
3314  double fa; FromSample( fa, a );
3315  a = ToSample( fa / b );
3316  }
3317 
3320  static void Div( sample& a, pcl::Complex<float> b )
3321  {
3322  float fa; FromSample( fa, a );
3323  a = ToSample( fa / b );
3324  }
3325 
3328  static void Div( sample& a, pcl::Complex<double> b )
3329  {
3330  double fa; FromSample( fa, a );
3331  a = ToSample( fa / b );
3332  }
3333 
3338  template <typename T>
3339  static void Pow( sample& a, T b )
3340  {
3341  float fa; FromSample( fa, a );
3342  float fb; FromSample( fb, ToSample( b ) );
3343  a = ToSample( pcl::Pow( fa, fb ) );
3344  }
3345 
3348  static void Pow( sample& a, float b )
3349  {
3350  float fa; FromSample( fa, a );
3351  a = ToSample( pcl::Pow( fa, b ) );
3352  }
3353 
3356  static void Pow( sample& a, double b )
3357  {
3358  double fa; FromSample( fa, a );
3359  a = ToSample( pcl::Pow( fa, b ) );
3360  }
3361 
3364  static void Pow( sample& a, pcl::Complex<float> b )
3365  {
3366  float fa; FromSample( fa, a );
3367  a = ToSample( pcl::Pow( fa, b ) );
3368  }
3369 
3372  static void Pow( sample& a, pcl::Complex<double> b )
3373  {
3374  double fa; FromSample( fa, a );
3375  a = ToSample( pcl::Pow( fa, b ) );
3376  }
3377 
3382  template <typename T>
3383  static void Dif( sample& a, T b )
3384  {
3385  a = sample( pcl::Range( pcl::Abs( int32( a ) - int32( ToSample( b ) ) ),
3386  int32( 0 ), int32( uint8_max ) ) );
3387  }
3388 
3393  template <typename T>
3394  static void Min( sample& a, T b )
3395  {
3396  a = pcl::Min( a, ToSample( b ) );
3397  }
3398 
3403  template <typename T>
3404  static void Max( sample& a, T b )
3405  {
3406  a = pcl::Max( a, ToSample( b ) );
3407  }
3408 
3414  template <typename T>
3415  static void Or( sample& a, T b )
3416  {
3417  a |= ToSample( b );
3418  }
3419 
3425  template <typename T>
3426  static void Nor( sample& a, T b )
3427  {
3428  a = ~(a | ToSample( b ));
3429  }
3430 
3436  template <typename T>
3437  static void And( sample& a, T b )
3438  {
3439  a &= ToSample( b );
3440  }
3441 
3445  static void Not( sample& a )
3446  {
3447  a = sample( ~a );
3448  }
3449 
3455  template <typename T>
3456  static void Not( sample& a, T b )
3457  {
3458  a = sample( ~ToSample( b ) );
3459  }
3460 
3466  template <typename T>
3467  static void Nand( sample& a, T b )
3468  {
3469  a = sample( ~(a & ToSample( b )) );
3470  }
3471 
3477  template <typename T>
3478  static void Xor( sample& a, T b )
3479  {
3480  a ^= ToSample( b );
3481  }
3482 
3488  template <typename T>
3489  static void Xnor( sample& a, T b )
3490  {
3491  a = sample( ~(a ^ ToSample( b )) );
3492  }
3493 
3499  template <typename T>
3500  static void ColorBurn( sample& a, T b )
3501  {
3502  float fa; FromSample( fa, a );
3503  float fb; FromSample( fb, ToSample( b ) );
3504  a = ToSample( 1 - pcl::Min( (1 - fa)/pcl::Max( EPSILON_F, fb ), 1.0F ) );
3505  }
3506 
3507  static void ColorBurn( sample& a, float b )
3508  {
3509  float fa; FromSample( fa, a );
3510  a = ToSample( 1 - pcl::Min( (1 - fa)/pcl::Max( EPSILON_F, b ), 1.0F ) );
3511  }
3512 
3513  static void ColorBurn( sample& a, double b )
3514  {
3515  double fa; FromSample( fa, a );
3516  a = ToSample( 1 - pcl::Min( (1 - fa)/pcl::Max( EPSILON_D, b ), 1.0 ) );
3517  }
3518 
3524  template <typename T>
3525  static void LinearBurn( sample& a, T b )
3526  {
3527  float fa; FromSample( fa, a );
3528  float fb; FromSample( fb, ToSample( b ) );
3529  a = ToSample( fa + fb - 1 );
3530  }
3531 
3532  static void LinearBurn( sample& a, float b )
3533  {
3534  float fa; FromSample( fa, a );
3535  a = ToSample( fa + b - 1 );
3536  }
3537 
3538  static void LinearBurn( sample& a, double b )
3539  {
3540  double fa; FromSample( fa, a );
3541  a = ToSample( fa + b - 1 );
3542  }
3543 
3549  template <typename T>
3550  static void Screen( sample& a, T b )
3551  {
3552  float fa; FromSample( fa, a );
3553  float fb; FromSample( fb, ToSample( b ) );
3554  a = ToSample( 1 - (1 - fa)*(1 - fb) );
3555  }
3556 
3557  static void Screen( sample& a, float b )
3558  {
3559  float fa; FromSample( fa, a );
3560  a = ToSample( 1 - (1 - fa)*(1 - b) );
3561  }
3562 
3563  static void Screen( sample& a, double b )
3564  {
3565  double fa; FromSample( fa, a );
3566  a = ToSample( 1 - (1 - fa)*(1 - b) );
3567  }
3568 
3574  template <typename T>
3575  static void ColorDodge( sample& a, T b )
3576  {
3577  float fa; FromSample( fa, a );
3578  float fb; FromSample( fb, ToSample( b ) );
3579  a = ToSample( pcl::Min( fa/pcl::Max( EPSILON_F, 1 - fb ), 1.0F ) );
3580  }
3581 
3582  static void ColorDodge( sample& a, float b )
3583  {
3584  float fa; FromSample( fa, a );
3585  a = ToSample( pcl::Min( fa/pcl::Max( EPSILON_F, 1 - b ), 1.0F ) );
3586  }
3587 
3588  static void ColorDodge( sample& a, double b )
3589  {
3590  double fa; FromSample( fa, a );
3591  a = ToSample( pcl::Min( fa/pcl::Max( EPSILON_D, 1 - b ), 1.0 ) );
3592  }
3593 
3599  template <typename T>
3600  static void Overlay( sample& a, T b )
3601  {
3602  float fa; FromSample( fa, a );
3603  float fb; FromSample( fb, ToSample( b ) );
3604  a = ToSample( (fa > 0.5F) ? 1 - ((1 - 2*(fa - 0.5F)) * (1 - fb)) : 2*a*fb );
3605  }
3606 
3607  static void Overlay( sample& a, float b )
3608  {
3609  float fa; FromSample( fa, a );
3610  a = ToSample( (fa > 0.5F) ? 1 - ((1 - 2*(fa - 0.5F)) * (1 - b)) : 2*a*b );
3611  }
3612 
3613  static void Overlay( sample& a, double b )
3614  {
3615  double fa; FromSample( fa, a );
3616  a = ToSample( (fa > 0.5) ? 1 - ((1 - 2*(fa - 0.5)) * (1 - b)) : 2*a*b );
3617  }
3618 
3624  template <typename T>
3625  static void SoftLight( sample& a, T b )
3626  {
3627  float fa; FromSample( fa, a );
3628  float fb; FromSample( fb, ToSample( b ) );
3629  a = ToSample( (fb > 0.5F) ? 1 - (1 - fa)*(1 - fb - 0.5F) : a*(fb + 0.5F) );
3630  }
3631 
3632  static void SoftLight( sample& a, float b )
3633  {
3634  float fa; FromSample( fa, a );
3635  a = ToSample( (b > 0.5F) ? 1 - (1 - fa)*(1 - b - 0.5F) : a*(b + 0.5F) );
3636  }
3637 
3638  static void SoftLight( sample& a, double b )
3639  {
3640  double fa; FromSample( fa, a );
3641  a = ToSample( (b > 0.5) ? 1 - (1 - fa)*(1 - b - 0.5) : a*(b + 0.5) );
3642  }
3643 
3649  template <typename T>
3650  static void HardLight( sample& a, T b )
3651  {
3652  float fa; FromSample( fa, a );
3653  float fb; FromSample( fb, ToSample( b ) );
3654  a = ToSample( (fb > 0.5F) ? 1 - (1 - fa)*(1 - 2*(fb - 0.5F)) : 2*fa*fb );
3655  }
3656 
3657  static void HardLight( sample& a, float b )
3658  {
3659  float fa; FromSample( fa, a );
3660  a = ToSample( (b > 0.5F) ? 1 - (1 - fa)*(1 - 2*(b - 0.5F)) : 2*fa*b );
3661  }
3662 
3663  static void HardLight( sample& a, double b )
3664  {
3665  double fa; FromSample( fa, a );
3666  a = ToSample( (b > 0.5) ? 1 - (1 - fa)*(1 - 2*(b - 0.5)) : 2*fa*b );
3667  }
3668 
3674  template <typename T>
3675  static void VividLight( sample& a, T b )
3676  {
3677  float fa; FromSample( fa, a );
3678  float fb; FromSample( fb, ToSample( b ) );
3679  a = ToSample( (fb > 0.5F) ? 1 - pcl::Max( (1 - fa)/(fb - 0.5F)/2, 1.0F ) : pcl::Min( fa/pcl::Max( EPSILON_F, 1 - 2*fb ), 1.0F ) );
3680  }
3681 
3682  static void VividLight( sample& a, float b )
3683  {
3684  float fa; FromSample( fa, a );
3685  a = ToSample( (b > 0.5F) ? 1 - pcl::Max( (1 - fa)/(b - 0.5F)/2, 1.0F ) : pcl::Min( fa/pcl::Max( EPSILON_F, 1 - 2*b ), 1.0F ) );
3686  }
3687 
3688  static void VividLight( sample& a, double b )
3689  {
3690  double fa; FromSample( fa, a );
3691  a = ToSample( (b > 0.5) ? 1 - pcl::Max( (1 - fa)/(b - 0.5)/2, 1.0 ) : pcl::Min( fa/pcl::Max( EPSILON_D, 1 - 2*b ), 1.0 ) );
3692  }
3693 
3699  template <typename T>
3700  static void LinearLight( sample& a, T b )
3701  {
3702  float fa; FromSample( fa, a );
3703  float fb; FromSample( fb, ToSample( b ) );
3704  a = ToSample( (fb > 0.5F) ? pcl::Max( fa + 2*(fb - 0.5F), 1.0F ) : pcl::Max( fa + 2*fb - 1, 1.0F ) );
3705  }
3706 
3707  static void LinearLight( sample& a, float b )
3708  {
3709  float fa; FromSample( fa, a );
3710  a = ToSample( (b > 0.5F) ? pcl::Max( fa + 2*(b - 0.5F), 1.0F ) : pcl::Max( fa + 2*b - 1, 1.0F ) );
3711  }
3712 
3713  static void LinearLight( sample& a, double b )
3714  {
3715  double fa; FromSample( fa, a );
3716  a = ToSample( (b > 0.5) ? pcl::Max( fa + 2*(b - 0.5), 1.0 ) : pcl::Max( fa + 2*b - 1, 1.0 ) );
3717  }
3718 
3724  template <typename T>
3725  static void PinLight( sample& a, T b )
3726  {
3727  float fa; FromSample( fa, a );
3728  float fb; FromSample( fb, ToSample( b ) );
3729  a = ToSample( (fb > 0.5F) ? pcl::Max( fa, 2*(fb - 0.5F) ) : pcl::Min( fa, 2*fb ) );
3730  }
3731 
3732  static void PinLight( sample& a, float b )
3733  {
3734  float fa; FromSample( fa, a );
3735  a = ToSample( (b > 0.5F) ? pcl::Max( fa, 2*(b - 0.5F) ) : pcl::Min( fa, 2*b ) );
3736  }
3737 
3738  static void PinLight( sample& a, double b )
3739  {
3740  double fa; FromSample( fa, a );
3741  a = ToSample( (b > 0.5) ? pcl::Max( fa, 2*(b - 0.5) ) : pcl::Min( fa, 2*b ) );
3742  }
3743 
3749  template <typename T>
3750  static void Exclusion( sample& a, T b )
3751  {
3752  float fa; FromSample( fa, a );
3753  float fb; FromSample( fb, ToSample( b ) );
3754  a = ToSample( pcl::Range( 0.5F - 2*(fa - 0.5F)*(fb - 0.5F), 0.0F, 1.0F ) );
3755  }
3756 
3757  static void Exclusion( sample& a, float b )
3758  {
3759  float fa; FromSample( fa, a );
3760  a = ToSample( pcl::Range( 0.5F - 2*(fa - 0.5F)*(b - 0.5F), 0.0F, 1.0F ) );
3761  }
3762 
3763  static void Exclusion( sample& a, double b )
3764  {
3765  double fa; FromSample( fa, a );
3766  a = ToSample( pcl::Range( 0.5 - 2*(fa - 0.5)*(b - 0.5), 0.0, 1.0 ) );
3767  }
3768 
3769  // -------------------------------------------------------------------------
3770 
3771  IMPLEMENT_TRANSFER_OPERATIONS
3772 };
3773 
3774 // ----------------------------------------------------------------------------
3775 
3786 class PCL_CLASS UInt16PixelTraits : public GenericPixelTraits<uint16>
3787 {
3788 public:
3789 
3794 
3799 
3804  static constexpr bool IsFloatSample()
3805  {
3806  return false;
3807  }
3808 
3813  static constexpr bool IsComplexSample()
3814  {
3815  return false;
3816  }
3817 
3824  static constexpr const char* SampleFormat()
3825  {
3826  return "UInt16";
3827  }
3828 
3834  static constexpr sample MaxSampleValue()
3835  {
3836  return uint16_max;
3837  }
3838 
3842  template <typename T>
3843  static sample FloatToSample( T x )
3844  {
3845 #ifdef __PCL_ENFORCE_PIXTRAITS_FLOAT_RANGE
3846  return sample( pcl::Range( Round( x ), T( 0 ), T( uint16_max ) ) );
3847 #else
3848  // ### N.B.: x must be in the range [0,uint16_max].
3849  return sample( RoundInt( x ) );
3850 #endif
3851  }
3852 
3856  static sample ToSample( uint8 x )
3857  {
3858 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
3859  return sample( x )*sample( uint8_to_uint16 );
3860 #else
3861  return p16LUT8[x];
3862 #endif
3863  }
3864 
3868  static sample ToSample( int8 x )
3869  {
3870 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
3871  return sample( (int32( x ) - int32( int8_min ))*int32( uint8_to_uint16 ) );
3872 #else
3873  return p16LUT8[int( x ) - int( int8_min )];
3874 #endif
3875  }
3876 
3880  static constexpr sample ToSample( uint16 x )
3881  {
3882  return sample( x );
3883  }
3884 
3888  static constexpr sample ToSample( int16 x )
3889  {
3890  return sample( int32( x ) - int32( int16_min ) );
3891  }
3892 
3896  static sample ToSample( uint32 x )
3897  {
3898  return sample( Round( double( x )*uint32_to_uint16 ) );
3899  }
3900 
3904  static sample ToSample( int32 x )
3905  {
3906  return sample( Round( (double( x ) - int32_min)*uint32_to_uint16 ) );
3907  }
3908 
3912  static sample ToSample( float x )
3913  {
3914  return FloatToSample( x*uint16_max );
3915  }
3916 
3922  static sample ToSampleConstrained( float x )
3923  {
3924  return FloatToSample( pcl::Range( x, 0.0F, 1.0F )*uint16_max );
3925  }
3926 
3930  static sample ToSample( double x )
3931  {
3932  return FloatToSample( x*uint16_max );
3933  }
3934 
3940  static sample ToSampleConstrained( double x )
3941  {
3942  return FloatToSample( pcl::Range( x, 0.0, 1.0 )*uint16_max );
3943  }
3944 
3948  template <typename T>
3949  static constexpr sample ToSample( const Complex<T>& x )
3950  {
3951  return ToSample( pcl::Abs( x ) );
3952  }
3953 
3957  static void FromSample( uint8& a, sample b )
3958  {
3959 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
3960  a = uint8( Round( double( b )*uint16_to_uint8 ) );
3961 #else
3962  a = p8LUT16[b];
3963 #endif
3964  }
3965 
3969  static void FromSample( int8& a, sample b )
3970  {
3971 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
3972  a = int8( Round( double( b )*uint16_to_uint8 ) + int8_min );
3973 #else
3974  a = int8( int( p8LUT16[b] ) + int( int8_min ) );
3975 #endif
3976  }
3977 
3981  static void FromSample( uint16& a, sample b )
3982  {
3983  a = uint16( b );
3984  }
3985 
3989  static void FromSample( int16& a, sample b )
3990  {
3991  a = int16( int32( b ) + int32( int16_min ) );
3992  }
3993 
3997  static void FromSample( uint32& a, sample b )
3998  {
3999 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
4000  a = uint32( b )*uint16_to_uint32;
4001 #else
4002  a = p32LUT16[b];
4003 #endif
4004  }
4005 
4009  static void FromSample( int32& a, sample b )
4010  {
4011 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
4012  a = int32( double( uint32( b )*uint16_to_uint32 ) + int32_min );
4013 #else
4014  a = int32( int64( p32LUT16[b] ) + int64( int32_min ) );
4015 #endif
4016  }
4017 
4021  static void FromSample( float& a, sample b )
4022  {
4023 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
4024  a = float( b )/uint16_max;
4025 #else
4026  a = pFLUT16[b];
4027 #endif
4028  }
4029 
4033  static void FromSample( double& a, sample b )
4034  {
4035 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
4036  a = double( b )/uint16_max;
4037 #else
4038  a = pDLUT16[b];
4039 #endif
4040  }
4041 
4045  template <typename T>
4046  static void FromSample( Complex<T>& a, sample b )
4047  {
4048  typename Complex<T>::component c;
4049  FromSample( c, b );
4050  a = c;
4051  }
4052 
4057  template <typename T>
4058  static void Mov( sample& a, T b )
4059  {
4060  a = ToSample( b );
4061  }
4062 
4067  template <typename T>
4068  static void Add( sample& a, T b )
4069  {
4070  a = sample( pcl::Range( uint32( a ) + uint32( ToSample( b ) ),
4071  uint32( 0 ), uint32( uint16_max ) ) );
4072  }
4073 
4078  template <typename T>
4079  static void Sub( sample& a, T b )
4080  {
4081  a = sample( pcl::Range( int32( a ) - int32( ToSample( b ) ),
4082  int32( 0 ), int32( uint16_max ) ) );
4083  }
4084 
4089  template <typename T>
4090  static void Mul( sample& a, T b )
4091  {
4092  double fa; FromSample( fa, a );
4093  double fb; FromSample( fb, ToSample( b ) );
4094  a = ToSample( fa * fb );
4095  }
4096 
4099  static void Mul( sample& a, float b )
4100  {
4101  double fa; FromSample( fa, a );
4102  a = ToSample( fa * b );
4103  }
4104 
4107  static void Mul( sample& a, double b )
4108  {
4109  double fa; FromSample( fa, a );
4110  a = ToSample( fa * b );
4111  }
4112 
4115  static void Mul( sample& a, pcl::Complex<float> b )
4116  {
4117  double fa; FromSample( fa, a );
4118  a = ToSample( fa * b );
4119  }
4120 
4123  static void Mul( sample& a, pcl::Complex<double> b )
4124  {
4125  double fa; FromSample( fa, a );
4126  a = ToSample( fa * b );
4127  }
4128 
4133  template <typename T>
4134  static void Div( sample& a, T b )
4135  {
4136  a = FloatToSample( double( a )/double( ToSample( b ) ) );
4137  }
4138 
4141  static void Div( sample& a, float b )
4142  {
4143  double fa; FromSample( fa, a );
4144  a = ToSample( fa / b );
4145  }
4146 
4149  static void Div( sample& a, double b )
4150  {
4151  double fa; FromSample( fa, a );
4152  a = ToSample( fa / b );
4153  }
4154 
4157  static void Div( sample& a, pcl::Complex<float> b )
4158  {
4159  double fa; FromSample( fa, a );
4160  a = ToSample( fa / b );
4161  }
4162 
4165  static void Div( sample& a, pcl::Complex<double> b )
4166  {
4167  double fa; FromSample( fa, a );
4168  a = ToSample( fa / b );
4169  }
4170 
4175  template <typename T>
4176  static void Pow( sample& a, T b )
4177  {
4178  double fa; FromSample( fa, a );
4179  double fb; FromSample( fb, ToSample( b ) );
4180  a = ToSample( pcl::Pow( fa, fb ) );
4181  }
4182 
4185  static void Pow( sample& a, float b )
4186  {
4187  double fa; FromSample( fa, a );
4188  a = ToSample( pcl::Pow( fa, double( b ) ) );
4189  }
4190 
4193  static void Pow( sample& a, double b )
4194  {
4195  double fa; FromSample( fa, a );
4196  a = ToSample( pcl::Pow( fa, b ) );
4197  }
4198 
4201  static void Pow( sample& a, pcl::Complex<float> b )
4202  {
4203  double fa; FromSample( fa, a );
4204  a = ToSample( pcl::Pow( fa, pcl::Complex<double>( b ) ) );
4205  }
4206 
4209  static void Pow( sample& a, pcl::Complex<double> b )
4210  {
4211  double fa; FromSample( fa, a );
4212  a = ToSample( pcl::Pow( fa, b ) );
4213  }
4214 
4219  template <typename T>
4220  static void Dif( sample& a, T b )
4221  {
4222  a = sample( pcl::Range( pcl::Abs( int32( a ) - int32( ToSample( b ) ) ),
4223  int32( 0 ), int32( uint16_max ) ) );
4224  }
4225 
4230  template <typename T>
4231  static void Min( sample& a, T b )
4232  {
4233  a = pcl::Min( a, ToSample( b ) );
4234  }
4235 
4240  template <typename T>
4241  static void Max( sample& a, T b )
4242  {
4243  a = pcl::Max( a, ToSample( b ) );
4244  }
4245 
4251  template <typename T>
4252  static void Or( sample& a, T b )
4253  {
4254  a |= ToSample( b );
4255  }
4256 
4262  template <typename T>
4263  static void Nor( sample& a, T b )
4264  {
4265  a = ~(a | ToSample( b ));
4266  }
4267 
4273  template <typename T>
4274  static void And( sample& a, T b )
4275  {
4276  a &= ToSample( b );
4277  }
4278 
4282  static void Not( sample& a )
4283  {
4284  a = sample( ~a );
4285  }
4286 
4292  template <typename T>
4293  static void Not( sample& a, T b )
4294  {
4295  a = sample( ~ToSample( b ) );
4296  }
4297 
4303  template <typename T>
4304  static void Nand( sample& a, T b )
4305  {
4306  a = sample( ~(a & ToSample( b )) );
4307  }
4308 
4314  template <typename T>
4315  static void Xor( sample& a, T b )
4316  {
4317  a ^= ToSample( b );
4318  }
4319 
4325  template <typename T>
4326  static void Xnor( sample& a, T b )
4327  {
4328  a = sample( ~(a ^ ToSample( b )) );
4329  }
4330 
4336  template <typename T>
4337  static void ColorBurn( sample& a, T b )
4338  {
4339  float fa; FromSample( fa, a );
4340  float fb; FromSample( fb, ToSample( b ) );
4341  a = ToSample( 1 - pcl::Min( (1 - fa)/pcl::Max( EPSILON_F, fb ), 1.0F ) );
4342  }
4343 
4344  static void ColorBurn( sample& a, float b )
4345  {
4346  float fa; FromSample( fa, a );
4347  a = ToSample( 1 - pcl::Min( (1 - fa)/pcl::Max( EPSILON_F, b ), 1.0F ) );
4348  }
4349 
4350  static void ColorBurn( sample& a, double b )
4351  {
4352  double fa; FromSample( fa, a );
4353  a = ToSample( 1 - pcl::Min( (1 - fa)/pcl::Max( EPSILON_D, b ), 1.0 ) );
4354  }
4355 
4361  template <typename T>
4362  static void LinearBurn( sample& a, T b )
4363  {
4364  float fa; FromSample( fa, a );
4365  float fb; FromSample( fb, ToSample( b ) );
4366  a = ToSample( fa + fb - 1 );
4367  }
4368 
4369  static void LinearBurn( sample& a, float b )
4370  {
4371  float fa; FromSample( fa, a );
4372  a = ToSample( fa + b - 1 );
4373  }
4374 
4375  static void LinearBurn( sample& a, double b )
4376  {
4377  double fa; FromSample( fa, a );
4378  a = ToSample( fa + b - 1 );
4379  }
4380 
4386  template <typename T>
4387  static void Screen( sample& a, T b )
4388  {
4389  float fa; FromSample( fa, a );
4390  float fb; FromSample( fb, ToSample( b ) );
4391  a = ToSample( 1 - (1 - fa)*(1 - fb) );
4392  }
4393 
4394  static void Screen( sample& a, float b )
4395  {
4396  float fa; FromSample( fa, a );
4397  a = ToSample( 1 - (1 - fa)*(1 - b) );
4398  }
4399 
4400  static void Screen( sample& a, double b )
4401  {
4402  double fa; FromSample( fa, a );
4403  a = ToSample( 1 - (1 - fa)*(1 - b) );
4404  }
4405 
4411  template <typename T>
4412  static void ColorDodge( sample& a, T b )
4413  {
4414  float fa; FromSample( fa, a );
4415  float fb; FromSample( fb, ToSample( b ) );
4416  a = ToSample( pcl::Min( fa/pcl::Max( EPSILON_F, 1 - fb ), 1.0F ) );
4417  }
4418 
4419  static void ColorDodge( sample& a, float b )
4420  {
4421  float fa; FromSample( fa, a );
4422  a = ToSample( pcl::Min( fa/pcl::Max( EPSILON_F, 1 - b ), 1.0F ) );
4423  }
4424 
4425  static void ColorDodge( sample& a, double b )
4426  {
4427  double fa; FromSample( fa, a );
4428  a = ToSample( pcl::Min( fa/pcl::Max( EPSILON_D, 1 - b ), 1.0 ) );
4429  }
4430 
4436  template <typename T>
4437  static void Overlay( sample& a, T b )
4438  {
4439  float fa; FromSample( fa, a );
4440  float fb; FromSample( fb, ToSample( b ) );
4441  a = ToSample( (fa > 0.5F) ? 1 - ((1 - 2*(fa - 0.5F)) * (1 - fb)) : 2*a*fb );
4442  }
4443 
4444  static void Overlay( sample& a, float b )
4445  {
4446  float fa; FromSample( fa, a );
4447  a = ToSample( (fa > 0.5F) ? 1 - ((1 - 2*(fa - 0.5F)) * (1 - b)) : 2*a*b );
4448  }
4449 
4450  static void Overlay( sample& a, double b )
4451  {
4452  double fa; FromSample( fa, a );
4453  a = ToSample( (fa > 0.5) ? 1 - ((1 - 2*(fa - 0.5)) * (1 - b)) : 2*a*b );
4454  }
4455 
4461  template <typename T>
4462  static void SoftLight( sample& a, T b )
4463  {
4464  float fa; FromSample( fa, a );
4465  float fb; FromSample( fb, ToSample( b ) );
4466  a = ToSample( (fb > 0.5F) ? 1 - (1 - fa)*(1 - fb - 0.5F) : a*(fb + 0.5F) );
4467  }
4468 
4469  static void SoftLight( sample& a, float b )
4470  {
4471  float fa; FromSample( fa, a );
4472  a = ToSample( (b > 0.5F) ? 1 - (1 - fa)*(1 - b - 0.5F) : a*(b + 0.5F) );
4473  }
4474 
4475  static void SoftLight( sample& a, double b )
4476  {
4477  double fa; FromSample( fa, a );
4478  a = ToSample( (b > 0.5) ? 1 - (1 - fa)*(1 - b - 0.5) : a*(b + 0.5) );
4479  }
4480 
4486  template <typename T>
4487  static void HardLight( sample& a, T b )
4488  {
4489  float fa; FromSample( fa, a );
4490  float fb; FromSample( fb, ToSample( b ) );
4491  a = ToSample( (fb > 0.5F) ? 1 - (1 - fa)*(1 - 2*(fb - 0.5F)) : 2*fa*fb );
4492  }
4493 
4494  static void HardLight( sample& a, float b )
4495  {
4496  float fa; FromSample( fa, a );
4497  a = ToSample( (b > 0.5F) ? 1 - (1 - fa)*(1 - 2*(b - 0.5F)) : 2*fa*b );
4498  }
4499 
4500  static void HardLight( sample& a, double b )
4501  {
4502  double fa; FromSample( fa, a );
4503  a = ToSample( (b > 0.5) ? 1 - (1 - fa)*(1 - 2*(b - 0.5)) : 2*fa*b );
4504  }
4505 
4511  template <typename T>
4512  static void VividLight( sample& a, T b )
4513  {
4514  float fa; FromSample( fa, a );
4515  float fb; FromSample( fb, ToSample( b ) );
4516  a = ToSample( (fb > 0.5F) ? 1 - pcl::Max( (1 - fa)/(fb - 0.5F)/2, 1.0F ) : pcl::Min( fa/pcl::Max( EPSILON_F, 1 - 2*fb ), 1.0F ) );
4517  }
4518 
4519  static void VividLight( sample& a, float b )
4520  {
4521  float fa; FromSample( fa, a );
4522  a = ToSample( (b > 0.5F) ? 1 - pcl::Max( (1 - fa)/(b - 0.5F)/2, 1.0F ) : pcl::Min( fa/pcl::Max( EPSILON_F, 1 - 2*b ), 1.0F ) );
4523  }
4524 
4525  static void VividLight( sample& a, double b )
4526  {
4527  double fa; FromSample( fa, a );
4528  a = ToSample( (b > 0.5) ? 1 - pcl::Max( (1 - fa)/(b - 0.5)/2, 1.0 ) : pcl::Min( fa/pcl::Max( EPSILON_D, 1 - 2*b ), 1.0 ) );
4529  }
4530 
4536  template <typename T>
4537  static void LinearLight( sample& a, T b )
4538  {
4539  float fa; FromSample( fa, a );
4540  float fb; FromSample( fb, ToSample( b ) );
4541  a = ToSample( (fb > 0.5F) ? pcl::Max( fa + 2*(fb - 0.5F), 1.0F ) : pcl::Max( fa + 2*fb - 1, 1.0F ) );
4542  }
4543 
4544  static void LinearLight( sample& a, float b )
4545  {
4546  float fa; FromSample( fa, a );
4547  a = ToSample( (b > 0.5F) ? pcl::Max( fa + 2*(b - 0.5F), 1.0F ) : pcl::Max( fa + 2*b - 1, 1.0F ) );
4548  }
4549 
4550  static void LinearLight( sample& a, double b )
4551  {
4552  double fa; FromSample( fa, a );
4553  a = ToSample( (b > 0.5) ? pcl::Max( fa + 2*(b - 0.5), 1.0 ) : pcl::Max( fa + 2*b - 1, 1.0 ) );
4554  }
4555 
4561  template <typename T>
4562  static void PinLight( sample& a, T b )
4563  {
4564  float fa; FromSample( fa, a );
4565  float fb; FromSample( fb, ToSample( b ) );
4566  a = ToSample( (fb > 0.5F) ? pcl::Max( fa, 2*(fb - 0.5F) ) : pcl::Min( fa, 2*fb ) );
4567  }
4568 
4569  static void PinLight( sample& a, float b )
4570  {
4571  float fa; FromSample( fa, a );
4572  a = ToSample( (b > 0.5F) ? pcl::Max( fa, 2*(b - 0.5F) ) : pcl::Min( fa, 2*b ) );
4573  }
4574 
4575  static void PinLight( sample& a, double b )
4576  {
4577  double fa; FromSample( fa, a );
4578  a = ToSample( (b > 0.5) ? pcl::Max( fa, 2*(b - 0.5) ) : pcl::Min( fa, 2*b ) );
4579  }
4580 
4586  template <typename T>
4587  static void Exclusion( sample& a, T b )
4588  {
4589  float fa; FromSample( fa, a );
4590  float fb; FromSample( fb, ToSample( b ) );
4591  a = ToSample( pcl::Range( 0.5F - 2*(fa - 0.5F)*(fb - 0.5F), 0.0F, 1.0F ) );
4592  }
4593 
4594  static void Exclusion( sample& a, float b )
4595  {
4596  float fa; FromSample( fa, a );
4597  a = ToSample( pcl::Range( 0.5F - 2*(fa - 0.5F)*(b - 0.5F), 0.0F, 1.0F ) );
4598  }
4599 
4600  static void Exclusion( sample& a, double b )
4601  {
4602  double fa; FromSample( fa, a );
4603  a = ToSample( pcl::Range( 0.5 - 2*(fa - 0.5)*(b - 0.5), 0.0, 1.0 ) );
4604  }
4605 
4606  // -------------------------------------------------------------------------
4607 
4608  IMPLEMENT_TRANSFER_OPERATIONS
4609 };
4610 
4611 // ----------------------------------------------------------------------------
4612 
4623 class PCL_CLASS UInt32PixelTraits : public GenericPixelTraits<uint32>
4624 {
4625 public:
4626 
4631 
4636 
4641  static constexpr bool IsFloatSample()
4642  {
4643  return false;
4644  }
4645 
4650  static constexpr bool IsComplexSample()
4651  {
4652  return false;
4653  }
4654 
4661  static constexpr const char* SampleFormat()
4662  {
4663  return "UInt32";
4664  }
4665 
4671  static constexpr sample MaxSampleValue()
4672  {
4673  return uint32_max;
4674  }
4675 
4679  template <typename T>
4680  static sample FloatToSample( T x )
4681  {
4682 #ifdef __PCL_ENFORCE_PIXTRAITS_FLOAT_RANGE
4683  return sample( pcl::Range( Round( x ), T( 0 ), T( uint32_max ) ) );
4684 #else
4685  // ### N.B.: x must be in the range [0,uint32_max].
4686  return sample( RoundI64( x ) );
4687 #endif
4688  }
4689 
4693  static sample ToSample( uint8 x )
4694  {
4695 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
4696  return sample( x )*sample( uint8_to_uint32 );
4697 #else
4698  return p32LUT8[x];
4699 #endif
4700  }
4701 
4705  static sample ToSample( int8 x )
4706  {
4707 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
4708  return sample( uint32( int32( x ) - int32( int8_min ) )*uint8_to_uint32 );
4709 #else
4710  return p32LUT8[int( x ) - int( int8_min )];
4711 #endif
4712  }
4713 
4717  static sample ToSample( uint16 x )
4718  {
4719 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
4720  return sample( x )*sample( uint16_to_uint32 );
4721 #else
4722  return p32LUT16[x];
4723 #endif
4724  }
4725 
4729  static sample ToSample( int16 x )
4730  {
4731 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
4732  return sample( uint32( int32( x ) - int32( int16_min ) )*uint16_to_uint32 );
4733 #else
4734  return p32LUT16[int( x ) - int( int16_min )];
4735 #endif
4736  }
4737 
4741  static constexpr sample ToSample( uint32 x )
4742  {
4743  return sample( x );
4744  }
4745 
4749  static constexpr sample ToSample( int32 x )
4750  {
4751  return sample( double( x ) - double( int32_min ) );
4752  }
4753 
4757  static sample ToSample( float x )
4758  {
4759  return FloatToSample( double( x )*uint32_max );
4760  }
4761 
4767  static sample ToSampleConstrained( float x )
4768  {
4769  return FloatToSample( pcl::Range( double( x ), 0.0, 1.0 )*uint32_max );
4770  }
4771 
4775  static sample ToSample( double x )
4776  {
4777  return FloatToSample( x*uint32_max );
4778  }
4779 
4785  static sample ToSampleConstrained( double x )
4786  {
4787  return FloatToSample( pcl::Range( x, 0.0, 1.0 )*uint32_max );
4788  }
4789 
4793  template <typename T>
4794  static sample ToSample( const Complex<T>& x )
4795  {
4796  return ToSample( pcl::Abs( x ) );
4797  }
4798 
4802  static void FromSample( uint8& a, sample b )
4803  {
4804  a = uint8( RoundInt( double( b )*uint32_to_uint8 ) );
4805  }
4806 
4810  static void FromSample( int8& a, sample b )
4811  {
4812  a = int8( RoundInt( double( b )*uint32_to_uint8 ) + int8_min );
4813  }
4814 
4818  static void FromSample( uint16& a, sample b )
4819  {
4820  a = uint16( RoundInt( double( b )*uint32_to_uint16 ) );
4821  }
4822 
4826  static void FromSample( int16& a, sample b )
4827  {
4828  a = int16( RoundInt( double( b )*uint32_to_uint16 ) + int16_min );
4829  }
4830 
4834  static void FromSample( uint32& a, sample b )
4835  {
4836  a = uint32( b );
4837  }
4838 
4842  static void FromSample( int32& a, sample b )
4843  {
4844  a = TruncInt( double( b ) + int32_min );
4845  }
4846 
4850  static void FromSample( float& a, sample b )
4851  {
4852  a = float( double( b )/uint32_max );
4853  }
4854 
4858  static void FromSample( double& a, sample b )
4859  {
4860  a = double( b )/uint32_max;
4861  }
4862 
4866  template <typename T>
4867  static void FromSample( Complex<T>& a, sample b )
4868  {
4869  typename Complex<T>::component c;
4870  FromSample( c, b );
4871  a = c;
4872  }
4873 
4878  template <typename T>
4879  static void Mov( sample& a, T b )
4880  {
4881  a = ToSample( b );
4882  }
4883 
4888  template <typename T>
4889  static void Add( sample& a, T b )
4890  {
4891  a = sample( pcl::Range( double( a ) + double( ToSample( b ) ),
4892  0.0, double( uint32_max ) ) );
4893  }
4894 
4899  template <typename T>
4900  static void Sub( sample& a, T b )
4901  {
4902  a = sample( pcl::Range( double( a ) - double( ToSample( b ) ),
4903  0.0, double( uint32_max ) ) );
4904  }
4905 
4910  template <typename T>
4911  static void Mul( sample& a, T b )
4912  {
4913  double fa; FromSample( fa, a );
4914  double fb; FromSample( fb, ToSample( b ) );
4915  a = ToSample( fa * fb );
4916  }
4917 
4920  static void Mul( sample& a, float b )
4921  {
4922  double fa; FromSample( fa, a );
4923  a = ToSample( fa * b );
4924  }
4925 
4928  static void Mul( sample& a, double b )
4929  {
4930  double fa; FromSample( fa, a );
4931  a = ToSample( fa * b );
4932  }
4933 
4936  static void Mul( sample& a, pcl::Complex<float> b )
4937  {
4938  double fa; FromSample( fa, a );
4939  a = ToSample( fa * b );
4940  }
4941 
4944  static void Mul( sample& a, pcl::Complex<double> b )
4945  {
4946  double fa; FromSample( fa, a );
4947  a = ToSample( fa * b );
4948  }
4949 
4954  template <typename T>
4955  static void Div( sample& a, T b )
4956  {
4957  a = FloatToSample( double( a )/double( ToSample( b ) ) );
4958  }
4959 
4962  static void Div( sample& a, float b )
4963  {
4964  double fa; FromSample( fa, a );
4965  a = ToSample( fa / b );
4966  }
4967 
4970  static void Div( sample& a, double b )
4971  {
4972  double fa; FromSample( fa, a );
4973  a = ToSample( fa / b );
4974  }
4975 
4978  static void Div( sample& a, pcl::Complex<float> b )
4979  {
4980  double fa; FromSample( fa, a );
4981  a = ToSample( fa / b );
4982  }
4983 
4986  static void Div( sample& a, pcl::Complex<double> b )
4987  {
4988  double fa; FromSample( fa, a );
4989  a = ToSample( fa / b );
4990  }
4991 
4996  template <typename T>
4997  static void Pow( sample& a, T b )
4998  {
4999  double fa; FromSample( fa, a );
5000  double fb; FromSample( fb, ToSample( b ) );
5001  a = ToSample( pcl::Pow( fa, fb ) );
5002  }
5003 
5006  static void Pow( sample& a, float b )
5007  {
5008  double fa; FromSample( fa, a );
5009  a = ToSample( pcl::Pow( fa, double( b ) ) );
5010  }
5011 
5014  static void Pow( sample& a, double b )
5015  {
5016  double fa; FromSample( fa, a );
5017  a = ToSample( pcl::Pow( fa, b ) );
5018  }
5019 
5022  static void Pow( sample& a, pcl::Complex<float> b )
5023  {
5024  double fa; FromSample( fa, a );
5025  a = ToSample( pcl::Pow( fa, pcl::Complex<double>( b ) ) );
5026  }
5027 
5030  static void Pow( sample& a, pcl::Complex<double> b )
5031  {
5032  double fa; FromSample( fa, a );
5033  a = ToSample( pcl::Pow( fa, b ) );
5034  }
5035 
5040  template <typename T>
5041  static void Dif( sample& a, T b )
5042  {
5043  a = sample( pcl::Range( pcl::Abs( double( a ) - double( ToSample( b ) ) ),
5044  0.0, double( uint32_max ) ) );
5045  }
5046 
5051  template <typename T>
5052  static void Min( sample& a, T b )
5053  {
5054  a = sample( pcl::Min( a, ToSample( b ) ) );
5055  }
5056 
5061  template <typename T>
5062  static void Max( sample& a, T b )
5063  {
5064  a = sample( pcl::Max( a, ToSample( b ) ) );
5065  }
5066 
5072  template <typename T>
5073  static void Or( sample& a, T b )
5074  {
5075  a |= ToSample( b );
5076  }
5077 
5083  template <typename T>
5084  static void Nor( sample& a, T b )
5085  {
5086  a = ~(a | ToSample( b ));
5087  }
5088 
5094  template <typename T>
5095  static void And( sample& a, T b )
5096  {
5097  a &= ToSample( b );
5098  }
5099 
5103  static void Not( sample& a )
5104  {
5105  a = sample( ~a );
5106  }
5107 
5113  template <typename T>
5114  static void Not( sample& a, T b )
5115  {
5116  a = sample( ~ToSample( b ) );
5117  }
5118 
5124  template <typename T>
5125  static void Nand( sample& a, T b )
5126  {
5127  a = sample( ~(a & ToSample( b )) );
5128  }
5129 
5135  template <typename T>
5136  static void Xor( sample& a, T b )
5137  {
5138  a ^= ToSample( b );
5139  }
5140 
5146  template <typename T>
5147  static void Xnor( sample& a, T b )
5148  {
5149  a = sample( ~(a ^ ToSample( b )) );
5150  }
5151 
5157  template <typename T>
5158  static void ColorBurn( sample& a, T b )
5159  {
5160  double fa; FromSample( fa, a );
5161  double fb; FromSample( fb, ToSample( b ) );
5162  a = ToSample( 1 - pcl::Min( (1 - fa)/pcl::Max( EPSILON_D, fb ), 1.0 ) );
5163  }
5164 
5165  static void ColorBurn( sample& a, float b )
5166  {
5167  double fa; FromSample( fa, a );
5168  a = ToSample( 1 - pcl::Min( (1 - fa)/pcl::Max( EPSILON_D, double( b ) ), 1.0 ) );
5169  }
5170 
5171  static void ColorBurn( sample& a, double b )
5172  {
5173  double fa; FromSample( fa, a );
5174  a = ToSample( 1 - pcl::Min( (1 - fa)/pcl::Max( EPSILON_D, b ), 1.0 ) );
5175  }
5176 
5182  template <typename T>
5183  static void LinearBurn( sample& a, T b )
5184  {
5185  double fa; FromSample( fa, a );
5186  double fb; FromSample( fb, ToSample( b ) );
5187  a = ToSample( fa + fb - 1 );
5188  }
5189 
5190  static void LinearBurn( sample& a, float b )
5191  {
5192  double fa; FromSample( fa, a );
5193  a = ToSample( fa + double( b ) - 1 );
5194  }
5195 
5196  static void LinearBurn( sample& a, double b )
5197  {
5198  double fa; FromSample( fa, a );
5199  a = ToSample( fa + b - 1 );
5200  }
5201 
5207  template <typename T>
5208  static void Screen( sample& a, T b )
5209  {
5210  double fa; FromSample( fa, a );
5211  double fb; FromSample( fb, ToSample( b ) );
5212  a = ToSample( 1 - (1 - fa)*(1 - fb) );
5213  }
5214 
5215  static void Screen( sample& a, float b )
5216  {
5217  double fa; FromSample( fa, a );
5218  a = ToSample( 1 - (1 - fa)*(1 - double( b )) );
5219  }
5220 
5221  static void Screen( sample& a, double b )
5222  {
5223  double fa; FromSample( fa, a );
5224  a = ToSample( 1 - (1 - fa)*(1 - b) );
5225  }
5226 
5232  template <typename T>
5233  static void ColorDodge( sample& a, T b )
5234  {
5235  double fa; FromSample( fa, a );
5236  double fb; FromSample( fb, ToSample( b ) );
5237  a = ToSample( pcl::Min( fa/pcl::Max( EPSILON_D, 1 - fb ), 1.0 ) );
5238  }
5239 
5240  static void ColorDodge( sample& a, float b )
5241  {
5242  double fa; FromSample( fa, a );
5243  a = ToSample( pcl::Min( fa/pcl::Max( EPSILON_D, 1 - double( b ) ), 1.0 ) );
5244  }
5245 
5246  static void ColorDodge( sample& a, double b )
5247  {
5248  double fa; FromSample( fa, a );
5249  a = ToSample( pcl::Min( fa/pcl::Max( EPSILON_D, 1 - b ), 1.0 ) );
5250  }
5251 
5257  template <typename T>
5258  static void Overlay( sample& a, T b )
5259  {
5260  double fa; FromSample( fa, a );
5261  double fb; FromSample( fb, ToSample( b ) );
5262  a = ToSample( (fa > 0.5) ? 1 - ((1 - 2*(fa - 0.5)) * (1 - fb)) : 2*a*fb );
5263  }
5264 
5265  static void Overlay( sample& a, float b )
5266  {
5267  double fa; FromSample( fa, a );
5268  a = ToSample( (fa > 0.5) ? 1 - ((1 - 2*(fa - 0.5)) * (1 - double( b ))) : 2*a*double( b ) );
5269  }
5270 
5271  static void Overlay( sample& a, double b )
5272  {
5273  double fa; FromSample( fa, a );
5274  a = ToSample( (fa > 0.5) ? 1 - ((1 - 2*(fa - 0.5)) * (1 - b)) : 2*a*b );
5275  }
5276 
5282  template <typename T>
5283  static void SoftLight( sample& a, T b )
5284  {
5285  double fa; FromSample( fa, a );
5286  double fb; FromSample( fb, ToSample( b ) );
5287  a = ToSample( (fb > 0.5) ? 1 - (1 - fa)*(1 - fb - 0.5) : a*(fb + 0.5) );
5288  }
5289 
5290  static void SoftLight( sample& a, float b )
5291  {
5292  double fa; FromSample( fa, a );
5293  double fb = double( b );
5294  a = ToSample( (fb > 0.5) ? 1 - (1 - fa)*(1 - fb - 0.5) : a*(fb + 0.5) );
5295  }
5296 
5297  static void SoftLight( sample& a, double b )
5298  {
5299  double fa; FromSample( fa, a );
5300  a = ToSample( (b > 0.5) ? 1 - (1 - fa)*(1 - b - 0.5) : a*(b + 0.5) );
5301  }
5302 
5308  template <typename T>
5309  static void HardLight( sample& a, T b )
5310  {
5311  double fa; FromSample( fa, a );
5312  double fb; FromSample( fb, ToSample( b ) );
5313  a = ToSample( (fb > 0.5) ? 1 - (1 - fa)*(1 - 2*(fb - 0.5)) : 2*fa*fb );
5314  }
5315 
5316  static void HardLight( sample& a, float b )
5317  {
5318  double fa; FromSample( fa, a );
5319  double fb = double( b );
5320  a = ToSample( (fb > 0.5) ? 1 - (1 - fa)*(1 - 2*(fb - 0.5)) : 2*fa*fb );
5321  }
5322 
5323  static void HardLight( sample& a, double b )
5324  {
5325  double fa; FromSample( fa, a );
5326  a = ToSample( (b > 0.5) ? 1 - (1 - fa)*(1 - 2*(b - 0.5)) : 2*fa*b );
5327  }
5328 
5334  template <typename T>
5335  static void VividLight( sample& a, T b )
5336  {
5337  double fa; FromSample( fa, a );
5338  double fb; FromSample( fb, ToSample( b ) );
5339  a = ToSample( (fb > 0.5) ? 1 - pcl::Max( (1 - fa)/(fb - 0.5)/2, 1.0 ) : pcl::Min( fa/pcl::Max( EPSILON_D, 1 - 2*fb ), 1.0 ) );
5340  }
5341 
5342  static void VividLight( sample& a, float b )
5343  {
5344  double fa; FromSample( fa, a );
5345  double fb = double( b );
5346  a = ToSample( (fb > 0.5) ? 1 - pcl::Max( (1 - fa)/(fb - 0.5)/2, 1.0 ) : pcl::Min( fa/pcl::Max( EPSILON_D, 1 - 2*fb ), 1.0 ) );
5347  }
5348 
5349  static void VividLight( sample& a, double b )
5350  {
5351  double fa; FromSample( fa, a );
5352  a = ToSample( (b > 0.5) ? 1 - pcl::Max( (1 - fa)/(b - 0.5)/2, 1.0 ) : pcl::Min( fa/pcl::Max( EPSILON_D, 1 - 2*b ), 1.0 ) );
5353  }
5354 
5360  template <typename T>
5361  static void LinearLight( sample& a, T b )
5362  {
5363  double fa; FromSample( fa, a );
5364  double fb; FromSample( fb, ToSample( b ) );
5365  a = ToSample( (fb > 0.5) ? pcl::Max( fa + 2*(fb - 0.5), 1.0 ) : pcl::Max( fa + 2*fb - 1, 1.0 ) );
5366  }
5367 
5368  static void LinearLight( sample& a, float b )
5369  {
5370  double fa; FromSample( fa, a );
5371  double fb = double( b );
5372  a = ToSample( (fb > 0.5) ? pcl::Max( fa + 2*(fb - 0.5), 1.0 ) : pcl::Max( fa + 2*fb - 1, 1.0 ) );
5373  }
5374 
5375  static void LinearLight( sample& a, double b )
5376  {
5377  double fa; FromSample( fa, a );
5378  a = ToSample( (b > 0.5) ? pcl::Max( fa + 2*(b - 0.5), 1.0 ) : pcl::Max( fa + 2*b - 1, 1.0 ) );
5379  }
5380 
5386  template <typename T>
5387  static void PinLight( sample& a, T b )
5388  {
5389  double fa; FromSample( fa, a );
5390  double fb; FromSample( fb, ToSample( b ) );
5391  a = ToSample( (fb > 0.5) ? pcl::Max( fa, 2*(fb - 0.5) ) : pcl::Min( fa, 2*fb ) );
5392  }
5393 
5394  static void PinLight( sample& a, float b )
5395  {
5396  double fa; FromSample( fa, a );
5397  double fb = double( b );
5398  a = ToSample( (fb > 0.5) ? pcl::Max( fa, 2*(fb - 0.5) ) : pcl::Min( fa, 2*fb ) );
5399  }
5400 
5401  static void PinLight( sample& a, double b )
5402  {
5403  double fa; FromSample( fa, a );
5404  a = ToSample( (b > 0.5) ? pcl::Max( fa, 2*(b - 0.5) ) : pcl::Min( fa, 2*b ) );
5405  }
5406 
5412  template <typename T>
5413  static void Exclusion( sample& a, T b )
5414  {
5415  double fa; FromSample( fa, a );
5416  double fb; FromSample( fb, ToSample( b ) );
5417  a = ToSample( pcl::Range( 0.5 - 2*(fa - 0.5)*(fb - 0.5), 0.0, 1.0 ) );
5418  }
5419 
5420  static void Exclusion( sample& a, float b )
5421  {
5422  double fa; FromSample( fa, a );
5423  a = ToSample( pcl::Range( 0.5 - 2*(fa - 0.5)*(double( b ) - 0.5), 0.0, 1.0 ) );
5424  }
5425 
5426  static void Exclusion( sample& a, double b )
5427  {
5428  double fa; FromSample( fa, a );
5429  a = ToSample( pcl::Range( 0.5 - 2*(fa - 0.5)*(b - 0.5), 0.0, 1.0 ) );
5430  }
5431 
5432  // -------------------------------------------------------------------------
5433 
5434  IMPLEMENT_TRANSFER_OPERATIONS
5435 };
5436 
5437 // ----------------------------------------------------------------------------
5438 
5451 class PCL_CLASS UInt20PixelTraits : public GenericPixelTraits<uint32>
5452 {
5453 public:
5454 
5459 
5464 
5469  static constexpr bool IsFloatSample()
5470  {
5471  return false;
5472  }
5473 
5478  static constexpr bool IsComplexSample()
5479  {
5480  return false;
5481  }
5482 
5489  static constexpr const char* SampleFormat()
5490  {
5491  return "UInt20";
5492  }
5493 
5499  static constexpr sample MaxSampleValue()
5500  {
5501  return uint20_max;
5502  }
5503 
5507  template <typename T>
5508  static sample FloatToSample( T x )
5509  {
5510 #ifdef __PCL_ENFORCE_PIXTRAITS_FLOAT_RANGE
5511  return sample( pcl::Range( Round( x ), T( 0 ), T( uint20_max ) ) );
5512 #else
5513  // ### N.B.: x must be in the range [0,uint20_max].
5514  return sample( RoundInt( x ) );
5515 #endif
5516  }
5517 
5521  static sample ToSample( uint8 x )
5522  {
5523 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
5524  return sample( RoundInt( x * uint8_to_uint20 ) );
5525 #else
5526  return p20LUT8[x];
5527 #endif
5528  }
5529 
5533  static sample ToSample( int8 x )
5534  {
5535 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
5536  return sample( RoundInt( (int32( x ) - int32( int8_min ))*uint8_to_uint20 ) );
5537 #else
5538  return p20LUT8[int( x ) - int( int8_min )];
5539 #endif
5540  }
5541 
5545  static sample ToSample( uint16 x )
5546  {
5547 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
5548  return sample( RoundInt( x * uint16_to_uint20 ) );
5549 #else
5550  return p20LUT16[x];
5551 #endif
5552  }
5553 
5557  static sample ToSample( int16 x )
5558  {
5559 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
5560  return sample( RoundInt( (int32( x ) - int32( int16_min ))*uint16_to_uint20 ) );
5561 #else
5562  return p20LUT16[int( x ) - int( int16_min )];
5563 #endif
5564  }
5565 
5569  static sample ToSample( uint32 x )
5570  {
5571  return sample( RoundInt( x * uint32_to_uint20 ) );
5572  }
5573 
5577  static sample ToSample( int32 x )
5578  {
5579  return sample( RoundInt( (double( x ) - int32_min)*uint32_to_uint20 ) );
5580  }
5581 
5585  static sample ToSample( float x )
5586  {
5587  return FloatToSample( x*uint20_max );
5588  }
5589 
5595  static sample ToSampleConstrained( float x )
5596  {
5597  return FloatToSample( pcl::Range( x, 0.0F, 1.0F )*uint20_max );
5598  }
5599 
5603  static sample ToSample( double x )
5604  {
5605  return FloatToSample( x*uint20_max );
5606  }
5607 
5613  static sample ToSampleConstrained( double x )
5614  {
5615  return FloatToSample( pcl::Range( x, 0.0, 1.0 )*uint20_max );
5616  }
5617 
5621  template <typename T>
5622  static constexpr sample ToSample( const Complex<T>& x )
5623  {
5624  return ToSample( pcl::Abs( x ) );
5625  }
5626 
5630  static void FromSample( uint8& a, sample b )
5631  {
5632 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
5633  a = uint8( RoundInt( b * uint20_to_uint8 ) );
5634 #else
5635  a = p8LUT20[b];
5636 #endif
5637  }
5638 
5642  static void FromSample( int8& a, sample b )
5643  {
5644 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
5645  a = int8( RoundInt( b * uint20_to_uint8 ) + int8_min );
5646 #else
5647  a = int8( int( p8LUT20[b] ) + int( int8_min ) );
5648 #endif
5649  }
5650 
5654  static void FromSample( uint16& a, sample b )
5655  {
5656 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
5657  a = uint16( RoundInt( b * uint20_to_uint16 ) );
5658 #else
5659  a = p16LUT20[b];
5660 #endif
5661  }
5662 
5666  static void FromSample( int16& a, sample b )
5667  {
5668 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
5669  a = int16( RoundInt( b * uint20_to_uint16 ) + int16_min );
5670 #else
5671  a = int16( int( p16LUT20[b] ) + int( int16_min ) );
5672 #endif
5673  }
5674 
5678  static void FromSample( uint32& a, sample b )
5679  {
5680 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
5681  a = uint32( RoundInt( b * uint20_to_uint32 ) );
5682 #else
5683  a = p32LUT20[b];
5684 #endif
5685  }
5686 
5690  static void FromSample( int32& a, sample b )
5691  {
5692 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
5693  a = int32( RoundInt( b * uint20_to_uint32 ) + int32_min );
5694 #else
5695  a = int32( int64( p32LUT20[b] ) + int64( int32_min ) );
5696 #endif
5697  }
5698 
5702  static void FromSample( float& a, sample b )
5703  {
5704 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
5705  a = float( b )/uint20_max;
5706 #else
5707  a = pFLUT20[b];
5708 #endif
5709  }
5710 
5714  static void FromSample( double& a, sample b )
5715  {
5716 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
5717  a = double( b )/uint20_max;
5718 #else
5719  a = pDLUT20[b];
5720 #endif
5721  }
5722 
5726  template <typename T>
5727  static void FromSample( Complex<T>& a, sample b )
5728  {
5729  typename Complex<T>::component c;
5730  FromSample( c, b );
5731  a = c;
5732  }
5733 };
5734 
5735 // ----------------------------------------------------------------------------
5736 
5749 class PCL_CLASS UInt24PixelTraits : public GenericPixelTraits<uint32>
5750 {
5751 public:
5752 
5757 
5762 
5767  static constexpr bool IsFloatSample()
5768  {
5769  return false;
5770  }
5771 
5776  static constexpr bool IsComplexSample()
5777  {
5778  return false;
5779  }
5780 
5787  static constexpr const char* SampleFormat()
5788  {
5789  return "UInt24";
5790  }
5791 
5797  static constexpr sample MaxSampleValue()
5798  {
5799  return uint24_max;
5800  }
5801 
5805  template <typename T>
5806  static sample FloatToSample( T x )
5807  {
5808 #ifdef __PCL_ENFORCE_PIXTRAITS_FLOAT_RANGE
5809  return sample( pcl::Range( Round( x ), T( 0 ), T( uint24_max ) ) );
5810 #else
5811  // ### N.B.: x must be in the range [0,uint24_max].
5812  return sample( RoundInt( x ) );
5813 #endif
5814  }
5815 
5819  static sample ToSample( uint8 x )
5820  {
5821 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
5822  return sample( x * uint8_to_uint24 );
5823 #else
5824  return p24LUT8[x];
5825 #endif
5826  }
5827 
5831  static sample ToSample( int8 x )
5832  {
5833 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
5834  return sample( RoundInt( (int32( x ) - int32( int8_min ))*uint8_to_uint24 ) );
5835 #else
5836  return p24LUT8[int( x ) - int( int8_min )];
5837 #endif
5838  }
5839 
5843  static sample ToSample( uint16 x )
5844  {
5845 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
5846  return sample( RoundInt( x * uint16_to_uint24 ) );
5847 #else
5848  return p24LUT16[x];
5849 #endif
5850  }
5851 
5855  static sample ToSample( int16 x )
5856  {
5857 #ifdef __PCL_DONT_USE_PIXTRAITS_LUT
5858  return sample( RoundInt( (int32( x ) - int32( int16_min ))*uint16_to_uint24 ) );
5859 #else
5860  return p24LUT16[int( x ) - int( int16_min )];
5861 #endif
5862  }
5863 
5867  static sample ToSample( uint32 x )
5868  {
5869  return sample( RoundInt( x * uint32_to_uint24 ) );
5870  }
5871 
5875  static sample ToSample( int32 x )
5876  {
5877  return sample( RoundInt( (double( x ) - int32_min)*uint32_to_uint24 ) );
5878  }
5879 
5883  static sample ToSample( float x )
5884  {
5885  return FloatToSample( double( x )*uint24_max );
5886  }
5887 
5893  static sample ToSampleConstrained( float x )
5894  {
5895  return FloatToSample( pcl::Range( double( x ), 0.0, 1.0 )*uint24_max );
5896  }
5897 
5901  static sample ToSample( double x )
5902  {
5903  return FloatToSample( x*uint24_max );
5904  }
5905 
5911  static sample ToSampleConstrained( double x )
5912  {
5913  return FloatToSample( pcl::Range( x, 0.0, 1.0 )*uint24_max );
5914  }
5915 
5919  template <typename T>
5920  static sample ToSample( const Complex<T>& x )
5921  {
5922  return ToSample( pcl::Abs( x ) );
5923  }
5924 
5928  static void FromSample( uint8& a, sample b )
5929  {
5930  a = uint8( RoundInt( b * uint24_to_uint8 ) );
5931  }
5932 
5936  static void FromSample( int8& a, sample b )
5937  {
5938  a = int8( RoundInt( b * uint24_to_uint8 ) + int8_min );
5939  }
5940 
5944  static void FromSample( uint16& a, sample b )
5945  {
5946  a = uint16( RoundInt( b * uint24_to_uint16 ) );
5947  }
5948 
5952  static void FromSample( int16& a, sample b )
5953  {
5954  a = int16( RoundInt( b * uint24_to_uint16 ) + int16_min );
5955  }
5956 
5960  static void FromSample( uint32& a, sample b )
5961  {
5962  a = uint32( RoundInt( b * uint24_to_uint32 ) );
5963  }
5964 
5968  static void FromSample( int32& a, sample b )
5969  {
5970  a = int32( RoundInt( b * uint24_to_uint32 ) + int32_min );
5971  }
5972 
5976  static void FromSample( float& a, sample b )
5977  {
5978  a = float( b )/uint24_max;
5979  }
5980 
5984  static void FromSample( double& a, sample b )
5985  {
5986  a = double( b )/uint24_max;
5987  }
5988 
5992  template <typename T>
5993  static void FromSample( Complex<T>& a, sample b )
5994  {
5995  typename Complex<T>::component c;
5996  FromSample( c, b );
5997  a = c;
5998  }
5999 };
6000 
6001 // ----------------------------------------------------------------------------
6002 
6003 #undef IMPLEMENT_TRANSFER_OPERATIONS
6004 
6005 #undef EPSILON_D
6006 #undef EPSILON_F
6007 
6008 #ifndef __PCL_DONT_USE_PIXTRAITS_LUT
6009 #undef pFLUT8
6010 #undef pFLUTA
6011 #undef p1FLUT8
6012 #undef pFLUT16
6013 #undef pFLUT20
6014 #undef pDLUT8
6015 #undef pDLUTA
6016 #undef p1DLUT8
6017 #undef pDLUT16
6018 #undef pDLUT20
6019 #undef p8LUT16
6020 #undef p8LUT20
6021 #undef p16LUT8
6022 #undef p16LUT20
6023 #undef p20LUT8
6024 #undef p20LUT16
6025 #undef p24LUT8
6026 #undef p24LUT16
6027 #undef p32LUT8
6028 #undef p32LUT16
6029 #undef p32LUT20
6030 #endif
6031 
6032 // ----------------------------------------------------------------------------
6033 
6034 } // pcl
6035 
6036 #endif // __PCL_PixelTraits_h
6037 
6038 // ----------------------------------------------------------------------------
6039 // EOF pcl/PixelTraits.h - Released 2019-11-07T10:59:34Z
static void Or(sample &a, T b)
Definition: PixelTraits.h:3415
static void ColorDodge(sample &a, T b)
Definition: PixelTraits.h:1378
static sample ToSample(float x)
Definition: PixelTraits.h:4757
GenericPixelTraits< uint32 > traits_type
Definition: PixelTraits.h:5458
#define uint24_to_uint32
Definition: Defs.h:946
static void Screen(sample &a, T b)
Definition: PixelTraits.h:5208
static void Mov(sample &a, T b)
Definition: PixelTraits.h:1727
static void FromSample(int16 &a, sample b)
Definition: PixelTraits.h:1095
#define uint8_to_uint20
Definition: Defs.h:844
static sample ToSample(int32 x)
Definition: PixelTraits.h:2351
#define uint24_to_uint16
Definition: Defs.h:934
static void FromSample(Complex< T > &a, sample b)
Definition: PixelTraits.h:2449
static void Xor(sample &a, T b)
Definition: PixelTraits.h:2631
GenericPixelTraits< double > traits_type
Definition: PixelTraits.h:924
static sample ToSample(float x)
Definition: PixelTraits.h:3912
#define uint32_to_uint24
Definition: Defs.h:976
static void FromSample(Complex< T > &a, sample b)
Definition: PixelTraits.h:1136
static void FromSample(float &a, sample b)
Definition: PixelTraits.h:5702
static void ColorDodge(sample &a, T b)
Definition: PixelTraits.h:2733
static void Add(sample &a, T b)
Definition: PixelTraits.h:4889
static sample ToSample(int16 x)
Definition: PixelTraits.h:1599
static sample ToSample(uint8 x)
Definition: PixelTraits.h:5819
#define uint16_to_uint8
Definition: Defs.h:868
static sample ToSample(const Complex< T > &x)
Definition: PixelTraits.h:4794
static sample ToSample(uint16 x)
Definition: PixelTraits.h:1006
static void FromSample(uint16 &a, sample b)
Definition: PixelTraits.h:522
static sample FloatToSample(T x)
Definition: PixelTraits.h:3006
static void Mul(sample &a, pcl::Complex< double > b)
Definition: PixelTraits.h:4944
traits_type::sample sample
Definition: PixelTraits.h:4635
static void Div(sample &a, pcl::Complex< double > b)
Definition: PixelTraits.h:4986
static sample ToSample(int16 x)
Definition: PixelTraits.h:453
static void PinLight(sample &a, T b)
Definition: PixelTraits.h:3725
static void LinearBurn(sample &a, T b)
Definition: PixelTraits.h:2683
static void FromSample(uint16 &a, sample b)
Definition: PixelTraits.h:1087
#define uint32_to_uint16
Definition: Defs.h:964
static void Overlay(sample &a, T b)
Definition: PixelTraits.h:824
static constexpr sample ToSample(float x)
Definition: PixelTraits.h:481
static void Pow(sample &a, pcl::Complex< float > b)
Definition: PixelTraits.h:3364
static sample FloatToSample(T x)
Definition: PixelTraits.h:5508
static void Not(sample &a, T b)
Definition: PixelTraits.h:2604
static sample ToSample(double x)
Definition: PixelTraits.h:3093
static void Overlay(sample &a, T b)
Definition: PixelTraits.h:2026
static sample ToSample(int8 x)
Definition: PixelTraits.h:994
static void Mul(sample &a, pcl::Complex< double > b)
Definition: PixelTraits.h:4123
static constexpr sample ToSample(const Complex< T > &x)
Definition: PixelTraits.h:3949
static void Exclusion(sample &a, T b)
Definition: PixelTraits.h:4587
static constexpr sample MaxSampleValue()
Definition: PixelTraits.h:965
static constexpr sample MaxSampleValue()
Definition: PixelTraits.h:4671
24-bit unsigned integer pixel traits.
Definition: PixelTraits.h:5749
static void LinearBurn(sample &a, T b)
Definition: PixelTraits.h:1356
#define uint16_to_uint24
Definition: Defs.h:880
static void Pow(sample &a, pcl::Complex< double > b)
Definition: PixelTraits.h:5030
int64 RoundI64(double x)
Definition: Math.h:1546
static void Nor(sample &a, T b)
Definition: PixelTraits.h:2565
static void Pow(sample &a, pcl::Complex< double > b)
Definition: PixelTraits.h:4209
64-bit IEEE 754 normalized floating point real pixel traits.
Definition: PixelTraits.h:917
static void FromSample(uint32 &a, sample b)
Definition: PixelTraits.h:1103
static void FromSample(Complex< T > &a, sample b)
Definition: PixelTraits.h:5993
static void Not(sample &a, T b)
Definition: PixelTraits.h:1291
static void LinearBurn(sample &a, T b)
Definition: PixelTraits.h:1951
static void FromSample(int32 &a, sample b)
Definition: PixelTraits.h:3172
static void Exclusion(sample &a, T b)
Definition: PixelTraits.h:2176
unsigned char uint8
Definition: Defs.h:576
static void Screen(sample &a, T b)
Definition: PixelTraits.h:2708
static sample ToSample(int8 x)
Definition: PixelTraits.h:5831
static void FromSample(double &a, sample b)
Definition: PixelTraits.h:3196
static void FromSample(uint32 &a, sample b)
Definition: PixelTraits.h:3160
static void Div(sample &a, double b)
Definition: PixelTraits.h:4970
static void Exclusion(sample &a, T b)
Definition: PixelTraits.h:1460
static void FromSample(double &a, sample b)
Definition: PixelTraits.h:5984
static void VividLight(sample &a, T b)
Definition: PixelTraits.h:4512
static void FromSample(int32 &a, sample b)
Definition: PixelTraits.h:4842
32-bit unsigned integer pixel traits.
Definition: PixelTraits.h:4623
static void Pow(sample &a, T b)
Definition: PixelTraits.h:1777
static constexpr sample ToSample(int32 x)
Definition: PixelTraits.h:473
static void VividLight(sample &a, T b)
Definition: PixelTraits.h:3675
static void And(sample &a, T b)
Definition: PixelTraits.h:4274
int RoundInt(T x)
Definition: Math.h:1397
sample::component component
Definition: PixelTraits.h:2229
static void Sub(sample &a, T b)
Definition: PixelTraits.h:601
static void FromSample(double &a, sample b)
Definition: PixelTraits.h:1127
#define uint16_max
Definition: Defs.h:769
static void Div(sample &a, float b)
Definition: PixelTraits.h:4962
static void Mul(sample &a, double b)
Definition: PixelTraits.h:4928
static void SoftLight(sample &a, T b)
Definition: PixelTraits.h:835
static void Div(sample &a, T b)
Definition: PixelTraits.h:2499
static void Xnor(sample &a, T b)
Definition: PixelTraits.h:767
static void Min(sample &a, T b)
Definition: PixelTraits.h:651
static void Or(sample &a, T b)
Definition: PixelTraits.h:4252
static constexpr const char * SampleFormat()
Definition: PixelTraits.h:4661
static constexpr sample MaxSampleValue()
Definition: PixelTraits.h:3834
signed short int16
Definition: Defs.h:582
static void FromSample(int16 &a, sample b)
Definition: PixelTraits.h:530
static void And(sample &a, T b)
Definition: PixelTraits.h:1847
static sample ToSample(int8 x)
Definition: PixelTraits.h:1575
static constexpr bool IsComplexSample()
Definition: PixelTraits.h:379
static constexpr sample ToSample(uint32 x)
Definition: PixelTraits.h:4741
static constexpr bool IsComplexSample()
Definition: PixelTraits.h:5478
static void And(sample &a, T b)
Definition: PixelTraits.h:1266
static void SoftLight(sample &a, T b)
Definition: PixelTraits.h:3625
PCL root namespace.
Definition: AbstractImage.h:76
static sample ToSample(double x)
Definition: PixelTraits.h:2367
static void Div(sample &a, pcl::Complex< float > b)
Definition: PixelTraits.h:3320
static void Not(sample &a)
Definition: PixelTraits.h:5103
static void FromSample(double &a, sample b)
Definition: PixelTraits.h:5714
static void Add(sample &a, T b)
Definition: PixelTraits.h:1156
static void Sub(sample &a, T b)
Definition: PixelTraits.h:1166
#define int8_min
Definition: Defs.h:733
static void ColorBurn(sample &a, T b)
Definition: PixelTraits.h:1345
static sample ToSample(int8 x)
Definition: PixelTraits.h:429
static void FromSample(uint16 &a, sample b)
Definition: PixelTraits.h:4818
static void Nor(sample &a, T b)
Definition: PixelTraits.h:1252
GenericPixelTraits< uint16 > traits_type
Definition: PixelTraits.h:3793
static void ColorDodge(sample &a, T b)
Definition: PixelTraits.h:2001
static void Mul(sample &a, T b)
Definition: PixelTraits.h:4911
static void HardLight(sample &a, T b)
Definition: PixelTraits.h:3650
static void Not(sample &a)
Definition: PixelTraits.h:4282
static void Or(sample &a, T b)
Definition: PixelTraits.h:673
static void Mul(sample &a, float b)
Definition: PixelTraits.h:4099
static sample ToSample(const Complex< T > &x)
Definition: PixelTraits.h:1644
static void Min(sample &a, T b)
Definition: PixelTraits.h:2529
static void FromSample(int8 &a, sample b)
Definition: PixelTraits.h:5642
static void VividLight(sample &a, T b)
Definition: PixelTraits.h:859
static sample ToSample(int16 x)
Definition: PixelTraits.h:1018
static constexpr sample ToSample(double x)
Definition: PixelTraits.h:489
static void SoftLight(sample &a, T b)
Definition: PixelTraits.h:5283
static void Nand(sample &a, T b)
Definition: PixelTraits.h:739
static sample ToSample(int32 x)
Definition: PixelTraits.h:1619
static void FromSample(float &a, sample b)
Definition: PixelTraits.h:554
static sample FloatToSample(T x)
Definition: PixelTraits.h:5806
static sample ToSample(int32 x)
Definition: PixelTraits.h:5577
static void FromSample(float &a, sample b)
Definition: PixelTraits.h:4021
static void Mov(sample &a, T b)
Definition: PixelTraits.h:4058
static sample ToSample(uint16 x)
Definition: PixelTraits.h:4717
static void SoftLight(sample &a, T b)
Definition: PixelTraits.h:2783
static sample ToSampleConstrained(double x)
Definition: PixelTraits.h:5911
static void Dif(sample &a, T b)
Definition: PixelTraits.h:5041
static sample ToSampleConstrained(double x)
Definition: PixelTraits.h:4785
static void HardLight(sample &a, T b)
Definition: PixelTraits.h:4487
static void Mul(sample &a, pcl::Complex< double > b)
Definition: PixelTraits.h:3286
static void Max(sample &a, T b)
Definition: PixelTraits.h:1226
static sample ToSample(uint8 x)
Definition: PixelTraits.h:4693
static void HardLight(sample &a, T b)
Definition: PixelTraits.h:847
static void FromSample(int8 &a, sample b)
Definition: PixelTraits.h:3128
static sample ToSample(uint16 x)
Definition: PixelTraits.h:5843
static void FromSample(uint16 &a, sample b)
Definition: PixelTraits.h:2400
static void Pow(sample &a, float b)
Definition: PixelTraits.h:3348
static void Mul(sample &a, T b)
Definition: PixelTraits.h:1757
static void Not(sample &a)
Definition: PixelTraits.h:3445
static void Mul(sample &a, double b)
Definition: PixelTraits.h:4107
static sample ToSample(const Complex< T > &x)
Definition: PixelTraits.h:2376
static void ColorBurn(sample &a, T b)
Definition: PixelTraits.h:4337
static void PinLight(sample &a, T b)
Definition: PixelTraits.h:1448
static void Max(sample &a, T b)
Definition: PixelTraits.h:4241
traits_type::sample sample
Definition: PixelTraits.h:364
static void Dif(sample &a, T b)
Definition: PixelTraits.h:2519
static void Nor(sample &a, T b)
Definition: PixelTraits.h:1833
static void FromSample(uint8 &a, sample b)
Definition: PixelTraits.h:1071
static sample ToSample(int8 x)
Definition: PixelTraits.h:5533
static void PinLight(sample &a, T b)
Definition: PixelTraits.h:4562
static constexpr bool IsFloatSample()
Definition: PixelTraits.h:1510
static constexpr sample ToSample(uint32 x)
Definition: PixelTraits.h:1030
static constexpr bool IsComplexSample()
Definition: PixelTraits.h:3813
static void VividLight(sample &a, T b)
Definition: PixelTraits.h:2101
Complex< T > Round(const Complex< T > &c)
Definition: Complex.h:929
static constexpr const char * SampleFormat()
Definition: PixelTraits.h:5489
static void Mul(sample &a, pcl::Complex< float > b)
Definition: PixelTraits.h:3278
static void FromSample(float &a, sample b)
Definition: PixelTraits.h:4850
GenericPixelTraits< uint32 > traits_type
Definition: PixelTraits.h:5756
static void SoftLight(sample &a, T b)
Definition: PixelTraits.h:4462
static void Exclusion(sample &a, T b)
Definition: PixelTraits.h:3750
static void Div(sample &a, float b)
Definition: PixelTraits.h:3304
static constexpr sample FloatToSample(T x)
Definition: PixelTraits.h:974
static void HardLight(sample &a, T b)
Definition: PixelTraits.h:2076
static void Xnor(sample &a, T b)
Definition: PixelTraits.h:1332
static void FromSample(uint32 &a, sample b)
Definition: PixelTraits.h:538
static void VividLight(sample &a, T b)
Definition: PixelTraits.h:5335
static void LinearLight(sample &a, T b)
Definition: PixelTraits.h:2126
static void Xor(sample &a, T b)
Definition: PixelTraits.h:5136
static void Pow(sample &a, double b)
Definition: PixelTraits.h:4193
static void Add(sample &a, T b)
Definition: PixelTraits.h:2469
static sample ToSampleConstrained(float x)
Definition: PixelTraits.h:5595
static sample ToSample(int8 x)
Definition: PixelTraits.h:4705
static void FromSample(uint8 &a, sample b)
Definition: PixelTraits.h:5928
static sample ToSampleConstrained(float x)
Definition: PixelTraits.h:3922
#define int16_min
Definition: Defs.h:754
static sample ToSampleConstrained(float x)
Definition: PixelTraits.h:4767
static void Div(sample &a, pcl::Complex< double > b)
Definition: PixelTraits.h:3328
static void Min(sample &a, T b)
Definition: PixelTraits.h:1216
static void HardLight(sample &a, T b)
Definition: PixelTraits.h:2809
8-bit unsigned integer pixel traits.
Definition: PixelTraits.h:2949
static void Add(sample &a, T b)
Definition: PixelTraits.h:4068
static constexpr sample ToSample(float x)
Definition: PixelTraits.h:1046
static sample ToSample(float x)
Definition: PixelTraits.h:3075
static void Add(sample &a, T b)
Definition: PixelTraits.h:1737
static void Min(sample &a, T b)
Definition: PixelTraits.h:1797
static void FromSample(uint32 &a, sample b)
Definition: PixelTraits.h:3997
static void FromSample(uint32 &a, sample b)
Definition: PixelTraits.h:1684
static void FromSample(int16 &a, sample b)
Definition: PixelTraits.h:3989
static void Or(sample &a, T b)
Definition: PixelTraits.h:1238
static sample FloatToSample(T x)
Definition: PixelTraits.h:4680
#define uint8_to_uint24
Definition: Defs.h:850
static sample ToSample(double x)
Definition: PixelTraits.h:1635
#define uint20_to_uint16
Definition: Defs.h:904
static constexpr sample ToSample(const Complex< T > &x)
Definition: PixelTraits.h:5622
static void Mov(sample &a, T b)
Definition: PixelTraits.h:3221
static void FromSample(uint16 &a, sample b)
Definition: PixelTraits.h:5944
constexpr const T & Range(const T &x, const T &a, const T &b)
Definition: Utility.h:190
static void FromSample(int16 &a, sample b)
Definition: PixelTraits.h:2408
static void FromSample(float &a, sample b)
Definition: PixelTraits.h:1119
static void Xnor(sample &a, T b)
Definition: PixelTraits.h:4326
static sample ToSample(const Complex< T > &x)
Definition: PixelTraits.h:3112
static sample ToSample(const Complex< T > &x)
Definition: PixelTraits.h:5920
static sample ToSampleConstrained(float x)
Definition: PixelTraits.h:5893
static sample ToSample(int8 x)
Definition: PixelTraits.h:3868
static void Xnor(sample &a, T b)
Definition: PixelTraits.h:1913
static void FromSample(float &a, sample b)
Definition: PixelTraits.h:3184
static void Nor(sample &a, T b)
Definition: PixelTraits.h:3426
static void Pow(sample &a, pcl::Complex< float > b)
Definition: PixelTraits.h:4201
static void Sub(sample &a, T b)
Definition: PixelTraits.h:1747
static void Not(sample &a, T b)
Definition: PixelTraits.h:5114
static void Screen(sample &a, T b)
Definition: PixelTraits.h:1367
static void Mul(sample &a, T b)
Definition: PixelTraits.h:2489
static sample FloatToSample(T x)
Definition: PixelTraits.h:2281
static void Mul(sample &a, T b)
Definition: PixelTraits.h:3253
static sample ToSample(uint8 x)
Definition: PixelTraits.h:5521
static sample ToSample(double x)
Definition: PixelTraits.h:5901
static void Xor(sample &a, T b)
Definition: PixelTraits.h:753
static constexpr sample ToSample(int16 x)
Definition: PixelTraits.h:3888
static constexpr const char * SampleFormat()
Definition: PixelTraits.h:955
static void Nand(sample &a, T b)
Definition: PixelTraits.h:3467
static void Sub(sample &a, T b)
Definition: PixelTraits.h:2479
static void Nand(sample &a, T b)
Definition: PixelTraits.h:1885
static void Div(sample &a, T b)
Definition: PixelTraits.h:621
T Abs(const Complex< T > &c)
Definition: Complex.h:420
static constexpr bool IsFloatSample()
Definition: PixelTraits.h:5767
static void LinearBurn(sample &a, T b)
Definition: PixelTraits.h:791
static void SoftLight(sample &a, T b)
Definition: PixelTraits.h:2051
static constexpr const char * SampleFormat()
Definition: PixelTraits.h:2262
static sample ToSample(uint16 x)
Definition: PixelTraits.h:441
#define uint16_to_uint20
Definition: Defs.h:874
#define uint32_to_uint8
Definition: Defs.h:958
static void FromSample(uint8 &a, sample b)
Definition: PixelTraits.h:3120
static void Pow(sample &a, float b)
Definition: PixelTraits.h:4185
#define uint32_max
Definition: Defs.h:809
static void Not(sample &a)
Definition: PixelTraits.h:2591
static void FromSample(double &a, sample b)
Definition: PixelTraits.h:2440
static void LinearLight(sample &a, T b)
Definition: PixelTraits.h:3700
static constexpr bool IsFloatSample()
Definition: PixelTraits.h:370
static sample ToSample(uint16 x)
Definition: PixelTraits.h:5545
static void Not(sample &a)
Definition: PixelTraits.h:1859
static void FromSample(int32 &a, sample b)
Definition: PixelTraits.h:2424
signed char int8
Definition: Defs.h:570
GenericPixelTraits< Complex< double > > traits_type
Definition: PixelTraits.h:2219
static constexpr bool IsComplexSample()
Definition: PixelTraits.h:5776
constexpr const T & Max(const T &a, const T &b)
Definition: Utility.h:119
static sample ToSample(uint8 x)
Definition: PixelTraits.h:3856
static void Dif(sample &a, T b)
Definition: PixelTraits.h:1787
static void ColorBurn(sample &a, T b)
Definition: PixelTraits.h:780
static void FromSample(float &a, sample b)
Definition: PixelTraits.h:2432
static sample ToSample(int32 x)
Definition: PixelTraits.h:5875
static void Screen(sample &a, T b)
Definition: PixelTraits.h:4387
static sample ToSample(uint16 x)
Definition: PixelTraits.h:3035
static void Overlay(sample &a, T b)
Definition: PixelTraits.h:5258
32-bit IEEE 754 normalized floating point real pixel traits.
Definition: PixelTraits.h:352
static void LinearLight(sample &a, T b)
Definition: PixelTraits.h:5361
unsigned short uint16
Definition: Defs.h:588
static void FromSample(Complex< T > &a, sample b)
Definition: PixelTraits.h:3209
static void FromSample(int8 &a, sample b)
Definition: PixelTraits.h:3969
static void FromSampl(int8 &a, sample b)
Definition: PixelTraits.h:1660
static void Nor(sample &a, T b)
Definition: PixelTraits.h:5084
static constexpr sample ToSample(uint16 x)
Definition: PixelTraits.h:3880
traits_type::sample sample
Definition: PixelTraits.h:5463
int TruncInt(T x)
Definition: Math.h:1035
static void Xor(sample &a, T b)
Definition: PixelTraits.h:3478
Generic complex number.
Definition: Complex.h:83
static sample ToSample(int32 x)
Definition: PixelTraits.h:3067
constexpr const T & Min(const T &a, const T &b)
Definition: Utility.h:90
static void Div(sample &a, pcl::Complex< float > b)
Definition: PixelTraits.h:4978
static void LinearLight(sample &a, T b)
Definition: PixelTraits.h:4537
static void LinearLight(sample &a, T b)
Definition: PixelTraits.h:871
static void Max(sample &a, T b)
Definition: PixelTraits.h:5062
static void FromSample(uint16 &a, sample b)
Definition: PixelTraits.h:3981
static void Screen(sample &a, T b)
Definition: PixelTraits.h:3550
static void Mov(sample &a, T b)
Definition: PixelTraits.h:581
GenericPixelTraits< uint8 > traits_type
Definition: PixelTraits.h:2956
static void FromSample(uint32 &a, sample b)
Definition: PixelTraits.h:4834
static void Mul(sample &a, double b)
Definition: PixelTraits.h:3270
static void Not(sample &a, T b)
Definition: PixelTraits.h:4293
static void Pow(sample &a, pcl::Complex< double > b)
Definition: PixelTraits.h:3372
static constexpr bool IsFloatSample()
Definition: PixelTraits.h:3804
static void ColorBurn(sample &a, T b)
Definition: PixelTraits.h:2658
static sample ToSampleConstrained(double x)
Definition: PixelTraits.h:5613
static void FromSample(double &a, sample b)
Definition: PixelTraits.h:562
static void Pow(sample &a, T b)
Definition: PixelTraits.h:4176
static void Xnor(sample &a, T b)
Definition: PixelTraits.h:3489
static sample ToSample(uint32 x)
Definition: PixelTraits.h:5569
#define uint32_to_uint20
Definition: Defs.h:970
static void Mov(sample &a, T b)
Definition: PixelTraits.h:4879
static void FromSample(int8 &a, sample b)
Definition: PixelTraits.h:5936
static void Pow(sample &a, T b)
Definition: PixelTraits.h:4997
static void Xnor(sample &a, T b)
Definition: PixelTraits.h:5147
static sample ToSample(double x)
Definition: PixelTraits.h:5603
traits_type::sample sample
Definition: PixelTraits.h:5761
static void FromSample(int8 &a, sample b)
Definition: PixelTraits.h:1079
#define uint8_to_uint16
Definition: Defs.h:838
static sample ToSample(int32 x)
Definition: PixelTraits.h:3904
static void Pow(sample &a, T b)
Definition: PixelTraits.h:2509
static void Or(sample &a, T b)
Definition: PixelTraits.h:1819
signed int int32
Definition: Defs.h:594
static sample ToSample(uint32 x)
Definition: PixelTraits.h:2343
static void Mul(sample &a, pcl::Complex< float > b)
Definition: PixelTraits.h:4936
static void FromSample(uint16 &a, sample b)
Definition: PixelTraits.h:1668
static void SoftLight(sample &a, T b)
Definition: PixelTraits.h:1400
#define uint16_to_uint32
Definition: Defs.h:886
static constexpr const char * SampleFormat()
Definition: PixelTraits.h:1530
static void Exclusion(sample &a, T b)
Definition: PixelTraits.h:5413
static sample ToSample(float x)
Definition: PixelTraits.h:1627
static void FromSample(int32 &a, sample b)
Definition: PixelTraits.h:5968
Base class of all pixel traits classes.
Definition: PixelTraits.h:176
static void Pow(sample &a, pcl::Complex< float > b)
Definition: PixelTraits.h:5022
static void Dif(sample &a, T b)
Definition: PixelTraits.h:3383
static sample ToSample(uint8 x)
Definition: PixelTraits.h:2295
static void Mul(sample &a, float b)
Definition: PixelTraits.h:3262
static void Xor(sample &a, T b)
Definition: PixelTraits.h:1318
static void FromSample(Complex< T > &a, sample b)
Definition: PixelTraits.h:4867
static sample FloatToSample(T x)
Definition: PixelTraits.h:3843
static void Exclusion(sample &a, T b)
Definition: PixelTraits.h:895
static void Xor(sample &a, T b)
Definition: PixelTraits.h:4315
static void Overlay(sample &a, T b)
Definition: PixelTraits.h:2758
static void Div(sample &a, T b)
Definition: PixelTraits.h:4134
static void Nor(sample &a, T b)
Definition: PixelTraits.h:4263
GenericPixelTraits< uint32 > traits_type
Definition: PixelTraits.h:4630
static sample FloatToSample(T x)
Definition: PixelTraits.h:1549
static void FromSample(uint8 &a, sample b)
Definition: PixelTraits.h:4802
static sample ToSampleConstrained(double x)
Definition: PixelTraits.h:3940
static constexpr const char * SampleFormat()
Definition: PixelTraits.h:2987
static sample MaxSampleValue()
Definition: PixelTraits.h:1540
static sample ToSample(int16 x)
Definition: PixelTraits.h:5557
#define uint8_max
Definition: Defs.h:748
static void Min(sample &a, T b)
Definition: PixelTraits.h:3394
static void PinLight(sample &a, T b)
Definition: PixelTraits.h:883
static constexpr int BytesPerSample()
Definition: PixelTraits.h:191
sample::component component
Definition: PixelTraits.h:1499
static void Div(sample &a, double b)
Definition: PixelTraits.h:3312
static sample ToSample(float x)
Definition: PixelTraits.h:5585
static void FromSample(int32 &a, sample b)
Definition: PixelTraits.h:546
static void Dif(sample &a, T b)
Definition: PixelTraits.h:4220
static sample MaxSampleValue()
Definition: PixelTraits.h:2272
static constexpr sample ToSample(const Complex< T > &x)
Definition: PixelTraits.h:1063
static constexpr sample ToSample(uint32 x)
Definition: PixelTraits.h:465
static void FromSample(int16 &a, sample b)
Definition: PixelTraits.h:5666
static constexpr bool IsComplexSample()
Definition: PixelTraits.h:2976
static sample ToSampleConstrained(double x)
Definition: PixelTraits.h:3103
static constexpr sample ToSample(int8 x)
Definition: PixelTraits.h:3027
static void Not(sample &a)
Definition: PixelTraits.h:713
static void Pow(sample &a, float b)
Definition: PixelTraits.h:5006
static sample ToSample(int16 x)
Definition: PixelTraits.h:2331
static void ColorBurn(sample &a, T b)
Definition: PixelTraits.h:1926
static void FromSample(int16 &a, sample b)
Definition: PixelTraits.h:5952
20-bit unsigned integer pixel traits.
Definition: PixelTraits.h:5451
static void LinearBurn(sample &a, T b)
Definition: PixelTraits.h:3525
static void Not(sample &a, T b)
Definition: PixelTraits.h:726
static void Screen(sample &a, T b)
Definition: PixelTraits.h:1976
static sample ToSample(double x)
Definition: PixelTraits.h:4775
static constexpr bool IsFloatSample()
Definition: PixelTraits.h:2967
static constexpr const char * SampleFormat()
Definition: PixelTraits.h:5787
static void FromSample(uint8 &a, sample b)
Definition: PixelTraits.h:2384
#define uint20_to_uint32
Definition: Defs.h:916
static void Nor(sample &a, T b)
Definition: PixelTraits.h:687
static void Mul(sample &a, pcl::Complex< float > b)
Definition: PixelTraits.h:4115
static void And(sample &a, T b)
Definition: PixelTraits.h:3437
static sample ToSample(uint32 x)
Definition: PixelTraits.h:3059
static void Screen(sample &a, T b)
Definition: PixelTraits.h:802
static void ColorBurn(sample &a, T b)
Definition: PixelTraits.h:3500
static constexpr bool IsFloatSample()
Definition: PixelTraits.h:5469
#define uint20_to_uint8
Definition: Defs.h:898
static void FromSample(int16 &a, sample b)
Definition: PixelTraits.h:4826
32-bit IEEE 754 normalized floating point complex pixel traits.
Definition: PixelTraits.h:1482
traits_type::sample sample
Definition: PixelTraits.h:1494
static sample ToSample(int16 x)
Definition: PixelTraits.h:3047
static void Add(sample &a, T b)
Definition: PixelTraits.h:591
static void And(sample &a, T b)
Definition: PixelTraits.h:5095
static sample ToSample(uint8 x)
Definition: PixelTraits.h:982
static void PinLight(sample &a, T b)
Definition: PixelTraits.h:5387
static void Div(sample &a, float b)
Definition: PixelTraits.h:4141
static void FromSample(int32 &a, sample b)
Definition: PixelTraits.h:1692
static void Sub(sample &a, T b)
Definition: PixelTraits.h:4900
static void Mov(sample &a, T b)
Definition: PixelTraits.h:1146
static constexpr sample MinSampleValue()
Definition: PixelTraits.h:208
static void FromSample(int32 &a, sample b)
Definition: PixelTraits.h:5690
static void ColorDodge(sample &a, T b)
Definition: PixelTraits.h:4412
static constexpr sample FloatToSample(T x)
Definition: PixelTraits.h:409
static void LinearLight(sample &a, T b)
Definition: PixelTraits.h:1436
static void Nand(sample &a, T b)
Definition: PixelTraits.h:4304
static void ColorBurn(sample &a, T b)
Definition: PixelTraits.h:5158
static void HardLight(sample &a, T b)
Definition: PixelTraits.h:5309
static constexpr sample MaxSampleValue()
Definition: PixelTraits.h:2997
static void Sub(sample &a, T b)
Definition: PixelTraits.h:3242
static void Mov(sample &a, T b)
Definition: PixelTraits.h:2459
static sample ToSample(double x)
Definition: PixelTraits.h:3930
static void Div(sample &a, pcl::Complex< float > b)
Definition: PixelTraits.h:4157
static void Overlay(sample &a, T b)
Definition: PixelTraits.h:4437
static void Min(sample &a, T b)
Definition: PixelTraits.h:5052
static void FromSample(Complex< T > &a, sample b)
Definition: PixelTraits.h:1717
static constexpr bool IsFloatSample()
Definition: PixelTraits.h:935
static void FromSample(uint32 &a, sample b)
Definition: PixelTraits.h:5960
static void ColorDodge(sample &a, T b)
Definition: PixelTraits.h:813
static sample ToSample(int16 x)
Definition: PixelTraits.h:4729
static void FromSample(uint16 &a, sample b)
Definition: PixelTraits.h:5654
static void FromSample(float &a, sample b)
Definition: PixelTraits.h:1700
static void Min(sample &a, T b)
Definition: PixelTraits.h:4231
static void VividLight(sample &a, T b)
Definition: PixelTraits.h:2835
static void ColorDodge(sample &a, T b)
Definition: PixelTraits.h:5233
static void FromSample(uint8 &a, sample b)
Definition: PixelTraits.h:1652
static void And(sample &a, T b)
Definition: PixelTraits.h:701
static void FromSample(int16 &a, sample b)
Definition: PixelTraits.h:1676
static constexpr int BitsPerSample()
Definition: PixelTraits.h:199
GenericPixelTraits< Complex< float > > traits_type
Definition: PixelTraits.h:1489
static void Dif(sample &a, T b)
Definition: PixelTraits.h:1206
static void Div(sample &a, pcl::Complex< double > b)
Definition: PixelTraits.h:4165
static void Overlay(sample &a, T b)
Definition: PixelTraits.h:1389
static sample ToSample(float x)
Definition: PixelTraits.h:5883
static void PinLight(sample &a, T b)
Definition: PixelTraits.h:2887
traits_type::sample sample
Definition: PixelTraits.h:2224
static sample ToSample(uint16 x)
Definition: PixelTraits.h:2319
static void Max(sample &a, T b)
Definition: PixelTraits.h:661
static void Div(sample &a, T b)
Definition: PixelTraits.h:4955
traits_type::sample sample
Definition: PixelTraits.h:3798
static constexpr sample ToSample(const Complex< T > &x)
Definition: PixelTraits.h:498
static sample ToSampleConstrained(float x)
Definition: PixelTraits.h:3085
static void Div(sample &a, T b)
Definition: PixelTraits.h:1186
#define int32_min
Definition: Defs.h:794
#define uint24_max
Definition: Defs.h:788
static constexpr sample ToSample(uint8 x)
Definition: PixelTraits.h:3019
static void FromSample(int8 &a, sample b)
Definition: PixelTraits.h:2392
static constexpr bool IsComplexSample()
Definition: PixelTraits.h:1519
static void Nand(sample &a, T b)
Definition: PixelTraits.h:5125
static void FromSample(int8 &a, sample b)
Definition: PixelTraits.h:4810
static constexpr sample MaxSampleValue()
Definition: PixelTraits.h:5797
static void Div(sample &a, T b)
Definition: PixelTraits.h:3297
static void FromSample(double &a, sample b)
Definition: PixelTraits.h:1708
static constexpr const char * SampleFormat()
Definition: PixelTraits.h:390
static void FromSample(double &a, sample b)
Definition: PixelTraits.h:4033
static void Div(sample &a, T b)
Definition: PixelTraits.h:1767
static constexpr bool IsComplexSample()
Definition: PixelTraits.h:4650
static sample ToSample(uint32 x)
Definition: PixelTraits.h:3896
static void Sub(sample &a, T b)
Definition: PixelTraits.h:4079
static void Or(sample &a, T b)
Definition: PixelTraits.h:5073
static void FromSample(uint8 &a, sample b)
Definition: PixelTraits.h:506
static void FromSample(uint8 &a, sample b)
Definition: PixelTraits.h:5630
static constexpr sample ToSample(int32 x)
Definition: PixelTraits.h:1038
static void Mul(sample &a, T b)
Definition: PixelTraits.h:611
static void Dif(sample &a, T b)
Definition: PixelTraits.h:641
static void PinLight(sample &a, T b)
Definition: PixelTraits.h:2151
static void FromSample(int32 &a, sample b)
Definition: PixelTraits.h:1111
static void Pow(sample &a, double b)
Definition: PixelTraits.h:3356
static sample ToSample(uint32 x)
Definition: PixelTraits.h:1611
static sample ToSample(uint8 x)
Definition: PixelTraits.h:1563
#define uint20_max
Definition: Defs.h:776
static void FromSample(uint8 &a, sample b)
Definition: PixelTraits.h:3957
static void FromSample(int16 &a, sample b)
Definition: PixelTraits.h:3148
static void Max(sample &a, T b)
Definition: PixelTraits.h:1807
static void Pow(sample &a, T b)
Definition: PixelTraits.h:3339
static void And(sample &a, T b)
Definition: PixelTraits.h:2579
64-bit IEEE 754 normalized floating point complex pixel traits.
Definition: PixelTraits.h:2212
static constexpr bool IsComplexSample()
Definition: PixelTraits.h:944
static sample ToSample(uint8 x)
Definition: PixelTraits.h:417
static void FromSample(float &a, sample b)
Definition: PixelTraits.h:5976
static void FromSample(uint16 &a, sample b)
Definition: PixelTraits.h:3136
static void FromSample(double &a, sample b)
Definition: PixelTraits.h:4858
static void FromSample(int8 &a, sample b)
Definition: PixelTraits.h:514
static void FromSample(Complex< T > &a, sample b)
Definition: PixelTraits.h:571
static sample ToSample(float x)
Definition: PixelTraits.h:2359
static void Pow(sample &a, T b)
Definition: PixelTraits.h:1196
#define uint8_to_uint32
Definition: Defs.h:856
static sample ToSample(uint16 x)
Definition: PixelTraits.h:1587
static void Nand(sample &a, T b)
Definition: PixelTraits.h:2617
static sample ToSample(uint32 x)
Definition: PixelTraits.h:5867
static void Div(sample &a, double b)
Definition: PixelTraits.h:4149
static void Max(sample &a, T b)
Definition: PixelTraits.h:2539
static void VividLight(sample &a, T b)
Definition: PixelTraits.h:1424
static void LinearBurn(sample &a, T b)
Definition: PixelTraits.h:4362
static void FromSample(Complex< T > &a, sample b)
Definition: PixelTraits.h:4046
static sample ToSample(int8 x)
Definition: PixelTraits.h:2307
static constexpr sample MaxSampleValue()
Definition: PixelTraits.h:400
static constexpr sample MaxSampleValue()
Definition: PixelTraits.h:5499
static void Mul(sample &a, T b)
Definition: PixelTraits.h:1176
static void LinearBurn(sample &a, T b)
Definition: PixelTraits.h:5183
traits_type::sample sample
Definition: PixelTraits.h:2961
static constexpr bool IsFloatSample()
Definition: PixelTraits.h:2242
static void ColorDodge(sample &a, T b)
Definition: PixelTraits.h:3575
static void Exclusion(sample &a, T b)
Definition: PixelTraits.h:2913
#define uint24_to_uint8
Definition: Defs.h:928
unsigned int uint32
Definition: Defs.h:600
static void Nand(sample &a, T b)
Definition: PixelTraits.h:1304
static void Pow(sample &a, double b)
Definition: PixelTraits.h:5014
signed long long int64
Definition: Defs.h:610
GenericPixelTraits< float > traits_type
Definition: PixelTraits.h:359
static void Xnor(sample &a, T b)
Definition: PixelTraits.h:2645
static void Mul(sample &a, float b)
Definition: PixelTraits.h:4920
static void Not(sample &a, T b)
Definition: PixelTraits.h:3456
traits_type::sample sample
Definition: PixelTraits.h:929
static constexpr sample ToSample(int32 x)
Definition: PixelTraits.h:4749
static void FromSample(int32 &a, sample b)
Definition: PixelTraits.h:4009
static void Mul(sample &a, T b)
Definition: PixelTraits.h:4090
static void Or(sample &a, T b)
Definition: PixelTraits.h:2551
static constexpr const char * SampleFormat()
Definition: PixelTraits.h:3824
static void Pow(sample &a, T b)
Definition: PixelTraits.h:631
static void Add(sample &a, T b)
Definition: PixelTraits.h:3231
static void Xor(sample &a, T b)
Definition: PixelTraits.h:1899
static void FromSample(uint32 &a, sample b)
Definition: PixelTraits.h:5678
static void Not(sample &a)
Definition: PixelTraits.h:1278
static void HardLight(sample &a, T b)
Definition: PixelTraits.h:1412
16-bit unsigned integer pixel traits.
Definition: PixelTraits.h:3786
Complex< T1 > Pow(const Complex< T1 > &c, T2 x)
Definition: Complex.h:738
static void Not(sample &a, T b)
Definition: PixelTraits.h:1872
static constexpr sample ToSample(double x)
Definition: PixelTraits.h:1054
static constexpr bool IsFloatSample()
Definition: PixelTraits.h:4641
static void FromSample(Complex< T > &a, sample b)
Definition: PixelTraits.h:5727
static constexpr bool IsComplexSample()
Definition: PixelTraits.h:2251
static void FromSample(uint32 &a, sample b)
Definition: PixelTraits.h:2416
static sample ToSample(int16 x)
Definition: PixelTraits.h:5855
static void LinearLight(sample &a, T b)
Definition: PixelTraits.h:2861
static void Max(sample &a, T b)
Definition: PixelTraits.h:3404
static void Overlay(sample &a, T b)
Definition: PixelTraits.h:3600