PCL
ImageVariant.h
Go to the documentation of this file.
1 // ____ ______ __
2 // / __ \ / ____// /
3 // / /_/ // / / /
4 // / ____// /___ / /___ PixInsight Class Library
5 // /_/ \____//_____/ PCL 2.7.0
6 // ----------------------------------------------------------------------------
7 // pcl/ImageVariant.h - Released 2024-06-18T15:48:54Z
8 // ----------------------------------------------------------------------------
9 // This file is part of the PixInsight Class Library (PCL).
10 // PCL is a multiplatform C++ framework for development of PixInsight modules.
11 //
12 // Copyright (c) 2003-2024 Pleiades Astrophoto S.L. All Rights Reserved.
13 //
14 // Redistribution and use in both source and binary forms, with or without
15 // modification, is permitted provided that the following conditions are met:
16 //
17 // 1. All redistributions of source code must retain the above copyright
18 // notice, this list of conditions and the following disclaimer.
19 //
20 // 2. All redistributions in binary form must reproduce the above copyright
21 // notice, this list of conditions and the following disclaimer in the
22 // documentation and/or other materials provided with the distribution.
23 //
24 // 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
25 // of their contributors, may be used to endorse or promote products derived
26 // from this software without specific prior written permission. For written
27 // permission, please contact info@pixinsight.com.
28 //
29 // 4. All products derived from this software, in any form whatsoever, must
30 // reproduce the following acknowledgment in the end-user documentation
31 // and/or other materials provided with the product:
32 //
33 // "This product is based on software from the PixInsight project, developed
34 // by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
35 //
36 // Alternatively, if that is where third-party acknowledgments normally
37 // appear, this acknowledgment must be reproduced in the product itself.
38 //
39 // THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
40 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
41 // TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
43 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
44 // EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
45 // INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
46 // DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
47 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
49 // POSSIBILITY OF SUCH DAMAGE.
50 // ----------------------------------------------------------------------------
51 
52 #ifndef __PCL_ImageVariant_h
53 #define __PCL_ImageVariant_h
54 
56 
57 #include <pcl/Defs.h>
58 
59 #include <pcl/Image.h>
60 #include <pcl/ReferenceCounter.h>
61 
62 #ifdef __PCL_BUILDING_PIXINSIGHT_APPLICATION
63 namespace pi
64 {
65  class SharedImage;
66 }
67 #endif
68 
69 #define SOLVE_TEMPLATE( F ) \
70  if ( IsComplexSample() ) \
71  switch ( BitsPerSample() ) \
72  { \
73  case 32: F( ComplexImage ); break; \
74  case 64: F( DComplexImage ); break; \
75  } \
76  else if ( IsFloatSample() ) \
77  switch ( BitsPerSample() ) \
78  { \
79  case 32: F( Image ); break; \
80  case 64: F( DImage ); break; \
81  } \
82  else \
83  switch ( BitsPerSample() ) \
84  { \
85  case 8: F( UInt8Image ); break; \
86  case 16: F( UInt16Image ); break; \
87  case 32: F( UInt32Image ); break; \
88  }
89 
90 #define SOLVE_TEMPLATE_2( I, F ) \
91  if ( I.IsComplexSample() ) \
92  switch ( I.BitsPerSample() ) \
93  { \
94  case 32: F( ComplexImage ); break; \
95  case 64: F( DComplexImage ); break; \
96  } \
97  else if ( I.IsFloatSample() ) \
98  switch ( I.BitsPerSample() ) \
99  { \
100  case 32: F( Image ); break; \
101  case 64: F( DImage ); break; \
102  } \
103  else \
104  switch ( I.BitsPerSample() ) \
105  { \
106  case 8: F( UInt8Image ); break; \
107  case 16: F( UInt16Image ); break; \
108  case 32: F( UInt32Image ); break; \
109  }
110 
111 #define SOLVE_TEMPLATE_REAL( F ) \
112  if ( IsFloatSample() ) \
113  switch ( BitsPerSample() ) \
114  { \
115  case 32: F( Image ); break; \
116  case 64: F( DImage ); break; \
117  } \
118  else \
119  switch ( BitsPerSample() ) \
120  { \
121  case 8: F( UInt8Image ); break; \
122  case 16: F( UInt16Image ); break; \
123  case 32: F( UInt32Image ); break; \
124  }
125 
126 #define SOLVE_TEMPLATE_REAL_2( I, F ) \
127  if ( I.IsFloatSample() ) \
128  switch ( I.BitsPerSample() ) \
129  { \
130  case 32: F( Image ); break; \
131  case 64: F( DImage ); break; \
132  } \
133  else \
134  switch ( I.BitsPerSample() ) \
135  { \
136  case 8: F( UInt8Image ); break; \
137  case 16: F( UInt16Image ); break; \
138  case 32: F( UInt32Image ); break; \
139  }
140 
141 namespace pcl
142 {
143 
144 // ----------------------------------------------------------------------------
145 
167 namespace SwapCompression
168 {
169  enum value_type
170  {
171  None, // Do not use compression.
172  ZLib, // ZLib (deflate) compression.
173  ZLib_SH, // ZLib (deflate) compression with byte shuffling.
174  LZ4, // LZ4 fast compression.
175  LZ4_Sh, // LZ4 fast compression with byte shuffling.
176  LZ4HC, // LZ4-HC compression.
177  LZ4HC_Sh, // LZ4-HC compression with byte shuffling.
178  Zstd, // Zstandard compression.
179  Zstd_Sh, // Zstandard compression with byte shuffling.
180 
181  NumberOfAlgorithms
182  };
183 }
184 
321 class PCL_CLASS ImageVariant
322 {
323 public:
324 
330  using color_space = AbstractImage::color_space;
331 
337  using image_op = ImageOp::value_type;
338 
339  /*
340  * An enumerated type that represents a compression algorithm for raw
341  * storage file generation. Valid constants for this enumeration are defined
342  * in the SwapCompression namespace.
343  */
344  using swap_compression = SwapCompression::value_type;
345 
351  {
352  m_data = new Data;
353  }
354 
362  template <class P>
364  {
365  m_data = new Data;
366  m_data->Update( image );
367  }
368 
378  ImageVariant( const ImageVariant& image )
379  : m_data( image.m_data )
380  {
381  m_data->Attach();
382  }
383 
388  : m_data( image.m_data )
389  {
390  image.m_data = nullptr;
391  }
392 
399  virtual ~ImageVariant()
400  {
401  if ( m_data != nullptr )
402  {
403  DetachFromData();
404  m_data = nullptr;
405  }
406  }
407 
412  const AbstractImage* ImagePtr() const noexcept
413  {
414  return m_data->image;
415  }
416 
421  {
422  return m_data->image;
423  }
424 
432  bool IsSameImage( const ImageVariant& image ) const noexcept
433  {
434  return m_data->image == image.m_data->image;
435  }
436 
441  bool IsFloatSample() const noexcept
442  {
443  return m_data->isFloatSample;
444  }
445 
449  bool IsComplexSample() const noexcept
450  {
451  return m_data->isComplexSample;
452  }
453 
458  int BitsPerSample() const noexcept
459  {
460  return m_data->bitsPerSample;
461  }
462 
467  int BytesPerSample() const noexcept
468  {
469  return m_data->bitsPerSample >> 3;
470  }
471 
476  int Width() const noexcept
477  {
478  return m_data->image ? m_data->image->Width() : 0;
479  }
480 
485  int Height() const noexcept
486  {
487  return m_data->image ? m_data->image->Height() : 0;
488  }
489 
496  size_type NumberOfPixels() const noexcept
497  {
498  return m_data->image ? m_data->image->NumberOfPixels() : 0;
499  }
500 
505  int NumberOfChannels() const noexcept
506  {
507  return m_data->image ? m_data->image->NumberOfChannels() : 0;
508  }
509 
517  int LastChannel() const noexcept
518  {
519  return m_data->image ? m_data->image->LastChannel() : -1;
520  }
521 
527  bool IsValidChannelIndex( int c ) const noexcept
528  {
529  return m_data->image && m_data->image->IsValidChannelIndex( c );
530  }
531 
540  int NumberOfNominalChannels() const noexcept
541  {
542  return m_data->image ? m_data->image->NumberOfNominalChannels() : 0;
543  }
544 
553  bool HasAlphaChannels() const noexcept
554  {
555  return m_data->image && m_data->image->HasAlphaChannels();
556  }
557 
566  int NumberOfAlphaChannels() const noexcept
567  {
568  return m_data->image ? m_data->image->NumberOfAlphaChannels() : 0;
569  }
570 
577  size_type NumberOfSamples() const noexcept
578  {
579  return m_data->image ? m_data->image->NumberOfSamples() : 0;
580  }
581 
590  {
591  return m_data->image ? m_data->image->NumberOfNominalSamples() : 0;
592  }
593 
602  {
603  return m_data->image ? m_data->image->NumberOfAlphaSamples() : 0;
604  }
605 
616  Rect Bounds() const noexcept
617  {
618  return m_data->image ? m_data->image->Bounds() : Rect( 0 );
619  }
620 
627  template <typename T>
628  bool Includes( const GenericPoint<T>& p ) const noexcept
629  {
630  return m_data->image && m_data->image->Includes( p );
631  }
632 
639  template <typename T>
640  bool Includes( const GenericRectangle<T>& r ) const noexcept
641  {
642  return m_data->image && m_data->image->Includes( r );
643  }
644 
654  template <typename T>
655  bool Includes( T x0, T y0, T x1, T y1 ) const noexcept
656  {
657  return m_data->image && m_data->image->Includes( x0, y0, x1, y1 );
658  }
659 
669  template <typename T>
670  bool Includes( T x, T y ) const noexcept
671  {
672  return m_data->image && m_data->image->Includes( x, y );
673  }
674 
681  template <typename T>
682  bool Intersects( const pcl::GenericRectangle<T>& r ) const noexcept
683  {
684  return m_data->image && m_data->image->Intersects( r );
685  }
686 
696  template <typename T>
697  bool Intersects( T x0, T y0, T x1, T y1 ) const noexcept
698  {
699  return m_data->image && m_data->image->Intersects( x0, y0, x1, y1 );
700  }
701 
709  template <typename T>
710  bool Clip( pcl::GenericPoint<T>& p ) const noexcept
711  {
712  return m_data->image && m_data->image->Clip( p );
713  }
714 
727  template <typename T>
728  bool Clip( T& x, T& y ) const noexcept
729  {
730  return m_data->image && m_data->image->Clip( x, y );
731  }
732 
743  template <typename T>
744  bool Clip( pcl::GenericRectangle<T>& r ) const noexcept
745  {
746  return m_data->image && m_data->image->Clip( r );
747  }
748 
765  template <typename T>
766  bool Clip( T& x0, T& y0, T& x1, T& y1 ) const noexcept
767  {
768  return m_data->image && m_data->image->Clip( x0, y0, x1, y1 );
769  }
770 
777  void SelectChannel( int c ) const noexcept
778  {
779  if ( m_data->image )
780  m_data->image->SelectChannel( c );
781  }
782 
792  int SelectedChannel() const noexcept
793  {
794  return m_data->image ? m_data->image->SelectedChannel() : -1;
795  }
796 
804  void SelectChannelRange( int c0, int c1 ) const noexcept
805  {
806  if ( m_data->image )
807  m_data->image->SelectChannelRange( c0, c1 );
808  }
809 
814  void SelectNominalChannels() const noexcept
815  {
816  if ( m_data->image )
817  m_data->image->SelectNominalChannels();
818  }
819 
827  void SelectAlphaChannels() const noexcept
828  {
829  if ( m_data->image )
830  m_data->image->SelectAlphaChannels();
831  }
832 
837  void ResetChannelRange() const noexcept
838  {
839  if ( m_data->image )
840  m_data->image->ResetChannelRange();
841  }
842 
847  int NumberOfSelectedChannels() const noexcept
848  {
849  return m_data->image ? m_data->image->NumberOfSelectedChannels() : 0;
850  }
851 
856  int FirstSelectedChannel() const noexcept
857  {
858  return m_data->image ? m_data->image->FirstSelectedChannel() : -1;
859  }
860 
865  int LastSelectedChannel() const noexcept
866  {
867  return m_data->image ? m_data->image->LastSelectedChannel() : -1;
868  }
869 
877  void GetSelectedChannelRange( int& c0, int& c1 ) const noexcept
878  {
879  if ( m_data->image )
880  m_data->image->GetSelectedChannelRange( c0, c1 );
881  }
882 
889  void SelectPoint( int x, int y ) const noexcept
890  {
891  if ( m_data->image )
892  m_data->image->SelectPoint( x, y );
893  }
894 
898  void SelectPoint( const Point& p ) const noexcept
899  {
900  if ( m_data->image )
901  m_data->image->SelectPoint( p );
902  }
903 
907  void ResetPoint() const noexcept
908  {
909  if ( m_data->image )
910  m_data->image->ResetPoint();
911  }
912 
917  Point SelectedPoint() const noexcept
918  {
919  return m_data->image ? m_data->image->SelectedPoint() : Point( 0 );
920  }
921 
935  void SelectRectangle( int x0, int y0, int x1, int y1 ) const noexcept
936  {
937  if ( m_data->image )
938  m_data->image->SelectRectangle( x0, y0, x1, y1 );
939  }
940 
949  void SelectRectangle( const Point& p0, const Point& p1 ) const noexcept
950  {
951  if ( m_data->image )
952  m_data->image->SelectRectangle( p0, p1 );
953  }
954 
959  void SelectRectangle( const Rect& r ) const noexcept
960  {
961  if ( m_data->image )
962  m_data->image->SelectRectangle( r );
963  }
964 
968  void ResetSelection() const noexcept
969  {
970  if ( m_data->image )
971  m_data->image->ResetSelection();
972  }
973 
979  bool IsEmptySelection() const noexcept
980  {
981  return m_data->image ? m_data->image->IsEmptySelection() : false;
982  }
983 
989  bool IsFullSelection() const noexcept
990  {
991  return m_data->image ? m_data->image->IsFullSelection() : false;
992  }
993 
998  Rect SelectedRectangle() const noexcept
999  {
1000  return m_data->image ? m_data->image->SelectedRectangle() : Rect( 0 );
1001  }
1002 
1011  bool IsCompletelySelected() const noexcept
1012  {
1013  return m_data->image ? m_data->image->IsCompletelySelected() : false;
1014  }
1015 
1022  {
1023  return m_data->image ? m_data->image->NumberOfSelectedPixels() : 0;
1024  }
1025 
1032  {
1033  return m_data->image ? m_data->image->NumberOfSelectedSamples() : 0;
1034  }
1035 
1060  bool IsRangeClippingEnabled() const noexcept
1061  {
1062  return m_data->image ? m_data->image->IsRangeClippingEnabled() : false;
1063  }
1064 
1075  bool IsLowRangeClippingEnabled() const noexcept
1076  {
1077  return m_data->image ? m_data->image->IsLowRangeClippingEnabled() : false;
1078  }
1079 
1090  bool IsHighRangeClippingEnabled() const noexcept
1091  {
1092  return m_data->image ? m_data->image->IsHighRangeClippingEnabled() : false;
1093  }
1094 
1100  void EnableRangeClipping( bool enableLow = true, bool enableHigh = true ) const noexcept
1101  {
1102  if ( m_data->image )
1103  m_data->image->EnableRangeClipping( enableLow, enableHigh );
1104  }
1105 
1111  void DisableRangeClipping( bool disableLow = true, bool disableHigh = true ) const noexcept
1112  {
1113  if ( m_data->image )
1114  m_data->image->DisableRangeClipping( disableLow, disableHigh );
1115  }
1116 
1123  double RangeClipLow() const noexcept
1124  {
1125  return m_data->image ? m_data->image->RangeClipLow() : 0.0;
1126  }
1127 
1134  double RangeClipHigh() const noexcept
1135  {
1136  return m_data->image ? m_data->image->RangeClipHigh() : 0.0;
1137  }
1138 
1144  void SetRangeClipLow( double clipLow ) const noexcept
1145  {
1146  if ( m_data->image )
1147  m_data->image->SetRangeClipLow( clipLow );
1148  }
1149 
1155  void SetRangeClipHigh( double clipHigh ) const noexcept
1156  {
1157  if ( m_data->image )
1158  m_data->image->SetRangeClipHigh( clipHigh );
1159  }
1160 
1167  void SetRangeClipping( double clipLow, double clipHigh ) const noexcept
1168  {
1169  if ( m_data->image )
1170  m_data->image->SetRangeClipping( clipLow, clipHigh );
1171  }
1172 
1180  void ResetRangeClipping() const noexcept
1181  {
1182  if ( m_data->image )
1183  m_data->image->ResetRangeClipping();
1184  }
1185 
1204  void ResetSelections() const noexcept
1205  {
1206  if ( m_data->image )
1207  m_data->image->ResetSelections();
1208  }
1209 
1217  ImageSelections& Selections() const noexcept
1218  {
1219  return m_data->image->Selections();
1220  }
1221 
1226  void PushSelections() const
1227  {
1228  if ( m_data->image )
1229  m_data->image->PushSelections();
1230  }
1231 
1240  void PopSelections() const
1241  {
1242  if ( m_data->image )
1243  m_data->image->PopSelections();
1244  }
1245 
1252  bool CanPopSelections() const noexcept
1253  {
1254  return m_data->image ? m_data->image->CanPopSelections() : false;
1255  }
1256 
1264  StatusMonitor& Status() const noexcept
1265  {
1266  PCL_PRECONDITION( m_data->image != nullptr )
1267  return m_data->image->Status();
1268  }
1269 
1276  {
1277  return m_data->image ? m_data->image->StatusCallback() : nullptr;
1278  }
1279 
1287  void SetStatusCallback( pcl::StatusCallback* callback ) const noexcept
1288  {
1289  if ( m_data->image )
1290  m_data->image->SetStatusCallback( callback );
1291  }
1292 
1301  bool IsParallelProcessingEnabled() const noexcept
1302  {
1303  return m_data->image != nullptr && m_data->image->IsParallelProcessingEnabled();
1304  }
1305 
1319  void EnableParallelProcessing( bool enable = true, int maxProcessors = 0 ) noexcept
1320  {
1321  if ( m_data->image )
1322  m_data->image->EnableParallelProcessing( enable, maxProcessors );
1323  }
1324 
1334  void DisableParallelProcessing( bool disable = true ) noexcept
1335  {
1336  if ( m_data->image )
1337  m_data->image->DisableParallelProcessing( disable );
1338  }
1339 
1353  int MaxProcessors() const noexcept
1354  {
1355  return m_data->image ? m_data->image->MaxProcessors() : 0;
1356  }
1357 
1379  void SetMaxProcessors( int maxProcessors ) noexcept
1380  {
1381  if ( m_data->image )
1382  m_data->image->SetMaxProcessors( maxProcessors );
1383  }
1384 
1392  size_type LineSize() const noexcept
1393  {
1394  return m_data->image ? BytesPerSample() * size_type( m_data->image->Width() ) : 0;
1395  }
1396 
1403  size_type ChannelSize() const noexcept
1404  {
1405  return BytesPerSample() * NumberOfPixels();
1406  }
1407 
1415  size_type ImageSize() const noexcept
1416  {
1417  return ChannelSize() * size_type( NumberOfChannels() );
1418  }
1419 
1428  size_type NominalSize() const noexcept
1429  {
1430  return ChannelSize() * size_type( NumberOfNominalChannels() );
1431  }
1432 
1441  size_type AlphaSize() const noexcept
1442  {
1443  return ChannelSize() * size_type( NumberOfAlphaChannels() );
1444  }
1445 
1451  bool IsColor() const noexcept
1452  {
1453  return m_data->image && m_data->image->IsColor();
1454  }
1455 
1464  color_space ColorSpace() const noexcept
1465  {
1466  return m_data->image ? m_data->image->ColorSpace() : ColorSpace::Unknown;
1467  }
1468 
1474  String ChannelId( int c ) const noexcept
1475  {
1476  return m_data->image ? m_data->image->ChannelId( c ) : String();
1477  }
1478 
1486  const RGBColorSystem& RGBWorkingSpace() const noexcept
1487  {
1488  PCL_PRECONDITION( m_data->image != nullptr )
1489  return m_data->image->RGBWorkingSpace();
1490  }
1491 
1503  void SetRGBWorkingSpace( const RGBColorSystem& rgbws )
1504  {
1505  if ( m_data->image )
1506  m_data->image->SetRGBWorkingSpace( rgbws );
1507  }
1508 
1509  // -------------------------------------------------------------------------
1510 
1511 #define __ABSOLUTE_DIFFERENCE( I ) \
1512  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).AbsoluteDifference( scalar, rect, firstChannel, lastChannel ) ) ); \
1513  result.SetOwnership( true )
1514 
1523  template <typename T>
1525  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
1526  {
1527  ImageVariant result;
1528  if ( *this )
1529  SOLVE_TEMPLATE( __ABSOLUTE_DIFFERENCE )
1530  return result;
1531  }
1532 
1533 #undef __ABSOLUTE_DIFFERENCE
1534 
1535  // -------------------------------------------------------------------------
1536 
1537 #define __ABSOLUTE_VALUE( I ) \
1538  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).AbsoluteValue( rect, firstChannel, lastChannel ) ) ); \
1539  result.SetOwnership( true )
1540 
1548  ImageVariant AbsoluteValue( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
1549  {
1550  ImageVariant result;
1551  if ( *this )
1552  SOLVE_TEMPLATE( __ABSOLUTE_VALUE )
1553  return result;
1554  }
1555 
1556 #undef __ABSOLUTE_VALUE
1557 
1558  // -------------------------------------------------------------------------
1559 
1560 #define __ADD( I ) \
1561  static_cast<pcl::I&>( **this ).Add( scalar, rect, firstChannel, lastChannel )
1562 
1569  template <typename T>
1570  ImageVariant& Add( T scalar,
1571  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
1572  {
1573  if ( *this )
1574  SOLVE_TEMPLATE( __ADD )
1575  return *this;
1576  }
1577 
1578 #undef __ADD
1579 
1580  // -------------------------------------------------------------------------
1581 
1582 #define __ADD_1( I ) \
1583  ImageVariant::Add( static_cast<pcl::I&>( **this ), image, point, channel, rect, firstChannel, lastChannel )
1584 
1585 #define __ADD_2( I ) \
1586  image1.Add( static_cast<const pcl::I&>( *image2 ), point, channel, rect, firstChannel, lastChannel )
1587 
1588 private:
1589 
1590  template <class P> static
1591  void Add( GenericImage<P>& image1, const ImageVariant& image2,
1592  const Point& point, int channel,
1593  const Rect& rect, int firstChannel, int lastChannel )
1594  {
1595  SOLVE_TEMPLATE_2( image2, __ADD_2 )
1596  }
1597 
1598 public:
1599 
1607  const Point& point = Point( int_max ), int channel = -1,
1608  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
1609  {
1610  if ( *this )
1611  if ( image )
1612  SOLVE_TEMPLATE( __ADD_1 )
1613  return *this;
1614  }
1615 
1616 #undef __ADD_1
1617 #undef __ADD_2
1618 
1619  // -------------------------------------------------------------------------
1620 
1621 #define __ADDED( I ) \
1622  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Added( scalar, rect, firstChannel, lastChannel ) ) ); \
1623  result.SetOwnership( true )
1624 
1631  template <typename T>
1632  ImageVariant Added( T scalar,
1633  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
1634  {
1635  ImageVariant result;
1636  if ( *this )
1637  SOLVE_TEMPLATE( __ADDED )
1638  return result;
1639  }
1640 
1641 #undef __ADDED
1642 
1643  // -------------------------------------------------------------------------
1644 
1645 #define __ALLOCATE_DATA( I ) \
1646  static_cast<pcl::I&>( **this ).AllocateData( width, height, numberOfChannels, colorSpace )
1647 
1658  ImageVariant& AllocateData( int width, int height, int numberOfChannels = 1, color_space colorSpace = ColorSpace::Gray )
1659  {
1660  if ( !*this )
1661  CreateImage();
1662  SOLVE_TEMPLATE( __ALLOCATE_DATA )
1663  return *this;
1664  }
1665 
1666 #undef __ALLOCATE_DATA
1667 
1668  // -------------------------------------------------------------------------
1669 
1670 #define __ALLOCATE_DATA( I ) \
1671  static_cast<pcl::I&>( **this ).AllocateData( rect, numberOfChannels, colorSpace )
1672 
1683  ImageVariant& AllocateData( const Rect& rect, int numberOfChannels = 1, color_space colorSpace = ColorSpace::Gray )
1684  {
1685  if ( !*this )
1686  CreateImage();
1687  SOLVE_TEMPLATE( __ALLOCATE_DATA )
1688  return *this;
1689  }
1690 
1691 #undef __ALLOCATE_DATA
1692 
1693  // -------------------------------------------------------------------------
1694 
1695 #define __AND( I ) \
1696  static_cast<pcl::I&>( **this ).And( scalar, rect, firstChannel, lastChannel )
1697 
1705  template <typename T>
1706  ImageVariant& And( T scalar,
1707  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
1708  {
1709  if ( *this )
1710  SOLVE_TEMPLATE_REAL( __AND )
1711  return *this;
1712  }
1713 
1714 #undef __AND
1715 
1716  // -------------------------------------------------------------------------
1717 
1718 #define __AND_1( I ) \
1719  ImageVariant::And( static_cast<pcl::I&>( **this ), image, point, channel, rect, firstChannel, lastChannel )
1720 
1721 #define __AND_2( I ) \
1722  image1.And( static_cast<const pcl::I&>( *image2 ), point, channel, rect, firstChannel, lastChannel )
1723 
1724 private:
1725 
1726  template <class P> static
1727  void And( GenericImage<P>& image1, const ImageVariant& image2,
1728  const Point& point, int channel,
1729  const Rect& rect, int firstChannel, int lastChannel )
1730  {
1731  SOLVE_TEMPLATE_REAL_2( image2, __AND_2 )
1732  }
1733 
1734 public:
1735 
1744  const Point& point = Point( int_max ), int channel = -1,
1745  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
1746  {
1747  if ( *this )
1748  if ( image )
1749  SOLVE_TEMPLATE_REAL( __AND_1 )
1750  return *this;
1751  }
1752 
1753 #undef __AND_1
1754 #undef __AND_2
1755 
1756  // -------------------------------------------------------------------------
1757 
1758 #define __APPLIED( I ) \
1759  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Applied( scalar, op, rect, firstChannel, lastChannel ) ) ); \
1760  result.SetOwnership( true )
1761 
1770  template <typename T>
1771  ImageVariant Applied( T scalar, image_op op = ImageOp::Mov,
1772  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
1773  {
1774  ImageVariant result;
1775  if ( *this )
1776  SOLVE_TEMPLATE( __APPLIED )
1777  return result;
1778  }
1779 
1780 #undef __APPLIED
1781 
1782  // -------------------------------------------------------------------------
1783 
1784 #define __APPLIED_1( I ) \
1785  result = ImageVariant::Applied( static_cast<const pcl::I&>( **this ), image, op, point, channel, rect, firstChannel, lastChannel )
1786 
1787 #define __APPLIED_2( I ) \
1788  result.SetImage( *new pcl::I( image1.Applied( static_cast<const pcl::I&>( *image2 ), op, point, channel, rect, firstChannel, lastChannel ) ) ); \
1789  result.SetOwnership( true )
1790 
1791 private:
1792 
1793  template <class P> static
1794  ImageVariant Applied( const GenericImage<P>& image1, const ImageVariant& image2,
1795  image_op op, const Point& point, int channel,
1796  const Rect& rect, int firstChannel, int lastChannel )
1797  {
1798  ImageVariant result;
1799  SOLVE_TEMPLATE_2( image2, __APPLIED_2 )
1800  return result;
1801  }
1802 
1803 public:
1804 
1813  ImageVariant Applied( const ImageVariant& image, image_op op = ImageOp::Mov,
1814  const Point& point = Point( int_max ), int channel = -1,
1815  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
1816  {
1817  ImageVariant result;
1818  if ( *this )
1819  if ( image )
1820  SOLVE_TEMPLATE( __APPLIED_1 )
1821  return result;
1822  }
1823 
1824 #undef __APPLIED_1
1825 #undef __APPLIED_2
1826 
1827  // -------------------------------------------------------------------------
1828 
1829 #define __APPLIED( I ) \
1830  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Applied( transformation, rect, firstChannel, lastChannel ) ) ); \
1831  result.SetOwnership( true )
1832 
1840  ImageVariant Applied( const ImageTransformation& transformation,
1841  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
1842  {
1843  ImageVariant result;
1844  if ( *this )
1845  SOLVE_TEMPLATE( __APPLIED )
1846  return result;
1847  }
1848 
1849 #undef __APPLIED
1850 
1851  // -------------------------------------------------------------------------
1852 
1853 #define __APPLY( I ) \
1854  static_cast<pcl::I&>( **this ).Apply( scalar, op, rect, firstChannel, lastChannel )
1855 
1864  template <typename T>
1865  ImageVariant& Apply( T scalar, image_op op = ImageOp::Mov,
1866  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
1867  {
1868  if ( *this )
1869  SOLVE_TEMPLATE( __APPLY )
1870  return *this;
1871  }
1872 
1873 #undef __APPLY
1874 
1875  // -------------------------------------------------------------------------
1876 
1877 #define __APPLY_1( I ) \
1878  ImageVariant::Apply( static_cast<pcl::I&>( **this ), image, op, point, channel, rect, firstChannel, lastChannel )
1879 
1880 #define __APPLY_2( I ) \
1881  image1.Apply( static_cast<const pcl::I&>( *image2 ), op, point, channel, rect, firstChannel, lastChannel )
1882 
1883 private:
1884 
1885  template <class P> static
1886  void Apply( GenericImage<P>& image1, const ImageVariant& image2,
1887  image_op op, const Point& point, int channel,
1888  const Rect& rect, int firstChannel, int lastChannel )
1889  {
1890  SOLVE_TEMPLATE_2( image2, __APPLY_2 )
1891  }
1892 
1893 public:
1894 
1903  ImageVariant& Apply( const ImageVariant& image, image_op op = ImageOp::Mov,
1904  const Point& point = Point( int_max ), int channel = -1,
1905  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
1906  {
1907  if ( *this )
1908  if ( image )
1909  SOLVE_TEMPLATE( __APPLY_1 )
1910  return *this;
1911  }
1912 
1913 #undef __APPLY_1
1914 #undef __APPLY_2
1915 
1916  // -------------------------------------------------------------------------
1917 
1918 #define __APPLY( I ) \
1919  static_cast<pcl::I&>( **this ).Apply( transformation, rect, firstChannel, lastChannel )
1920 
1928  ImageVariant& Apply( const ImageTransformation& transformation,
1929  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
1930  {
1931  if ( *this )
1932  SOLVE_TEMPLATE( __APPLY )
1933  return *this;
1934  }
1935 
1936 #undef __APPLY
1937 
1938  // -------------------------------------------------------------------------
1939 
1940 #define __ASSIGN_IMAGE_1( I ) \
1941  ImageVariant::AssignImage( static_cast<pcl::I&>( **this ), image, rect, firstChannel, lastChannel )
1942 
1943 #define __ASSIGN_IMAGE_2( I ) \
1944  image1.Assign( static_cast<const pcl::I&>( *image2 ), rect, firstChannel, lastChannel )
1945 
1946 private:
1947 
1948  template <class P> static
1949  void AssignImage( GenericImage<P>& image1, const ImageVariant& image2,
1950  const Rect& rect, int firstChannel, int lastChannel )
1951  {
1952  SOLVE_TEMPLATE_2( image2, __ASSIGN_IMAGE_2 )
1953  }
1954 
1955 public:
1956 
1964  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
1965  {
1966  if ( *this )
1967  if ( image )
1968  SOLVE_TEMPLATE( __ASSIGN_IMAGE_1 )
1969  return *this;
1970  }
1971 
1972 #undef __ASSIGN_IMAGE_1
1973 #undef __ASSIGN_IMAGE_2
1974 
1975  // -------------------------------------------------------------------------
1976 
1977 #define __AVG_DEV( I ) \
1978  result = static_cast<const pcl::I&>( **this ).AvgDev( center, rect, firstChannel, lastChannel, maxProcessors )
1979 
1986  double AvgDev( double center,
1987  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
1988  int maxProcessors = 0 ) const
1989  {
1990  double result = 0;
1991  if ( *this )
1992  SOLVE_TEMPLATE( __AVG_DEV )
1993  return result;
1994  }
1995 
1996 #undef __AVG_DEV
1997 
1998  // -------------------------------------------------------------------------
1999 
2000 #define __2SIDED_AVG_DEV( I ) \
2001  result = static_cast<const pcl::I&>( **this ).TwoSidedAvgDev( center, rect, firstChannel, lastChannel, maxProcessors )
2002 
2011  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
2012  int maxProcessors = 0 ) const
2013  {
2014  TwoSidedEstimate result( 0 );
2015  if ( *this )
2016  SOLVE_TEMPLATE( __2SIDED_AVG_DEV )
2017  return result;
2018  }
2019 
2020 #undef __2SIDED_AVG_DEV
2021 
2022  // -------------------------------------------------------------------------
2023 
2024 #define __BINARIZE( I ) \
2025  static_cast<pcl::I&>( **this ).Binarize( threshold, rect, firstChannel, lastChannel )
2026 
2034  template <typename T>
2035  ImageVariant& Binarize( T threshold, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
2036  {
2037  if ( *this )
2038  SOLVE_TEMPLATE_REAL( __BINARIZE )
2039  return *this;
2040  }
2041 
2042 #undef __BINARIZE
2043 
2044  // -------------------------------------------------------------------------
2045 
2046 #define __BINARIZE( I ) \
2047  static_cast<pcl::I&>( **this ).Binarize( rect, firstChannel, lastChannel )
2048 
2056  ImageVariant& Binarize( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
2057  {
2058  if ( *this )
2059  SOLVE_TEMPLATE_REAL( __BINARIZE )
2060  return *this;
2061  }
2062 
2063 #undef __BINARIZE
2064 
2065  // -------------------------------------------------------------------------
2066 
2067 #define __BINARIZED( I ) \
2068  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Binarized( threshold, rect, firstChannel, lastChannel ) ) ); \
2069  result.SetOwnership( true )
2070 
2078  template <typename T>
2079  ImageVariant Binarized( T threshold, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
2080  {
2081  ImageVariant result;
2082  if ( *this )
2083  SOLVE_TEMPLATE_REAL( __BINARIZED )
2084  return result;
2085  }
2086 
2087 #undef __BINARIZED
2088 
2089  // -------------------------------------------------------------------------
2090 
2091 #define __BINARIZED( I ) \
2092  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Binarized( rect, firstChannel, lastChannel ) ) ); \
2093  result.SetOwnership( true )
2094 
2102  ImageVariant Binarized( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
2103  {
2104  ImageVariant result;
2105  if ( *this )
2106  SOLVE_TEMPLATE_REAL( __BINARIZED )
2107  return result;
2108  }
2109 
2110 #undef __BINARIZED
2111 
2112  // -------------------------------------------------------------------------
2113 
2114 #define __PBMV( I ) \
2115  result = static_cast<const pcl::I&>( **this ).BendMidvariance( center, beta, rect, firstChannel, lastChannel, maxProcessors )
2116 
2125  double BendMidvariance( double center, double beta = 0.2,
2126  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
2127  int maxProcessors = 0 ) const
2128  {
2129  double result = 0;
2130  if ( *this )
2131  SOLVE_TEMPLATE( __PBMV )
2132  return result;
2133  }
2134 
2135 #undef __PBMV
2136 
2137  // -------------------------------------------------------------------------
2138 
2139 #define __BWMV( I ) \
2140  result = static_cast<const pcl::I&>( **this ).BiweightMidvariance( center, sigma, k, reducedLength, rect, firstChannel, lastChannel, maxProcessors )
2141 
2150  double BiweightMidvariance( double center, double sigma, int k = 9, bool reducedLength = false,
2151  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
2152  int maxProcessors = 0 ) const
2153  {
2154  double result = 0;
2155  if ( *this )
2156  SOLVE_TEMPLATE( __BWMV )
2157  return result;
2158  }
2159 
2160 #undef __BWMV
2161 
2162  // -------------------------------------------------------------------------
2163 
2164 #define __2SIDED_BWMV( I ) \
2165  result = static_cast<const pcl::I&>( **this ).TwoSidedBiweightMidvariance( center, sigma, k, reducedLength, rect, firstChannel, lastChannel, maxProcessors )
2166 
2175  TwoSidedEstimate TwoSidedBiweightMidvariance( double center, const TwoSidedEstimate& sigma, int k = 9, bool reducedLength = false,
2176  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
2177  int maxProcessors = 0 ) const
2178  {
2179  TwoSidedEstimate result( 0 );
2180  if ( *this )
2181  SOLVE_TEMPLATE( __2SIDED_BWMV )
2182  return result;
2183  }
2184 
2185 #undef __2SIDED_BWMV
2186 
2187  // -------------------------------------------------------------------------
2188 
2189 #define __BLACK( I ) \
2190  static_cast<pcl::I&>( **this ).Black( rect, firstChannel, lastChannel )
2191 
2198  ImageVariant& Black( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
2199  {
2200  if ( *this )
2201  SOLVE_TEMPLATE( __BLACK )
2202  return *this;
2203  }
2204 
2205 #undef __BLACK
2206 
2207  // -------------------------------------------------------------------------
2208 
2209 #define __BLEND( I ) \
2210  static_cast<pcl::I&>( **this ).Blend( bitmap, point, rect )
2211 
2218  ImageVariant& Blend( const Bitmap& bitmap,
2219  const Point& point = Point( int_max ), const Rect& rect = Rect( 0 ) )
2220  {
2221  if ( *this )
2222  SOLVE_TEMPLATE_REAL( __BLEND )
2223  return *this;
2224  }
2225 
2226 #undef __BLEND
2227 
2228  // -------------------------------------------------------------------------
2229 
2230 #define __BLENDED( I ) \
2231  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Blended( bitmap, point, rect ) ) ); \
2232  result.SetOwnership( true )
2233 
2240  ImageVariant Blended( const Bitmap& bitmap, const Point& point = Point( int_max ), const Rect& rect = Rect( 0 ) ) const
2241  {
2242  ImageVariant result;
2243  if ( *this )
2244  SOLVE_TEMPLATE_REAL( __BLENDED )
2245  return result;
2246  }
2247 
2248 #undef __BLENDED
2249 
2250  // -------------------------------------------------------------------------
2251 
2252 #define __COUNT( I ) \
2253  result = static_cast<const pcl::I&>( **this ).Count( rect, firstChannel, lastChannel, maxProcessors )
2254 
2261  uint64 Count( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1, int maxProcessors = 0 ) const
2262  {
2263  uint64 result = 0;
2264  if ( *this )
2265  SOLVE_TEMPLATE( __COUNT )
2266  return result;
2267  }
2268 
2269 #undef __COUNT
2270 
2271  // -------------------------------------------------------------------------
2272 
2273 #define __CREATE_ALPHA_CHANNELS( I ) \
2274  static_cast<pcl::I&>( **this ).CreateAlphaChannels( n )
2275 
2288  void CreateAlphaChannels( int n )
2289  {
2290  if ( *this )
2291  SOLVE_TEMPLATE( __CREATE_ALPHA_CHANNELS )
2292  }
2293 
2294 #undef __CREATE_ALPHA_CHANNELS
2295 
2296  // -------------------------------------------------------------------------
2297 
2298 #define __CROP( I ) \
2299  static_cast<pcl::I&>( **this ).Crop( fillValues )
2300 
2307  template <typename T>
2308  ImageVariant& Crop( const GenericVector<T>& fillValues )
2309  {
2310  if ( *this )
2311  SOLVE_TEMPLATE( __CROP )
2312  return *this;
2313  }
2314 
2315 #undef __CROP
2316 
2317  // -------------------------------------------------------------------------
2318 
2319 #define __CROP( I ) \
2320  static_cast<pcl::I&>( **this ).Crop()
2321 
2330  {
2331  if ( *this )
2332  SOLVE_TEMPLATE( __CROP )
2333  return *this;
2334  }
2335 
2336 #undef __CROP
2337 
2338  // -------------------------------------------------------------------------
2339 
2340 #define __CROP_BY( I ) \
2341  static_cast<pcl::I&>( **this ).CropBy( left, top, right, bottom, fillValues )
2342 
2349  template <typename T>
2350  ImageVariant& CropBy( int left, int top, int right, int bottom, const GenericVector<T>& fillValues )
2351  {
2352  if ( *this )
2353  SOLVE_TEMPLATE( __CROP_BY )
2354  return *this;
2355  }
2356 
2357 #undef __CROP_BY
2358 
2359  // -------------------------------------------------------------------------
2360 
2361 #define __CROP_BY( I ) \
2362  static_cast<pcl::I&>( **this ).CropBy( left, top, right, bottom )
2363 
2370  ImageVariant& CropBy( int left, int top, int right, int bottom )
2371  {
2372  if ( *this )
2373  SOLVE_TEMPLATE( __CROP_BY )
2374  return *this;
2375  }
2376 
2377 #undef __CROP_BY
2378 
2379  // -------------------------------------------------------------------------
2380 
2381 #define __CROP_TO( I ) \
2382  static_cast<pcl::I&>( **this ).CropTo( rect, fillValues )
2383 
2390  template <typename T>
2391  ImageVariant& CropTo( const Rect& rect, const GenericVector<T>& fillValues )
2392  {
2393  if ( *this )
2394  SOLVE_TEMPLATE( __CROP_TO )
2395  return *this;
2396  }
2397 
2398 #undef __CROP_TO
2399 
2400  // -------------------------------------------------------------------------
2401 
2402 #define __CROP_TO( I ) \
2403  static_cast<pcl::I&>( **this ).CropTo( rect )
2404 
2412  ImageVariant& CropTo( const Rect& rect )
2413  {
2414  if ( *this )
2415  SOLVE_TEMPLATE( __CROP_TO )
2416  return *this;
2417  }
2418 
2419 #undef __CROP_TO
2420 
2421  // -------------------------------------------------------------------------
2422 
2423 #define __CROP_TO( I ) \
2424  static_cast<pcl::I&>( **this ).CropTo( x0, y0, x1, y1, fillValues )
2425 
2432  template <typename T>
2433  ImageVariant& CropTo( int x0, int y0, int x1, int y1, const GenericVector<T>& fillValues )
2434  {
2435  if ( *this )
2436  SOLVE_TEMPLATE( __CROP_TO )
2437  return *this;
2438  }
2439 
2440 #undef __CROP_TO
2441 
2442  // -------------------------------------------------------------------------
2443 
2444 #define __CROP_TO( I ) \
2445  static_cast<pcl::I&>( **this ).CropTo( x0, y0, x1, y1 )
2446 
2454  ImageVariant& CropTo( int x0, int y0, int x1, int y1 )
2455  {
2456  if ( *this )
2457  SOLVE_TEMPLATE( __CROP_TO )
2458  return *this;
2459  }
2460 
2461 #undef __CROP_TO
2462 
2463  // -------------------------------------------------------------------------
2464 
2465 #define __DELETE_ALPHA_CHANNEL( I ) \
2466  static_cast<pcl::I&>( **this ).DeleteAlphaChannel( channel )
2467 
2474  void DeleteAlphaChannel( int channel )
2475  {
2476  if ( *this )
2477  SOLVE_TEMPLATE( __DELETE_ALPHA_CHANNEL )
2478  }
2479 
2480 #undef __DELETE_ALPHA_CHANNEL
2481 
2482  // -------------------------------------------------------------------------
2483 
2484 #define __DELETE_ALPHA_CHANNELS( I ) \
2485  static_cast<pcl::I&>( **this ).DeleteAlphaChannels()
2486 
2495  {
2496  if ( *this )
2497  SOLVE_TEMPLATE( __DELETE_ALPHA_CHANNELS )
2498  }
2499 
2500 #undef __DELETE_ALPHA_CHANNELS
2501 
2502  // -------------------------------------------------------------------------
2503 
2504 #define __DIVIDE( I ) \
2505  static_cast<pcl::I&>( **this ).Divide( scalar, rect, firstChannel, lastChannel )
2506 
2513  template <typename T>
2514  ImageVariant& Divide( T scalar, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
2515  {
2516  if ( *this )
2517  SOLVE_TEMPLATE( __DIVIDE )
2518  return *this;
2519  }
2520 
2521 #undef __DIVIDE
2522 
2526  template <typename T>
2527  ImageVariant& Div( T scalar, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
2528  {
2529  return Divide( scalar, rect, firstChannel, lastChannel );
2530  }
2531 
2532  // -------------------------------------------------------------------------
2533 
2534 #define __DIVIDE_1( I ) \
2535  ImageVariant::Divide( static_cast<pcl::I&>( **this ), image, point, channel, rect, firstChannel, lastChannel )
2536 
2537 #define __DIVIDE_2( I ) \
2538  image1.Divide( static_cast<const pcl::I&>( *image2 ), point, channel, rect, firstChannel, lastChannel )
2539 
2540 private:
2541 
2542  template <class P> static
2543  void Divide( GenericImage<P>& image1, const ImageVariant& image2,
2544  const Point& point, int channel,
2545  const Rect& rect, int firstChannel, int lastChannel )
2546  {
2547  SOLVE_TEMPLATE_2( image2, __DIVIDE_2 )
2548  }
2549 
2550 public:
2551 
2559  const Point& point = Point( int_max ), int channel = -1,
2560  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
2561  {
2562  if ( *this )
2563  if ( image )
2564  SOLVE_TEMPLATE( __DIVIDE_1 )
2565  return *this;
2566  }
2567 
2568 #undef __DIVIDE_1
2569 #undef __DIVIDE_2
2570 
2575  const Point& point = Point( int_max ), int channel = -1,
2576  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
2577  {
2578  return Divide( image, point, channel, rect, firstChannel, lastChannel );
2579  }
2580 
2581  // -------------------------------------------------------------------------
2582 
2583 #define __DIVIDED( I ) \
2584  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Divided( scalar, rect, firstChannel, lastChannel ) ) ); \
2585  result.SetOwnership( true )
2586 
2593  template <typename T>
2595  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
2596  {
2597  ImageVariant result;
2598  if ( *this )
2599  SOLVE_TEMPLATE( __DIVIDED )
2600  return result;
2601  }
2602 
2603 #undef __DIVIDED
2604 
2605  // -------------------------------------------------------------------------
2606 
2607 #define __EXCHANGE_1( I ) \
2608  ImageVariant::Exchange( static_cast<pcl::I&>( **this ), image, point, channel, rect, firstChannel, lastChannel )
2609 
2610 #define __EXCHANGE_2( I ) \
2611  image1.Exchange( static_cast<pcl::I&>( *image2 ), point, channel, rect, firstChannel, lastChannel )
2612 
2613 private:
2614 
2615  template <class P> static
2616  void Exchange( GenericImage<P>& image1, ImageVariant& image2,
2617  const Point& point, int channel,
2618  const Rect& rect, int firstChannel, int lastChannel )
2619  {
2620  SOLVE_TEMPLATE_2( image2, __EXCHANGE_2 )
2621  }
2622 
2623 public:
2624 
2633  const Point& point = Point( int_max ), int channel = -1,
2634  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
2635  {
2636  if ( *this )
2637  if ( image )
2638  SOLVE_TEMPLATE( __EXCHANGE_1 )
2639  return *this;
2640  }
2641 
2642 #undef __EXCHANGE_1
2643 #undef __EXCHANGE_2
2644 
2649  const Point& point = Point( int_max ), int channel = -1,
2650  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
2651  {
2652  return Exchange( image, point, channel, rect, firstChannel, lastChannel );
2653  }
2654 
2655  // -------------------------------------------------------------------------
2656 
2657 #define __FILL( I ) \
2658  static_cast<pcl::I&>( **this ).Fill( scalar, rect, firstChannel, lastChannel )
2659 
2666  template <typename T>
2667  ImageVariant& Fill( T scalar,
2668  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
2669  {
2670  if ( *this )
2671  SOLVE_TEMPLATE( __FILL )
2672  return *this;
2673  }
2674 
2675 #undef __FILL
2676 
2677  // -------------------------------------------------------------------------
2678 
2679 #define __FILL( I ) \
2680  static_cast<pcl::I&>( **this ).Fill( values, rect, firstChannel, lastChannel )
2681 
2689  template <typename T>
2691  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
2692  {
2693  if ( *this )
2694  SOLVE_TEMPLATE( __FILL )
2695  return *this;
2696  }
2697 
2698 #undef __FILL
2699 
2700  // -------------------------------------------------------------------------
2701 
2702 #define __FILLED( I ) \
2703  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Filled( scalar, rect, firstChannel, lastChannel ) ) ); \
2704  result.SetOwnership( true )
2705 
2712  template <typename T>
2714  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
2715  {
2716  ImageVariant result;
2717  if ( *this )
2718  SOLVE_TEMPLATE( __FILLED )
2719  return result;
2720  }
2721 
2722 #undef __FILLED
2723 
2724  // -------------------------------------------------------------------------
2725 
2726 #define __FILLED( I ) \
2727  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Filled( values, rect, firstChannel, lastChannel ) ) ); \
2728  result.SetOwnership( true )
2729 
2737  template <typename T>
2739  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
2740  {
2741  ImageVariant result;
2742  if ( *this )
2743  SOLVE_TEMPLATE( __FILLED )
2744  return result;
2745  }
2746 
2747 #undef __FILLED
2748 
2749  // -------------------------------------------------------------------------
2750 
2751 #define __FORGET_ALPHA_CHANNEL( I ) \
2752  static_cast<pcl::I&>( **this ).ForgetAlphaChannel( channel )
2753 
2761  void ForgetAlphaChannel( int channel )
2762  {
2763  if ( *this )
2764  SOLVE_TEMPLATE( __FORGET_ALPHA_CHANNEL )
2765  }
2766 
2767 #undef __FORGET_ALPHA_CHANNEL
2768 
2769  // -------------------------------------------------------------------------
2770 
2771 #define __FORGET_ALPHA_CHANNELS( I ) \
2772  static_cast<pcl::I&>( **this ).ForgetAlphaChannels()
2773 
2782  {
2783  if ( *this )
2784  SOLVE_TEMPLATE( __FORGET_ALPHA_CHANNELS )
2785  }
2786 
2787 #undef __FORGET_ALPHA_CHANNELS
2788 
2789  // -------------------------------------------------------------------------
2790 
2791 #define __GET_COLUMN( I ) \
2792  static_cast<const pcl::I&>( **this ).GetColumn( buffer, x, channel )
2793 
2801  template <typename T>
2802  void GetColumn( T* buffer, int x, int channel = -1 ) const
2803  {
2804  PCL_PRECONDITION( buffer != 0 )
2805  if ( *this )
2806  SOLVE_TEMPLATE( __GET_COLUMN )
2807  }
2808 
2809 #undef __GET_COLUMN
2810 
2811  // -------------------------------------------------------------------------
2812 
2813 #define __GET_EXTREME_SAMPLE_VALUES( I ) \
2814  static_cast<const pcl::I&>( **this ).GetExtremeSampleValues( min, max, rect, firstChannel, lastChannel, maxProcessors )
2815 
2822  template <typename T>
2823  void GetExtremeSampleValues( T& min, T& max,
2824  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
2825  int maxProcessors = 0 ) const
2826  {
2827  PCL_PRECONDITION( buffer != 0 )
2828  if ( *this )
2829  SOLVE_TEMPLATE( __GET_EXTREME_SAMPLE_VALUES )
2830  }
2831 
2832 #undef __GET_EXTREME_SAMPLE_VALUES
2833 
2834  // -------------------------------------------------------------------------
2835 
2836 #define __GET_INTENSITY_1( I ) \
2837  ImageVariant::GetIntensity( Y, static_cast<const pcl::I&>( **this ), rect, maxProcessors )
2838 
2839 #define __GET_INTENSITY_2( I ) \
2840  image.GetIntensity( static_cast<pcl::I&>( *Y ), rect, maxProcessors )
2841 
2842 private:
2843 
2844  template <class P> static
2845  void GetIntensity( ImageVariant& Y, const GenericImage<P>& image, const Rect& rect, int maxProcessors )
2846  {
2847  if ( !Y.IsComplexSample() )
2848  SOLVE_TEMPLATE_REAL_2( Y, __GET_INTENSITY_2 )
2849  }
2850 
2851 public:
2852 
2865  void GetIntensity( ImageVariant& Y, const Rect& rect = Rect( 0 ), int maxProcessors = 0 ) const
2866  {
2867  if ( *this )
2868  if ( !IsComplexSample() )
2869  {
2870  if ( !Y )
2871  Y.CreateFloatImage( 32 );
2872 
2873  SOLVE_TEMPLATE_REAL( __GET_INTENSITY_1 )
2874  }
2875  }
2876 
2877 #undef __GET_INTENSITY_1
2878 #undef __GET_INTENSITY_2
2879 
2880  // -------------------------------------------------------------------------
2881 
2882 #define __GET_LIGHTNESS_1( I ) \
2883  ImageVariant::GetLightness( L, static_cast<const pcl::I&>( **this ), rect, maxProcessors )
2884 
2885 #define __GET_LIGHTNESS_2( I ) \
2886  image.GetLightness( static_cast<pcl::I&>( *L ), rect, maxProcessors )
2887 
2888 private:
2889 
2890  template <class P> static
2891  void GetLightness( ImageVariant& L, const GenericImage<P>& image, const Rect& rect, int maxProcessors )
2892  {
2893  if ( !L.IsComplexSample() )
2894  SOLVE_TEMPLATE_REAL_2( L, __GET_LIGHTNESS_2 )
2895  }
2896 
2897 public:
2898 
2913  void GetLightness( ImageVariant& L, const Rect& rect = Rect( 0 ), int maxProcessors = 0 ) const
2914  {
2915  if ( *this )
2916  if ( !IsComplexSample() )
2917  {
2918  if ( !L )
2919  L.CreateFloatImage( ( BitsPerSample() < 32 ) ? 32 : ( IsFloatSample() ? BitsPerSample() : 64 ) );
2920 
2921  SOLVE_TEMPLATE_REAL( __GET_LIGHTNESS_1 )
2922  }
2923  }
2924 
2925 #undef __GET_LIGHTNESS_1
2926 #undef __GET_LIGHTNESS_2
2927 
2928  // -------------------------------------------------------------------------
2929 
2930 #define __GET_LUMINANCE_1( I ) \
2931  ImageVariant::GetLuminance( Y, static_cast<const pcl::I&>( **this ), rect, maxProcessors )
2932 
2933 #define __GET_LUMINANCE_2( I ) \
2934  image.GetLuminance( static_cast<pcl::I&>( *Y ), rect, maxProcessors )
2935 
2936 private:
2937 
2938  template <class P> static
2939  void GetLuminance( ImageVariant& Y, const GenericImage<P>& image, const Rect& rect, int maxProcessors )
2940  {
2941  if ( !Y.IsComplexSample() )
2942  SOLVE_TEMPLATE_REAL_2( Y, __GET_LUMINANCE_2 )
2943  }
2944 
2945 public:
2946 
2961  void GetLuminance( ImageVariant& Y, const Rect& rect = Rect( 0 ), int maxProcessors = 0 ) const
2962  {
2963  if ( *this )
2964  if ( !IsComplexSample() )
2965  {
2966  if ( !Y )
2967  Y.CreateFloatImage( ( BitsPerSample() < 32 ) ? 32 : ( IsFloatSample() ? BitsPerSample() : 64 ) );
2968 
2969  SOLVE_TEMPLATE_REAL( __GET_LUMINANCE_1 )
2970  }
2971  }
2972 
2973 #undef __GET_LUMINANCE_1
2974 #undef __GET_LUMINANCE_2
2975 
2976  // -------------------------------------------------------------------------
2977 
2978 #define __GET_ROW( I ) \
2979  static_cast<const pcl::I&>( **this ).GetRow( buffer, y, channel )
2980 
2987  template <typename T>
2988  void GetRow( T* buffer, int y, int channel = -1 ) const
2989  {
2990  PCL_PRECONDITION( buffer != 0 )
2991  if ( *this )
2992  SOLVE_TEMPLATE( __GET_ROW )
2993  }
2994 
2995 #undef __GET_ROW
2996 
2997  // -------------------------------------------------------------------------
2998 
2999 #define __INVERT( I ) \
3000  static_cast<pcl::I&>( **this ).Invert( scalar, rect, firstChannel, lastChannel )
3001 
3008  template <typename T>
3009  ImageVariant& Invert( T scalar, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
3010  {
3011  if ( *this )
3012  SOLVE_TEMPLATE_REAL( __INVERT )
3013  return *this;
3014  }
3015 
3016 #undef __INVERT
3017 
3018  // -------------------------------------------------------------------------
3019 
3020 #define __INVERT( I ) \
3021  static_cast<pcl::I&>( **this ).Invert( rect, firstChannel, lastChannel )
3022 
3030  ImageVariant& Invert( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
3031  {
3032  if ( *this )
3033  SOLVE_TEMPLATE_REAL( __INVERT )
3034  return *this;
3035  }
3036 
3037 #undef __INVERT
3038 
3039  // -------------------------------------------------------------------------
3040 
3041 #define __INVERTED( I ) \
3042  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Inverted( scalar, rect, firstChannel, lastChannel ) ) ); \
3043  result.SetOwnership( true )
3044 
3052  template <typename T>
3054  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
3055  {
3056  ImageVariant result;
3057  if ( *this )
3058  SOLVE_TEMPLATE( __INVERTED )
3059  return result;
3060  }
3061 
3062 #undef __INVERTED
3063 
3064  // -------------------------------------------------------------------------
3065 
3066 #define __INVERTED( I ) \
3067  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Inverted( rect, firstChannel, lastChannel ) ) ); \
3068  result.SetOwnership( true )
3069 
3078  ImageVariant Inverted( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
3079  {
3080  ImageVariant result;
3081  if ( *this )
3082  SOLVE_TEMPLATE( __INVERTED )
3083  return result;
3084  }
3085 
3086 #undef __INVERTED
3087 
3088  // -------------------------------------------------------------------------
3089 
3090 #ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
3091 
3092 #define __IS_SHARED_IMAGE( I ) \
3093  result = static_cast<const pcl::I&>( **this ).IsShared()
3094 
3103  bool IsSharedImage() const noexcept
3104  {
3105  bool result = false;
3106  if ( *this )
3107  SOLVE_TEMPLATE( __IS_SHARED_IMAGE )
3108  return result;
3109  }
3110 
3111 #undef __IS_SHARED_IMAGE
3112 
3113 #endif // !__PCL_BUILDING_PIXINSIGHT_APPLICATION
3114 
3115  // -------------------------------------------------------------------------
3116 
3117 #ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
3118 
3119 #define __SHARED_IMAGE_HANDLE( I ) \
3120  handle = static_cast<const pcl::I&>( **this ).Allocator().Handle()
3121 
3127  void* SharedImageHandle() const noexcept
3128  {
3129  void* handle = nullptr;
3130  if ( *this )
3131  SOLVE_TEMPLATE( __SHARED_IMAGE_HANDLE )
3132  return handle;
3133  }
3134 
3135 #undef __SHARED_IMAGE_HANDLE
3136 
3137 #endif // !__PCL_BUILDING_PIXINSIGHT_APPLICATION
3138 
3139  // -------------------------------------------------------------------------
3140 
3141 #define __IS_UNIQUE_IMAGE( I ) \
3142  result = static_cast<const pcl::I&>( **this ).IsUnique()
3143 
3153  bool IsUniqueImage() const noexcept
3154  {
3155  bool result = false;
3156  if ( *this )
3157  SOLVE_TEMPLATE( __IS_UNIQUE_IMAGE )
3158  return result;
3159  }
3160 
3161 #undef __IS_UNIQUE_IMAGE
3162 
3163  // -------------------------------------------------------------------------
3164 
3165 #define __LOCATE_EXTREME_SAMPLE_VALUES( I ) \
3166  static_cast<const pcl::I&>( **this ).LocateExtremeSampleValues( xmin, ymin, min, xmax, ymax, max, rect, firstChannel, lastChannel, maxProcessors )
3167 
3175  template <typename T>
3176  void LocateExtremeSampleValues( int& xmin, int& ymin, T& min,
3177  int& xmax, int& ymax, T& max,
3178  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
3179  int maxProcessors = 0 ) const
3180  {
3181  if ( *this )
3182  SOLVE_TEMPLATE_REAL( __LOCATE_EXTREME_SAMPLE_VALUES )
3183  }
3184 
3185 #undef __LOCATE_EXTREME_SAMPLE_VALUES
3186 
3187  // -------------------------------------------------------------------------
3188 
3189 #define __LOCATE_EXTREME_SAMPLE_VALUES( I ) \
3190  static_cast<const pcl::I&>( **this ).LocateExtremeSampleValues( pmin, min, pmax, max, rect, firstChannel, lastChannel, maxProcessors )
3191 
3199  template <typename T>
3200  void LocateExtremeSampleValues( Point& pmin, T& min,
3201  Point& pmax, T& max,
3202  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
3203  int maxProcessors = 0 ) const
3204  {
3205  if ( *this )
3206  SOLVE_TEMPLATE_REAL( __LOCATE_EXTREME_SAMPLE_VALUES )
3207  }
3208 
3209 #undef __LOCATE_EXTREME_SAMPLE_VALUES
3210 
3211  // -------------------------------------------------------------------------
3212 
3213 #define __LOCATE_MAXIMUM_SAMPLE_VALUE( I ) \
3214  pcl::I::pixel_traits::FromSample( result, static_cast<const pcl::I&>( **this ).LocateMaximumSampleValue( xmax, ymax, rect, firstChannel, lastChannel, maxProcessors ) )
3215 
3223  double LocateMaximumSampleValue( int& xmax, int& ymax,
3224  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
3225  int maxProcessors = 0 ) const
3226  {
3227  double result = 0;
3228  if ( *this )
3229  SOLVE_TEMPLATE( __LOCATE_MAXIMUM_SAMPLE_VALUE )
3230  return result;
3231  }
3232 
3233 #undef __LOCATE_MAXIMUM_SAMPLE_VALUE
3234 
3235  // -------------------------------------------------------------------------
3236 
3237 #define __LOCATE_MAXIMUM_SAMPLE_VALUE( I ) \
3238  pcl::I::pixel_traits::FromSample( result, static_cast<const pcl::I&>( **this ).LocateMaximumSampleValue( pmax, rect, firstChannel, lastChannel, maxProcessors ) )
3239 
3248  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
3249  int maxProcessors = 0 ) const
3250  {
3251  double result = 0;
3252  if ( *this )
3253  SOLVE_TEMPLATE( __LOCATE_MAXIMUM_SAMPLE_VALUE )
3254  return result;
3255  }
3256 
3257 #undef __LOCATE_MAXIMUM_SAMPLE_VALUE
3258 
3259  // -------------------------------------------------------------------------
3260 
3261 #define __LOCATE_MINIMUM_SAMPLE_VALUE( I ) \
3262  pcl::I::pixel_traits::FromSample( result, static_cast<const pcl::I&>( **this ).LocateMinimumSampleValue( xmin, ymin, rect, firstChannel, lastChannel, maxProcessors ) )
3263 
3271  double LocateMinimumSampleValue( int& xmin, int& ymin,
3272  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
3273  int maxProcessors = 0 ) const
3274  {
3275  double result = 0;
3276  if ( *this )
3277  SOLVE_TEMPLATE( __LOCATE_MINIMUM_SAMPLE_VALUE )
3278  return result;
3279  }
3280 
3281 #undef __LOCATE_MINIMUM_SAMPLE_VALUE
3282 
3283  // -------------------------------------------------------------------------
3284 
3285 #define __LOCATE_MINIMUM_SAMPLE_VALUE( I ) \
3286  pcl::I::pixel_traits::FromSample( result, static_cast<const pcl::I&>( **this ).LocateMinimumSampleValue( pmin, rect, firstChannel, lastChannel, maxProcessors ) )
3287 
3296  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
3297  int maxProcessors = 0 ) const
3298  {
3299  double result = 0;
3300  if ( *this )
3301  SOLVE_TEMPLATE( __LOCATE_MINIMUM_SAMPLE_VALUE )
3302  return result;
3303  }
3304 
3305 #undef __LOCATE_MINIMUM_SAMPLE_VALUE
3306 
3307  // -------------------------------------------------------------------------
3308 
3309 #define __MAD( I ) \
3310  result = static_cast<const pcl::I&>( **this ).MAD( center, rect, firstChannel, lastChannel, maxProcessors )
3311 
3318  double MAD( double center,
3319  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
3320  int maxProcessors = 0 ) const
3321  {
3322  double result = 0;
3323  if ( *this )
3324  SOLVE_TEMPLATE( __MAD )
3325  return result;
3326  }
3327 
3328 #undef __MAD
3329 
3330 // -------------------------------------------------------------------------
3331 
3332 #define __2SIDED_MAD( I ) \
3333  result = static_cast<const pcl::I&>( **this ).TwoSidedMAD( center, rect, firstChannel, lastChannel, maxProcessors )
3334 
3343  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
3344  int maxProcessors = 0 ) const
3345  {
3346  TwoSidedEstimate result( 0 );
3347  if ( *this )
3348  SOLVE_TEMPLATE( __2SIDED_MAD )
3349  return result;
3350  }
3351 
3352 #undef __2SIDED_MAD
3353 
3354 // -------------------------------------------------------------------------
3355 
3356 #define __MAXIMUM( I ) \
3357  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Maximum( scalar, rect, firstChannel, lastChannel ) ) ); \
3358  result.SetOwnership( true )
3359 
3367  template <typename T>
3369  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
3370  {
3371  ImageVariant result;
3372  if ( *this )
3373  SOLVE_TEMPLATE( __MAXIMUM )
3374  return result;
3375  }
3376 
3377 #undef __MAXIMUM
3378 
3379  // -------------------------------------------------------------------------
3380 
3381 #define __MAXIMUM_SAMPLE_VALUE( I ) \
3382  pcl::I::pixel_traits::FromSample( result, static_cast<const pcl::I&>( **this ).MaximumSampleValue( rect, firstChannel, lastChannel, maxProcessors ) )
3383 
3390  double MaximumSampleValue( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
3391  int maxProcessors = 0 ) const
3392  {
3393  double result = 0;
3394  if ( *this )
3395  SOLVE_TEMPLATE( __MAXIMUM_SAMPLE_VALUE )
3396  return result;
3397  }
3398 
3399 #undef __MAXIMUM_SAMPLE_VALUE
3400 
3401  // -------------------------------------------------------------------------
3402 
3403 #define __MEAN( I ) \
3404  result = static_cast<const pcl::I&>( **this ).Mean( rect, firstChannel, lastChannel, maxProcessors )
3405 
3411  double Mean( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
3412  int maxProcessors = 0 ) const
3413  {
3414  double result = 0;
3415  if ( *this )
3416  SOLVE_TEMPLATE( __MEAN )
3417  return result;
3418  }
3419 
3420 #undef __MEAN
3421 
3422  // -------------------------------------------------------------------------
3423 
3424 #define __MEAN_OF_SQUARES( I ) \
3425  result = static_cast<const pcl::I&>( **this ).MeanOfSquares( rect, firstChannel, lastChannel, maxProcessors )
3426 
3433  double MeanOfSquares( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
3434  int maxProcessors = 0 ) const
3435  {
3436  double result = 0;
3437  if ( *this )
3438  SOLVE_TEMPLATE( __MEAN_OF_SQUARES )
3439  return result;
3440  }
3441 
3442 #undef __MEAN_OF_SQUARES
3443 
3444  // -------------------------------------------------------------------------
3445 
3446 #define __MEDIAN( I ) \
3447  result = static_cast<const pcl::I&>( **this ).Median( rect, firstChannel, lastChannel, maxProcessors )
3448 
3454  double Median( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
3455  int maxProcessors = 0 ) const
3456  {
3457  double result = 0;
3458  if ( *this )
3459  SOLVE_TEMPLATE( __MEDIAN )
3460  return result;
3461  }
3462 
3463 #undef __MEDIAN
3464 
3465  // -------------------------------------------------------------------------
3466 
3467 #define __ORDER_STATISTIC( I ) \
3468  result = static_cast<const pcl::I&>( **this ).OrderStatistic( k, rect, firstChannel, lastChannel, maxProcessors )
3469 
3475  double OrderStatistic( double k,
3476  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
3477  int maxProcessors = 0 ) const
3478  {
3479  double result = 0;
3480  if ( *this )
3481  SOLVE_TEMPLATE( __ORDER_STATISTIC )
3482  return result;
3483  }
3484 
3485 #undef __ORDER_STATISTIC
3486 
3487  // -------------------------------------------------------------------------
3488 
3489 #define __MINIMUM( I ) \
3490  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Minimum( scalar, rect, firstChannel, lastChannel ) ) ); \
3491  result.SetOwnership( true )
3492 
3500  template <typename T>
3502  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
3503  {
3504  ImageVariant result;
3505  if ( *this )
3506  SOLVE_TEMPLATE( __MINIMUM )
3507  return result;
3508  }
3509 
3510 #undef __MINIMUM
3511 
3512  // -------------------------------------------------------------------------
3513 
3514 #define __MINIMUM_SAMPLE_VALUE( I ) \
3515  pcl::I::pixel_traits::FromSample( result, static_cast<const pcl::I&>( **this ).MinimumSampleValue( rect, firstChannel, lastChannel, maxProcessors ) )
3516 
3523  double MinimumSampleValue( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
3524  int maxProcessors = 0 ) const
3525  {
3526  double result = 0;
3527  if ( *this )
3528  SOLVE_TEMPLATE( __MINIMUM_SAMPLE_VALUE )
3529  return result;
3530  }
3531 
3532 #undef __MINIMUM_SAMPLE_VALUE
3533 
3534  // -------------------------------------------------------------------------
3535 
3536 #define __MODULUS( I ) \
3537  result = static_cast<const pcl::I&>( **this ).Modulus( rect, firstChannel, lastChannel, maxProcessors )
3538 
3545  double Modulus( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
3546  int maxProcessors = 0 ) const
3547  {
3548  double result = 0;
3549  if ( *this )
3550  SOLVE_TEMPLATE( __MODULUS )
3551  return result;
3552  }
3553 
3554 #undef __MODULUS
3555 
3556  // -------------------------------------------------------------------------
3557 
3558 #define __MOVE( I ) \
3559  static_cast<pcl::I&>( **this ).Move( scalar, rect, firstChannel, lastChannel )
3560 
3567  template <typename T>
3568  ImageVariant& Move( T scalar,
3569  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
3570  {
3571  if ( *this )
3572  SOLVE_TEMPLATE( __MOVE )
3573  return *this;
3574  }
3575 
3576 #undef __MOVE
3577 
3581  template <typename T>
3582  ImageVariant& Mov( T scalar, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
3583  {
3584  return Move( scalar, rect, firstChannel, lastChannel );
3585  }
3586 
3587  // -------------------------------------------------------------------------
3588 
3589 #define __MOVE_1( I ) \
3590  ImageVariant::Move( static_cast<pcl::I&>( **this ), image, point, channel, rect, firstChannel, lastChannel )
3591 
3592 #define __MOVE_2( I ) \
3593  image1.Move( static_cast<const pcl::I&>( *image2 ), point, channel, rect, firstChannel, lastChannel )
3594 
3595 private:
3596 
3597  template <class P> static
3598  void Move( GenericImage<P>& image1, const ImageVariant& image2,
3599  const Point& point, int channel,
3600  const Rect& rect, int firstChannel, int lastChannel )
3601  {
3602  SOLVE_TEMPLATE_2( image2, __MOVE_2 )
3603  }
3604 
3605 public:
3606 
3614  const Point& point = Point( int_max ), int channel = -1,
3615  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
3616  {
3617  if ( *this )
3618  if ( image )
3619  SOLVE_TEMPLATE( __MOVE_1 )
3620  return *this;
3621  }
3622 
3623 #undef __MOVE_1
3624 #undef __MOVE_2
3625 
3626  ImageVariant& Mov( const ImageVariant& image,
3627  const Point& point = Point( int_max ), int channel = -1,
3628  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
3629  {
3630  return Move( image, point, channel, rect, firstChannel, lastChannel );
3631  }
3632 
3633  // -------------------------------------------------------------------------
3634 
3635 #define __MULTIPLY( I ) \
3636  static_cast<pcl::I&>( **this ).Multiply( scalar, rect, firstChannel, lastChannel )
3637 
3645  template <typename T>
3647  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
3648  {
3649  if ( *this )
3650  SOLVE_TEMPLATE( __MULTIPLY )
3651  return *this;
3652  }
3653 
3654 #undef __MULTIPLY
3655 
3659  template <typename T>
3660  ImageVariant& Mul( T scalar,
3661  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
3662  {
3663  return Multiply( scalar, rect, firstChannel, lastChannel );
3664  }
3665 
3666  // -------------------------------------------------------------------------
3667 
3668 #define __MULTIPLY_1( I ) \
3669  ImageVariant::Multiply( static_cast<pcl::I&>( **this ), image, point, channel, rect, firstChannel, lastChannel )
3670 
3671 #define __MULTIPLY_2( I ) \
3672  image1.Multiply( static_cast<const pcl::I&>( *image2 ), point, channel, rect, firstChannel, lastChannel )
3673 
3674 private:
3675 
3676  template <class P> static
3677  void Multiply( GenericImage<P>& image1, const ImageVariant& image2,
3678  const Point& point, int channel,
3679  const Rect& rect, int firstChannel, int lastChannel )
3680  {
3681  SOLVE_TEMPLATE_2( image2, __MULTIPLY_2 )
3682  }
3683 
3684 public:
3685 
3694  const Point& point = Point( int_max ), int channel = -1,
3695  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
3696  {
3697  if ( *this )
3698  if ( image )
3699  SOLVE_TEMPLATE( __MULTIPLY_1 )
3700  return *this;
3701  }
3702 
3703 #undef __MULTIPLY_1
3704 #undef __MULTIPLY_2
3705 
3710  const Point& point = Point( int_max ), int channel = -1,
3711  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
3712  {
3713  return Multiply( image, point, channel, rect, firstChannel, lastChannel );
3714  }
3715 
3716  // -------------------------------------------------------------------------
3717 
3718 #define __MULTIPLIED( I ) \
3719  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Multiplied( scalar, rect, firstChannel, lastChannel ) ) ); \
3720  result.SetOwnership( true )
3721 
3729  template <typename T>
3731  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
3732  {
3733  ImageVariant result;
3734  if ( *this )
3735  SOLVE_TEMPLATE( __MULTIPLIED )
3736  return result;
3737  }
3738 
3739 #undef __MULTIPLIED
3740 
3741  // -------------------------------------------------------------------------
3742 
3743 #define __NAND( I ) \
3744  static_cast<pcl::I&>( **this ).Nand( scalar, rect, firstChannel, lastChannel )
3745 
3753  template <typename T>
3754  ImageVariant& Nand( T scalar,
3755  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
3756  {
3757  if ( *this )
3758  SOLVE_TEMPLATE_REAL( __NAND )
3759  return *this;
3760  }
3761 
3762 #undef __NAND
3763 
3764  // -------------------------------------------------------------------------
3765 
3766 #define __NAND_1( I ) \
3767  ImageVariant::Nand( static_cast<pcl::I&>( **this ), image, point, channel, rect, firstChannel, lastChannel )
3768 
3769 #define __NAND_2( I ) \
3770  image1.Nand( static_cast<const pcl::I&>( *image2 ), point, channel, rect, firstChannel, lastChannel )
3771 
3772 private:
3773 
3774  template <class P> static
3775  void Nand( GenericImage<P>& image1, const ImageVariant& image2,
3776  const Point& point, int channel,
3777  const Rect& rect, int firstChannel, int lastChannel )
3778  {
3779  SOLVE_TEMPLATE_REAL_2( image2, __NAND_2 )
3780  }
3781 
3782 public:
3783 
3792  const Point& point = Point( int_max ), int channel = -1,
3793  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
3794  {
3795  if ( *this )
3796  if ( image )
3797  SOLVE_TEMPLATE_REAL( __NAND_1 )
3798  return *this;
3799  }
3800 
3801 #undef __NAND_1
3802 #undef __NAND_2
3803 
3804  // -------------------------------------------------------------------------
3805 
3806 #define __NOR( I ) \
3807  static_cast<pcl::I&>( **this ).Nor( scalar, rect, firstChannel, lastChannel )
3808 
3816  template <typename T>
3817  ImageVariant& Nor( T scalar,
3818  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
3819  {
3820  if ( *this )
3821  SOLVE_TEMPLATE_REAL( __NOR )
3822  return *this;
3823  }
3824 
3825 #undef __NOR
3826 
3827  // -------------------------------------------------------------------------
3828 
3829 #define __NOR_1( I ) \
3830  ImageVariant::Nor( static_cast<pcl::I&>( **this ), image, point, channel, rect, firstChannel, lastChannel )
3831 
3832 #define __NOR_2( I ) \
3833  image1.Nor( static_cast<const pcl::I&>( *image2 ), point, channel, rect, firstChannel, lastChannel )
3834 
3835 private:
3836 
3837  template <class P> static
3838  void Nor( GenericImage<P>& image1, const ImageVariant& image2,
3839  const Point& point, int channel,
3840  const Rect& rect, int firstChannel, int lastChannel )
3841  {
3842  SOLVE_TEMPLATE_REAL_2( image2, __NOR_2 )
3843  }
3844 
3845 public:
3846 
3855  const Point& point = Point( int_max ), int channel = -1,
3856  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
3857  {
3858  if ( *this )
3859  if ( image )
3860  SOLVE_TEMPLATE_REAL( __NOR_1 )
3861  return *this;
3862  }
3863 
3864 #undef __NOR_1
3865 #undef __NOR_2
3866 
3867  // -------------------------------------------------------------------------
3868 
3869 #define __NORM( I ) \
3870  result = static_cast<const pcl::I&>( **this ).Norm( rect, firstChannel, lastChannel, maxProcessors )
3871 
3878  double Norm( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
3879  int maxProcessors = 0 ) const
3880  {
3881  double result = 0;
3882  if ( *this )
3883  SOLVE_TEMPLATE( __NORM )
3884  return result;
3885  }
3886 
3887 #undef __NORM
3888 
3889  // -------------------------------------------------------------------------
3890 
3891 #define __NORMS( I ) \
3892  result = static_cast<const pcl::I&>( **this ).Norms( maxDegree, rect, firstChannel, lastChannel, maxProcessors )
3893 
3899  Vector Norms( int maxDegree, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
3900  int maxProcessors = 0 ) const
3901  {
3902  Vector result;
3903  if ( *this )
3904  SOLVE_TEMPLATE( __NORMS )
3905  return result;
3906  }
3907 
3908 #undef __NORM
3909 
3910  // -------------------------------------------------------------------------
3911 
3912 #define __NORMALIZE( I ) \
3913  static_cast<pcl::I&>( **this ).Normalize( lowerBound, upperBound, rect, firstChannel, lastChannel )
3914 
3922  template <typename T>
3923  ImageVariant& Normalize( T lowerBound, T upperBound,
3924  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
3925  {
3926  if ( *this )
3927  SOLVE_TEMPLATE_REAL( __NORMALIZE )
3928  return *this;
3929  }
3930 
3931 #undef __NORMALIZE
3932 
3933  // -------------------------------------------------------------------------
3934 
3935 #define __NORMALIZE( I ) \
3936  static_cast<pcl::I&>( **this ).Normalize( rect, firstChannel, lastChannel )
3937 
3945  ImageVariant& Normalize( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
3946  {
3947  if ( *this )
3948  SOLVE_TEMPLATE_REAL( __NORMALIZE )
3949  return *this;
3950  }
3951 
3952 #undef __NORMALIZE
3953 
3954  // -------------------------------------------------------------------------
3955 
3956 #define __NORMALIZED( I ) \
3957  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Normalized( lowerBound, upperBound, rect, firstChannel, lastChannel ) ) ); \
3958  result.SetOwnership( true )
3959 
3967  template <typename T>
3968  ImageVariant Normalized( T lowerBound, T upperBound,
3969  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
3970  {
3971  ImageVariant result;
3972  if ( *this )
3973  SOLVE_TEMPLATE_REAL( __NORMALIZED )
3974  return result;
3975  }
3976 
3977 #undef __NORMALIZED
3978 
3979  // -------------------------------------------------------------------------
3980 
3981 #define __NORMALIZED( I ) \
3982  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Normalized( rect, firstChannel, lastChannel ) ) ); \
3983  result.SetOwnership( true )
3984 
3992  ImageVariant Normalized( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
3993  {
3994  ImageVariant result;
3995  if ( *this )
3996  SOLVE_TEMPLATE_REAL( __NORMALIZED )
3997  return result;
3998  }
3999 
4000 #undef __NORMALIZED
4001 
4002  // -------------------------------------------------------------------------
4003 
4004 #define __NOT( I ) \
4005  static_cast<pcl::I&>( **this ).Not( rect, firstChannel, lastChannel )
4006 
4013  ImageVariant& Not( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4014  {
4015  if ( *this )
4016  SOLVE_TEMPLATE_REAL( __NOT )
4017  return *this;
4018  }
4019 
4020 #undef __NOT
4021 
4022  // -------------------------------------------------------------------------
4023 
4024 #define __ONE( I ) \
4025  static_cast<pcl::I&>( **this ).One( rect, firstChannel, lastChannel )
4026 
4034  ImageVariant& One( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4035  {
4036  if ( *this )
4037  SOLVE_TEMPLATE_REAL( __ONE )
4038  return *this;
4039  }
4040 
4041 #undef __ONE
4042 
4043  // -------------------------------------------------------------------------
4044 
4045 #define __MULTIPLY( I ) \
4046  static_cast<pcl::I&>( **this ) *= scalar
4047 
4051  template <typename T>
4052  ImageVariant& operator *=( T scalar )
4053  {
4054  if ( *this )
4055  SOLVE_TEMPLATE( __MULTIPLY )
4056  return *this;
4057  }
4058 
4059 #undef __MULTIPLY
4060 
4061  // -------------------------------------------------------------------------
4062 
4063 #define __MULTIPLY_1( I ) \
4064  ImageVariant::Multiply( static_cast<pcl::I&>( **this ), image )
4065 
4066 #define __MULTIPLY_2( I ) \
4067  image1 *= static_cast<const pcl::I&>( *image2 )
4068 
4069 private:
4070 
4071  template <class P> static
4072  void Multiply( GenericImage<P>& image1, const ImageVariant& image2 )
4073  {
4074  SOLVE_TEMPLATE_2( image2, __MULTIPLY_2 )
4075  }
4076 
4077 public:
4078 
4082  ImageVariant& operator *=( const ImageVariant& image )
4083  {
4084  if ( *this )
4085  if ( image )
4086  SOLVE_TEMPLATE( __MULTIPLY_1 )
4087  return *this;
4088  }
4089 
4090 #undef __MULTIPLY_1
4091 #undef __MULTIPLY_2
4092 
4093  // -------------------------------------------------------------------------
4094 
4095 #define __ADD( I ) \
4096  static_cast<pcl::I&>( **this ) += scalar
4097 
4101  template <typename T>
4102  ImageVariant& operator +=( T scalar )
4103  {
4104  if ( *this )
4105  SOLVE_TEMPLATE( __ADD )
4106  return *this;
4107  }
4108 
4109 #undef __ADD
4110 
4111  // -------------------------------------------------------------------------
4112 
4113 #define __ADD_1( I ) \
4114  ImageVariant::Add( static_cast<pcl::I&>( **this ), image )
4115 
4116 #define __ADD_2( I ) \
4117  image1 += static_cast<const pcl::I&>( *image2 )
4118 
4119 private:
4120 
4121  template <class P> static
4122  void Add( GenericImage<P>& image1, const ImageVariant& image2 )
4123  {
4124  SOLVE_TEMPLATE_2( image2, __ADD_2 )
4125  }
4126 
4127 public:
4128 
4132  ImageVariant& operator +=( const ImageVariant& image )
4133  {
4134  if ( *this )
4135  if ( image )
4136  SOLVE_TEMPLATE( __ADD_1 )
4137  return *this;
4138  }
4139 
4140 #undef __ADD_1
4141 #undef __ADD_2
4142 
4143  // -------------------------------------------------------------------------
4144 
4145 #define __SUBTRACT( I ) \
4146  static_cast<pcl::I&>( **this ) -= scalar
4147 
4151  template <typename T>
4152  ImageVariant& operator -=( T scalar )
4153  {
4154  if ( *this )
4155  SOLVE_TEMPLATE( __SUBTRACT )
4156  return *this;
4157  }
4158 
4159 #undef __SUBTRACT
4160 
4161  // -------------------------------------------------------------------------
4162 
4163 #define __SUBTRACT_1( I ) \
4164  ImageVariant::Subtract( static_cast<pcl::I&>( **this ), image )
4165 
4166 #define __SUBTRACT_2( I ) \
4167  image1 -= static_cast<const pcl::I&>( *image2 )
4168 
4169 private:
4170 
4171  template <class P> static
4172  void Subtract( GenericImage<P>& image1, const ImageVariant& image2 )
4173  {
4174  SOLVE_TEMPLATE_2( image2, __SUBTRACT_2 )
4175  }
4176 
4177 public:
4178 
4182  ImageVariant& operator -=( const ImageVariant& image )
4183  {
4184  if ( *this )
4185  if ( image )
4186  SOLVE_TEMPLATE( __SUBTRACT_1 )
4187  return *this;
4188  }
4189 
4190 #undef __SUBTRACT_1
4191 #undef __SUBTRACT_2
4192 
4193  // -------------------------------------------------------------------------
4194 
4195 #define __DIVIDE( I ) \
4196  static_cast<pcl::I&>( **this ) /= scalar
4197 
4201  template <typename T>
4202  ImageVariant& operator /=( T scalar )
4203  {
4204  if ( *this )
4205  SOLVE_TEMPLATE( __DIVIDE )
4206  return *this;
4207  }
4208 
4209 #undef __DIVIDE
4210 
4211  // -------------------------------------------------------------------------
4212 
4213 #define __DIVIDE_1( I ) \
4214  ImageVariant::Divide( static_cast<pcl::I&>( **this ), image )
4215 
4216 #define __DIVIDE_2( I ) \
4217  image1 /= static_cast<const pcl::I&>( *image2 )
4218 
4219 private:
4220 
4221  template <class P> static
4222  void Divide( GenericImage<P>& image1, const ImageVariant& image2 )
4223  {
4224  SOLVE_TEMPLATE_2( image2, __DIVIDE_2 )
4225  }
4226 
4227 public:
4228 
4232  ImageVariant& operator /=( const ImageVariant& image )
4233  {
4234  if ( *this )
4235  if ( image )
4236  SOLVE_TEMPLATE( __DIVIDE_1 )
4237  return *this;
4238  }
4239 
4240 #undef __DIVIDE_1
4241 #undef __DIVIDE_2
4242 
4243  // -------------------------------------------------------------------------
4244 
4245 #define __RAISE( I ) \
4246  static_cast<pcl::I&>( **this ) ^= scalar
4247 
4251  template <typename T>
4252  ImageVariant& operator ^=( T scalar )
4253  {
4254  if ( *this )
4255  SOLVE_TEMPLATE( __RAISE )
4256  return *this;
4257  }
4258 
4259 #undef __RAISE
4260 
4261  // -------------------------------------------------------------------------
4262 
4263 #define __RAISE_1( I ) \
4264  ImageVariant::Raise( static_cast<pcl::I&>( **this ), image )
4265 
4266 #define __RAISE_2( I ) \
4267  image1 ^= static_cast<const pcl::I&>( *image2 )
4268 
4269 private:
4270 
4271  template <class P> static
4272  void Raise( GenericImage<P>& image1, const ImageVariant& image2 )
4273  {
4274  SOLVE_TEMPLATE_2( image2, __RAISE_2 )
4275  }
4276 
4277 public:
4278 
4282  ImageVariant& operator ^=( const ImageVariant& image )
4283  {
4284  if ( *this )
4285  if ( image )
4286  SOLVE_TEMPLATE( __RAISE_1 )
4287  return *this;
4288  }
4289 
4290 #undef __RAISE_1
4291 #undef __RAISE_2
4292 
4293  // -------------------------------------------------------------------------
4294 
4295 #define __INVERTED( I ) \
4296  result.SetImage( *new pcl::I( ~static_cast<const pcl::I&>( **this ) ) ); \
4297  result.SetOwnership( true )
4298 
4307  ImageVariant operator ~() const
4308  {
4309  ImageVariant result;
4310  if ( *this )
4311  SOLVE_TEMPLATE( __INVERTED )
4312  return result;
4313  }
4314 
4315 #undef __INVERTED
4316 
4317  // -------------------------------------------------------------------------
4318 
4319 #define __OR( I ) \
4320  static_cast<pcl::I&>( **this ).Or( scalar, rect, firstChannel, lastChannel )
4321 
4329  template <typename T>
4330  ImageVariant& Or( T scalar, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4331  {
4332  if ( *this )
4333  SOLVE_TEMPLATE_REAL( __OR )
4334  return *this;
4335  }
4336 
4337 #undef __OR
4338 
4339  // -------------------------------------------------------------------------
4340 
4341 #define __OR_1( I ) \
4342  ImageVariant::Or( static_cast<pcl::I&>( **this ), image, point, channel, rect, firstChannel, lastChannel )
4343 
4344 #define __OR_2( I ) \
4345  image1.Or( static_cast<const pcl::I&>( *image2 ), point, channel, rect, firstChannel, lastChannel )
4346 
4347 private:
4348 
4349  template <class P> static
4350  void Or( GenericImage<P>& image1, const ImageVariant& image2,
4351  const Point& point, int channel,
4352  const Rect& rect, int firstChannel, int lastChannel )
4353  {
4354  SOLVE_TEMPLATE_REAL_2( image2, __OR_2 )
4355  }
4356 
4357 public:
4358 
4366  ImageVariant& Or( const ImageVariant& image,
4367  const Point& point = Point( int_max ), int channel = -1,
4368  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4369  {
4370  if ( *this )
4371  if ( image )
4372  SOLVE_TEMPLATE_REAL( __OR_1 )
4373  return *this;
4374  }
4375 
4376 #undef __OR_1
4377 #undef __OR_2
4378 
4379  // -------------------------------------------------------------------------
4380 
4381 #define __RAISE( I ) \
4382  static_cast<pcl::I&>( **this ).Raise( scalar, rect, firstChannel, lastChannel )
4383 
4390  template <typename T>
4391  ImageVariant& Raise( T scalar,
4392  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4393  {
4394  if ( *this )
4395  SOLVE_TEMPLATE( __RAISE )
4396  return *this;
4397  }
4398 
4399 #undef __RAISE
4400 
4404  template <typename T>
4405  ImageVariant& Pow( T scalar,
4406  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4407  {
4408  return Raise( scalar, rect, firstChannel, lastChannel );
4409  }
4410 
4411  // -------------------------------------------------------------------------
4412 
4413 #define __Qn( I ) \
4414  result = static_cast<const pcl::I&>( **this ).Qn( rect, firstChannel, lastChannel, maxProcessors )
4415 
4422  double Qn( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
4423  int maxProcessors = 0 ) const
4424  {
4425  double result = false;
4426  if ( *this )
4427  SOLVE_TEMPLATE( __Qn )
4428  return result;
4429  }
4430 
4431 #undef __Qn
4432 
4433  // -------------------------------------------------------------------------
4434 
4435 #define __RAISE_1( I ) \
4436  ImageVariant::Raise( static_cast<pcl::I&>( **this ), image, point, channel, rect, firstChannel, lastChannel )
4437 
4438 #define __RAISE_2( I ) \
4439  image1.Raise( static_cast<const pcl::I&>( *image2 ), point, channel, rect, firstChannel, lastChannel )
4440 
4441 private:
4442 
4443  template <class P> static
4444  void Raise( GenericImage<P>& image1, const ImageVariant& image2,
4445  const Point& point, int channel,
4446  const Rect& rect, int firstChannel, int lastChannel )
4447  {
4448  SOLVE_TEMPLATE_2( image2, __RAISE_2 )
4449  }
4450 
4451 public:
4452 
4461  const Point& point = Point( int_max ), int channel = -1,
4462  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4463  {
4464  if ( *this )
4465  if ( image )
4466  SOLVE_TEMPLATE( __RAISE_1 )
4467  return *this;
4468  }
4469 
4470 #undef __RAISE_1
4471 #undef __RAISE_2
4472 
4477  const Point& point = Point( int_max ), int channel = -1,
4478  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4479  {
4480  return Raise( image, point, channel, rect, firstChannel, lastChannel );
4481  }
4482 
4483  // -------------------------------------------------------------------------
4484 
4485 #define __RAISED( I ) \
4486  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Raised( scalar, rect, firstChannel, lastChannel ) ) ); \
4487  result.SetOwnership( true )
4488 
4495  template <typename T>
4497  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
4498  {
4499  ImageVariant result;
4500  if ( *this )
4501  SOLVE_TEMPLATE( __RAISED )
4502  return result;
4503  }
4504 
4505 #undef __RAISED
4506 
4507  // -------------------------------------------------------------------------
4508 
4509 #define __READ( I ) \
4510  static_cast<pcl::I&>( **this ).Read( file )
4511 
4519  {
4520  if ( *this )
4521  SOLVE_TEMPLATE( __READ )
4522  return *this;
4523  }
4524 
4525 #undef __READ
4526 
4527  // -------------------------------------------------------------------------
4528 
4529 #define __READ( I ) \
4530  static_cast<pcl::I&>( **this ).Read( filePath )
4531 
4538  ImageVariant& Read( const String& filePath )
4539  {
4540  if ( *this )
4541  SOLVE_TEMPLATE( __READ )
4542  return *this;
4543  }
4544 
4545 #undef __READ
4546 
4547  // -------------------------------------------------------------------------
4548 
4549 #define __RESCALE( I ) \
4550  static_cast<pcl::I&>( **this ).Rescale( lowerBound, upperBound, rect, firstChannel, lastChannel )
4551 
4558  template <typename T>
4559  ImageVariant& Rescale( T lowerBound, T upperBound,
4560  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4561  {
4562  if ( *this )
4563  SOLVE_TEMPLATE_REAL( __RESCALE )
4564  return *this;
4565  }
4566 
4567 #undef __RESCALE
4568 
4569  // -------------------------------------------------------------------------
4570 
4571 #define __RESCALE( I ) \
4572  static_cast<pcl::I&>( **this ).Rescale( rect, firstChannel, lastChannel )
4573 
4580  ImageVariant& Rescale( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4581  {
4582  if ( *this )
4583  SOLVE_TEMPLATE_REAL( __RESCALE )
4584  return *this;
4585  }
4586 
4587 #undef __RESCALE
4588 
4589  // -------------------------------------------------------------------------
4590 
4591 #define __RESCALED( I ) \
4592  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Rescaled( lowerBound, upperBound, rect, firstChannel, lastChannel ) ) ); \
4593  result.SetOwnership( true )
4594 
4602  template <typename T>
4603  ImageVariant Rescaled( T lowerBound, T upperBound,
4604  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
4605  {
4606  ImageVariant result;
4607  if ( *this )
4608  SOLVE_TEMPLATE_REAL( __RESCALED )
4609  return result;
4610  }
4611 
4612 #undef __RESCALED
4613 
4614  // -------------------------------------------------------------------------
4615 
4616 #define __RESCALED( I ) \
4617  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Rescaled( rect, firstChannel, lastChannel ) ) ); \
4618  result.SetOwnership( true )
4619 
4627  ImageVariant Rescaled( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
4628  {
4629  ImageVariant result;
4630  if ( *this )
4631  SOLVE_TEMPLATE_REAL( __RESCALED )
4632  return result;
4633  }
4634 
4635 #undef __RESCALED
4636 
4637  // -------------------------------------------------------------------------
4638 
4639 #define __SET_ABSOLUTE_DIFFERENCE( I ) \
4640  static_cast<pcl::I&>( **this ).SetAbsoluteDifference( scalar, rect, firstChannel, lastChannel )
4641 
4650  template <typename T>
4652  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4653  {
4654  if ( *this )
4655  SOLVE_TEMPLATE( __SET_ABSOLUTE_DIFFERENCE )
4656  return *this;
4657  }
4658 
4659 #undef __SET_ABSOLUTE_DIFFERENCE
4660 
4664  template <typename T>
4665  ImageVariant& Dif( T scalar,
4666  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4667  {
4668  return SetAbsoluteDifference( scalar, rect, firstChannel, lastChannel );
4669  }
4670 
4671  // -------------------------------------------------------------------------
4672 
4673 #define __SET_ABSOLUTE_DIFFERENCE_1( I ) \
4674  ImageVariant::SetAbsoluteDifference( static_cast<pcl::I&>( **this ), image, point, channel, rect, firstChannel, lastChannel )
4675 
4676 #define __SET_ABSOLUTE_DIFFERENCE_2( I ) \
4677  image1.SetAbsoluteDifference( static_cast<const pcl::I&>( *image2 ), point, channel, rect, firstChannel, lastChannel )
4678 
4679 private:
4680 
4681  template <class P> static
4682  void SetAbsoluteDifference( GenericImage<P>& image1, const ImageVariant& image2,
4683  const Point& point, int channel,
4684  const Rect& rect, int firstChannel, int lastChannel )
4685  {
4686  SOLVE_TEMPLATE_2( image2, __SET_ABSOLUTE_DIFFERENCE_2 )
4687  }
4688 
4689 public:
4690 
4700  const Point& point = Point( int_max ), int channel = -1,
4701  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4702  {
4703  if ( *this )
4704  if ( image )
4705  SOLVE_TEMPLATE( __SET_ABSOLUTE_DIFFERENCE_1 )
4706  return *this;
4707  }
4708 
4709 #undef __SET_ABSOLUTE_DIFFERENCE_1
4710 #undef __SET_ABSOLUTE_DIFFERENCE_2
4711 
4712  ImageVariant& Dif( const ImageVariant& image,
4713  const Point& point = Point( int_max ), int channel = -1,
4714  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4715  {
4716  return SetAbsoluteDifference( image, point, channel, rect, firstChannel, lastChannel );
4717  }
4718 
4719  // -------------------------------------------------------------------------
4720 
4721 #define __SET_ABSOLUTE_VALUE( I ) \
4722  static_cast<pcl::I&>( **this ).SetAbsoluteValue( rect, firstChannel, lastChannel )
4723 
4731  ImageVariant& SetAbsoluteValue( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4732  {
4733  if ( *this )
4734  SOLVE_TEMPLATE( __SET_ABSOLUTE_VALUE )
4735  return *this;
4736  }
4737 
4738  ImageVariant& Abs( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4739  {
4740  return SetAbsoluteValue( rect, firstChannel, lastChannel );
4741  }
4742 
4743 #undef __SET_ABSOLUTE_VALUE
4744 
4745  // -------------------------------------------------------------------------
4746 
4747 #define __SET_COLOR_SPACE( I ) \
4748  static_cast<pcl::I&>( **this ).SetColorSpace( colorSpace, maxProcessors )
4749 
4757  ImageVariant& SetColorSpace( color_space colorSpace, int maxProcessors = 0 )
4758  {
4759  if ( *this )
4760  SOLVE_TEMPLATE( __SET_COLOR_SPACE )
4761  return *this;
4762  }
4763 
4764 #undef __SET_COLOR_SPACE
4765 
4766  // -------------------------------------------------------------------------
4767 
4768 #define __SET_COLUMN( I ) \
4769  static_cast<pcl::I&>( **this ).SetColumn( buffer, x, channel )
4770 
4778  template <typename T>
4779  ImageVariant& SetColumn( const T* buffer, int x, int channel = -1 )
4780  {
4781  PCL_PRECONDITION( buffer != 0 )
4782  if ( *this )
4783  SOLVE_TEMPLATE( __SET_COLUMN )
4784  return *this;
4785  }
4786 
4787 #undef __SET_COLUMN
4788 
4789  // -------------------------------------------------------------------------
4790 
4791 #define __SET_LIGHTNESS_1( I ) \
4792  ImageVariant::SetLightness( static_cast<pcl::I&>( **this ), L, point, rect, maxProcessors )
4793 
4794 #define __SET_LIGHTNESS_2( I ) \
4795  image.SetLightness( static_cast<const pcl::I&>( *L ), point, rect, maxProcessors )
4796 
4797 private:
4798 
4799  template <class P> static
4800  void SetLightness( GenericImage<P>& image, const ImageVariant& L,
4801  const Point& point, const Rect& rect, int maxProcessors )
4802  {
4803  if ( !L.IsComplexSample() )
4804  SOLVE_TEMPLATE_REAL_2( L, __SET_LIGHTNESS_2 )
4805  }
4806 
4807 public:
4808 
4817  const Point& point = Point( int_max ),
4818  const Rect& rect = Rect( 0 ), int maxProcessors = 0 )
4819  {
4820  if ( *this )
4821  if ( !IsComplexSample() )
4822  if ( L )
4823  SOLVE_TEMPLATE_REAL( __SET_LIGHTNESS_1 )
4824  return *this;
4825  }
4826 
4827 #undef __SET_LIGHTNESS_1
4828 #undef __SET_LIGHTNESS_2
4829 
4830  // -------------------------------------------------------------------------
4831 
4832 #define __SET_LUMINANCE_1( I ) \
4833  ImageVariant::SetLuminance( static_cast<pcl::I&>( **this ), Y, point, rect, maxProcessors )
4834 
4835 #define __SET_LUMINANCE_2( I ) \
4836  image.SetLuminance( static_cast<const pcl::I&>( *Y ), point, rect, maxProcessors )
4837 
4838 private:
4839 
4840  template <class P> static
4841  void SetLuminance( GenericImage<P>& image, const ImageVariant& Y,
4842  const Point& point, const Rect& rect, int maxProcessors )
4843  {
4844  if ( !Y.IsComplexSample() )
4845  SOLVE_TEMPLATE_REAL_2( Y, __SET_LUMINANCE_2 )
4846  }
4847 
4848 public:
4849 
4858  const Point& point = Point( int_max ),
4859  const Rect& rect = Rect( 0 ), int maxProcessors = 0 )
4860  {
4861  if ( *this )
4862  if ( !IsComplexSample() )
4863  if ( Y )
4864  SOLVE_TEMPLATE_REAL( __SET_LUMINANCE_1 )
4865  return *this;
4866  }
4867 
4868 #undef __SET_LUMINANCE_1
4869 #undef __SET_LUMINANCE_2
4870 
4871  // -------------------------------------------------------------------------
4872 
4873 #define __SET_MAXIMUM( I ) \
4874  static_cast<pcl::I&>( **this ).SetMaximum( scalar, rect, firstChannel, lastChannel )
4875 
4883  template <typename T>
4885  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4886  {
4887  if ( *this )
4888  SOLVE_TEMPLATE( __SET_MAXIMUM )
4889  return *this;
4890  }
4891 
4892 #undef __SET_MAXIMUM
4893 
4897  template <typename T>
4898  ImageVariant& Max( T scalar,
4899  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4900  {
4901  return SetMaximum( scalar, rect, firstChannel, lastChannel );
4902  }
4903 
4904  // -------------------------------------------------------------------------
4905 
4906 #define __SET_MAXIMUM_1( I ) \
4907  ImageVariant::SetMaximum( static_cast<pcl::I&>( **this ), image, point, channel, rect, firstChannel, lastChannel )
4908 
4909 #define __SET_MAXIMUM_2( I ) \
4910  image1.SetMaximum( static_cast<const pcl::I&>( *image2 ), point, channel, rect, firstChannel, lastChannel )
4911 
4912 private:
4913 
4914  template <class P> static
4915  void SetMaximum( GenericImage<P>& image1, const ImageVariant& image2,
4916  const Point& point, int channel,
4917  const Rect& rect, int firstChannel, int lastChannel )
4918  {
4919  SOLVE_TEMPLATE_2( image2, __SET_MAXIMUM_2 )
4920  }
4921 
4922 public:
4923 
4933  const Point& point = Point( int_max ), int channel = -1,
4934  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4935  {
4936  if ( *this )
4937  if ( image )
4938  SOLVE_TEMPLATE( __SET_MAXIMUM_1 )
4939  return *this;
4940  }
4941 
4942 #undef __SET_MAXIMUM_1
4943 #undef __SET_MAXIMUM_2
4944 
4949  const Point& point = Point( int_max ), int channel = -1,
4950  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4951  {
4952  return SetMaximum( image, point, channel, rect, firstChannel, lastChannel );
4953  }
4954 
4955  // -------------------------------------------------------------------------
4956 
4957 #define __SET_MINIMUM( I ) \
4958  static_cast<pcl::I&>( **this ).SetMinimum( scalar, rect, firstChannel, lastChannel )
4959 
4967  template <typename T>
4969  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4970  {
4971  if ( *this )
4972  SOLVE_TEMPLATE( __SET_MINIMUM )
4973  return *this;
4974  }
4975 
4976 #undef __SET_MINIMUM
4977 
4981  template <typename T>
4982  ImageVariant& Min( T scalar,
4983  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4984  {
4985  return SetMinimum( scalar, rect, firstChannel, lastChannel );
4986  }
4987 
4988  // -------------------------------------------------------------------------
4989 
4990 #define __SET_MINIMUM_1( I ) \
4991  ImageVariant::SetMinimum( static_cast<pcl::I&>( **this ), image, point, channel, rect, firstChannel, lastChannel )
4992 
4993 #define __SET_MINIMUM_2( I ) \
4994  image1.SetMinimum( static_cast<const pcl::I&>( *image2 ), point, channel, rect, firstChannel, lastChannel )
4995 
4996 private:
4997 
4998  template <class P> static
4999  void SetMinimum( GenericImage<P>& image1, const ImageVariant& image2,
5000  const Point& point, int channel,
5001  const Rect& rect, int firstChannel, int lastChannel )
5002  {
5003  SOLVE_TEMPLATE_2( image2, __SET_MINIMUM_2 )
5004  }
5005 
5006 public:
5007 
5017  const Point& point = Point( int_max ), int channel = -1,
5018  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
5019  {
5020  if ( *this )
5021  if ( image )
5022  SOLVE_TEMPLATE( __SET_MINIMUM_1 )
5023  return *this;
5024  }
5025 
5026 #undef __SET_MINIMUM_1
5027 #undef __SET_MINIMUM_2
5028 
5033  const Point& point = Point( int_max ), int channel = -1,
5034  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
5035  {
5036  return SetMinimum( image, point, channel, rect, firstChannel, lastChannel );
5037  }
5038 
5039  // -------------------------------------------------------------------------
5040 
5041 #define __Sn( I ) \
5042  result = static_cast<const pcl::I&>( **this ).Sn( rect, firstChannel, lastChannel, maxProcessors )
5043 
5050  double Sn( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
5051  int maxProcessors = 0 ) const
5052  {
5053  double result = false;
5054  if ( *this )
5055  SOLVE_TEMPLATE( __Sn )
5056  return result;
5057  }
5058 
5059 #undef __Sn
5060 
5061  // -------------------------------------------------------------------------
5062 
5063 #define __SET_ROW( I ) \
5064  static_cast<pcl::I&>( **this ).SetRow( buffer, y, channel )
5065 
5073  template <typename T>
5074  ImageVariant& SetRow( const T* buffer, int y, int channel = -1 )
5075  {
5076  PCL_PRECONDITION( buffer != 0 )
5077  if ( *this )
5078  SOLVE_TEMPLATE( __SET_ROW )
5079  return *this;
5080  }
5081 
5082 #undef __SET_ROW
5083 
5084  // -------------------------------------------------------------------------
5085 
5086 #define __ENSURE_UNIQUE_IMAGE( I ) \
5087  static_cast<pcl::I&>( **this ).EnsureUnique()
5088 
5098  {
5099  if ( *this )
5100  SOLVE_TEMPLATE( __ENSURE_UNIQUE_IMAGE )
5101  return *this;
5102  }
5103 
5104 #undef __ENSURE_UNIQUE_IMAGE
5105 
5106  // -------------------------------------------------------------------------
5107 
5108 #define __ENSURE_LOCAL_IMAGE( I ) \
5109  static_cast<pcl::I&>( **this ).EnsureLocal()
5110 
5119  {
5120  if ( *this )
5121  SOLVE_TEMPLATE( __ENSURE_LOCAL_IMAGE )
5122  return *this;
5123  }
5124 
5125 #undef __ENSURE_LOCAL_IMAGE
5126 
5127  // -------------------------------------------------------------------------
5128 
5129 #define __SHIFT( I ) \
5130  static_cast<pcl::I&>( **this ).Shift( fillValues )
5131 
5138  template <typename T>
5139  ImageVariant& Shift( const GenericVector<T>& fillValues )
5140  {
5141  if ( *this )
5142  SOLVE_TEMPLATE( __SHIFT )
5143  return *this;
5144  }
5145 
5146 #undef __SHIFT
5147 
5148  // -------------------------------------------------------------------------
5149 
5150 #define __SHIFT( I ) \
5151  static_cast<pcl::I&>( **this ).Shift()
5152 
5161  {
5162  if ( *this )
5163  SOLVE_TEMPLATE( __SHIFT )
5164  return *this;
5165  }
5166 
5167 #undef __SHIFT
5168 
5169  // -------------------------------------------------------------------------
5170 
5171 #define __SHIFT_BY( I ) \
5172  static_cast<pcl::I&>( **this ).ShiftBy( dx, dy, fillValues )
5173 
5180  template <typename T>
5181  ImageVariant& ShiftBy( int dx, int dy, const GenericVector<T>& fillValues )
5182  {
5183  if ( *this )
5184  SOLVE_TEMPLATE( __SHIFT_BY )
5185  return *this;
5186  }
5187 
5188 #undef __SHIFT_BY
5189 
5190  // -------------------------------------------------------------------------
5191 
5192 #define __SHIFT_BY( I ) \
5193  static_cast<pcl::I&>( **this ).ShiftBy( dx, dy )
5194 
5202  ImageVariant& ShiftBy( int dx, int dy )
5203  {
5204  if ( *this )
5205  SOLVE_TEMPLATE( __SHIFT_BY )
5206  return *this;
5207  }
5208 
5209 #undef __SHIFT_BY
5210 
5211  // -------------------------------------------------------------------------
5212 
5213 #define __SHIFT_TO( I ) \
5214  static_cast<pcl::I&>( **this ).ShiftTo( x, y, fillValues )
5215 
5222  template <typename T>
5223  ImageVariant& ShiftTo( int x, int y, const GenericVector<T>& fillValues )
5224  {
5225  if ( *this )
5226  SOLVE_TEMPLATE( __SHIFT_TO )
5227  return *this;
5228  }
5229 
5230 #undef __SHIFT_TO
5231 
5232  // -------------------------------------------------------------------------
5233 
5234 #define __SHIFT_TO( I ) \
5235  static_cast<pcl::I&>( **this ).ShiftTo( x, y )
5236 
5244  ImageVariant& ShiftTo( int x, int y )
5245  {
5246  if ( *this )
5247  SOLVE_TEMPLATE( __SHIFT_TO )
5248  return *this;
5249  }
5250 
5251 #undef __SHIFT_TO
5252 
5253  // -------------------------------------------------------------------------
5254 
5255 #define __SHIFT_TO( I ) \
5256  static_cast<pcl::I&>( **this ).ShiftTo( p, fillValues )
5257 
5264  template <typename T>
5265  ImageVariant& ShiftTo( const Point& p, const GenericVector<T>& fillValues )
5266  {
5267  if ( *this )
5268  SOLVE_TEMPLATE( __SHIFT_TO )
5269  return *this;
5270  }
5271 
5272 #undef __SHIFT_TO
5273 
5274  // -------------------------------------------------------------------------
5275 
5276 #define __SHIFT_TO( I ) \
5277  static_cast<pcl::I&>( **this ).ShiftTo( p )
5278 
5287  {
5288  if ( *this )
5289  SOLVE_TEMPLATE( __SHIFT_TO )
5290  return *this;
5291  }
5292 
5293 #undef __SHIFT_TO
5294 
5295  // -------------------------------------------------------------------------
5296 
5297 #define __SHIFT_TO_BOTTOM_LEFT( I ) \
5298  static_cast<pcl::I&>( **this ).ShiftToBottomLeft( width, height, fillValues )
5299 
5307  template <typename T>
5308  ImageVariant& ShiftToBottomLeft( int width, int height, const GenericVector<T>& fillValues )
5309  {
5310  if ( *this )
5311  SOLVE_TEMPLATE( __SHIFT_TO_BOTTOM_LEFT )
5312  return *this;
5313  }
5314 
5315 #undef __SHIFT_TO_BOTTOM_LEFT
5316 
5317  // -------------------------------------------------------------------------
5318 
5319 #define __SHIFT_TO_BOTTOM_LEFT( I ) \
5320  static_cast<pcl::I&>( **this ).ShiftToBottomLeft( width, height )
5321 
5331  ImageVariant& ShiftToBottomLeft( int width, int height )
5332  {
5333  if ( *this )
5334  SOLVE_TEMPLATE( __SHIFT_TO_BOTTOM_LEFT )
5335  return *this;
5336  }
5337 
5338 #undef __SHIFT_TO_BOTTOM_LEFT
5339 
5340  // -------------------------------------------------------------------------
5341 
5342 #define __SHIFT_TO_BOTTOM_RIGHT( I ) \
5343  static_cast<pcl::I&>( **this ).ShiftToBottomRight( width, height, fillValues )
5344 
5352  template <typename T>
5353  ImageVariant& ShiftToBottomRight( int width, int height, const GenericVector<T>& fillValues )
5354  {
5355  if ( *this )
5356  SOLVE_TEMPLATE( __SHIFT_TO_BOTTOM_RIGHT )
5357  return *this;
5358  }
5359 
5360 #undef __SHIFT_TO_BOTTOM_RIGHT
5361 
5362  // -------------------------------------------------------------------------
5363 
5364 #define __SHIFT_TO_BOTTOM_RIGHT( I ) \
5365  static_cast<pcl::I&>( **this ).ShiftToBottomRight( width, height )
5366 
5376  ImageVariant& ShiftToBottomRight( int width, int height )
5377  {
5378  if ( *this )
5379  SOLVE_TEMPLATE( __SHIFT_TO_BOTTOM_RIGHT )
5380  return *this;
5381  }
5382 
5383 #undef __SHIFT_TO_BOTTOM_RIGHT
5384 
5385  // -------------------------------------------------------------------------
5386 
5387 #define __SHIFT_TO_BOTTOM_CENTER( I ) \
5388  static_cast<pcl::I&>( **this ).ShiftToCenter( width, height, fillValues )
5389 
5397  template <typename T>
5398  ImageVariant& ShiftToCenter( int width, int height, const GenericVector<T>& fillValues )
5399  {
5400  if ( *this )
5401  SOLVE_TEMPLATE( __SHIFT_TO_BOTTOM_CENTER )
5402  return *this;
5403  }
5404 
5405 #undef __SHIFT_TO_BOTTOM_CENTER
5406 
5407  // -------------------------------------------------------------------------
5408 
5409 #define __SHIFT_TO_BOTTOM_CENTER( I ) \
5410  static_cast<pcl::I&>( **this ).ShiftToCenter( width, height )
5411 
5421  ImageVariant& ShiftToCenter( int width, int height )
5422  {
5423  if ( *this )
5424  SOLVE_TEMPLATE( __SHIFT_TO_BOTTOM_CENTER )
5425  return *this;
5426  }
5427 
5428 #undef __SHIFT_TO_BOTTOM_CENTER
5429 
5430  // -------------------------------------------------------------------------
5431 
5432 #define __SHIFT_TO_TOP_LEFT( I ) \
5433  static_cast<pcl::I&>( **this ).ShiftToTopLeft( width, height, fillValues )
5434 
5442  template <typename T>
5443  ImageVariant& ShiftToTopLeft( int width, int height, const GenericVector<T>& fillValues )
5444  {
5445  if ( *this )
5446  SOLVE_TEMPLATE( __SHIFT_TO_TOP_LEFT )
5447  return *this;
5448  }
5449 
5450 #undef __SHIFT_TO_TOP_LEFT
5451 
5452  // -------------------------------------------------------------------------
5453 
5454 #define __SHIFT_TO_TOP_LEFT( I ) \
5455  static_cast<pcl::I&>( **this ).ShiftToTopLeft( width, height )
5456 
5466  ImageVariant& ShiftToTopLeft( int width, int height )
5467  {
5468  if ( *this )
5469  SOLVE_TEMPLATE( __SHIFT_TO_TOP_LEFT )
5470  return *this;
5471  }
5472 
5473 #undef __SHIFT_TO_TOP_LEFT
5474 
5475  // -------------------------------------------------------------------------
5476 
5477 #define __SHIFT_TO_TOP_RIGHT( I ) \
5478  static_cast<pcl::I&>( **this ).ShiftToTopRight( width, height, fillValues )
5479 
5487  template <typename T>
5488  ImageVariant& ShiftToTopRight( int width, int height, const GenericVector< T >& fillValues )
5489  {
5490  if ( *this )
5491  SOLVE_TEMPLATE( __SHIFT_TO_TOP_RIGHT )
5492  return *this;
5493  }
5494 
5495 #undef __SHIFT_TO_TOP_RIGHT
5496 
5497  // -------------------------------------------------------------------------
5498 
5499 #define __SHIFT_TO_TOP_RIGHT( I ) \
5500  static_cast<pcl::I&>( **this ).ShiftToTopRight( width, height )
5501 
5511  ImageVariant& ShiftToTopRight( int width, int height )
5512  {
5513  if ( *this )
5514  SOLVE_TEMPLATE( __SHIFT_TO_TOP_RIGHT )
5515  return *this;
5516  }
5517 
5518 #undef __SHIFT_TO_TOP_RIGHT
5519 
5520  // -------------------------------------------------------------------------
5521 
5522 #define __STD_DEV( I ) \
5523  result = static_cast<const pcl::I&>( **this ).StdDev( rect, firstChannel, lastChannel, maxProcessors )
5524 
5530  double StdDev( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
5531  int maxProcessors = 0 ) const
5532  {
5533  double result = 0;
5534  if ( *this )
5535  SOLVE_TEMPLATE( __STD_DEV )
5536  return result;
5537  }
5538 
5539 #undef __STD_DEV
5540 
5541  // -------------------------------------------------------------------------
5542 
5543 #define __SUBTRACT( I ) \
5544  static_cast<pcl::I&>( **this ).Subtract( scalar, rect, firstChannel, lastChannel )
5545 
5553  template <typename T>
5555  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
5556  {
5557  if ( *this )
5558  SOLVE_TEMPLATE( __SUBTRACT )
5559  return *this;
5560  }
5561 
5562 #undef __SUBTRACT
5563 
5567  template <typename T>
5568  ImageVariant& Sub( T scalar,
5569  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
5570  {
5571  return Subtract( scalar, rect, firstChannel, lastChannel );
5572  }
5573 
5574  // -------------------------------------------------------------------------
5575 
5576 #define __SUBTRACT_1( I ) \
5577  ImageVariant::Subtract( static_cast<pcl::I&>( **this ), image, point, channel, rect, firstChannel, lastChannel )
5578 
5579 #define __SUBTRACT_2( I ) \
5580  image1.Subtract( static_cast<const pcl::I&>( *image2 ), point, channel, rect, firstChannel, lastChannel )
5581 
5582 private:
5583 
5584  template <class P> static
5585  void Subtract( GenericImage<P>& image1, const ImageVariant& image2,
5586  const Point& point, int channel,
5587  const Rect& rect, int firstChannel, int lastChannel )
5588  {
5589  SOLVE_TEMPLATE_2( image2, __SUBTRACT_2 )
5590  }
5591 
5592 public:
5593 
5602  const Point& point = Point( int_max ), int channel = -1,
5603  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
5604  {
5605  if ( *this )
5606  if ( image )
5607  SOLVE_TEMPLATE( __SUBTRACT_1 )
5608  return *this;
5609  }
5610 
5611 #undef __SUBTRACT_1
5612 #undef __SUBTRACT_2
5613 
5618  const Point& point = Point( int_max ), int channel = -1,
5619  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
5620  {
5621  return Subtract( image, point, channel, rect, firstChannel, lastChannel );
5622  }
5623 
5624  // -------------------------------------------------------------------------
5625 
5626 #define __SUBTRACTED( I ) \
5627  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Subtracted( scalar, rect, firstChannel, lastChannel ) ) ); \
5628  result.SetOwnership( true )
5629 
5637  template <typename T>
5639  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
5640  {
5641  ImageVariant result;
5642  if ( *this )
5643  SOLVE_TEMPLATE( __SUBTRACTED )
5644  return result;
5645  }
5646 
5647 #undef __SUBTRACTED
5648 
5649  // -------------------------------------------------------------------------
5650 
5651 #define __SUM_OF_SQUARES( I ) \
5652  result = static_cast<const pcl::I&>( **this ).SumOfSquares( rect, firstChannel, lastChannel, maxProcessors )
5653 
5660  double SumOfSquares( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
5661  int maxProcessors = 0 ) const
5662  {
5663  double result = 0;
5664  if ( *this )
5665  SOLVE_TEMPLATE( __SUM_OF_SQUARES )
5666  return result;
5667  }
5668 
5669 #undef __SUM_OF_SQUARES
5670 
5671  // -------------------------------------------------------------------------
5672 
5673 #define __TRANSFER_IMAGE_1( I ) \
5674  ImageVariant::TransferImage( static_cast<pcl::I&>( **this ), image )
5675 
5676 #define __TRANSFER_IMAGE_2( I ) \
5677  image1.Transfer( static_cast<pcl::I&>( *image2 ) )
5678 
5679 private:
5680 
5681  template <class P> static
5682  void TransferImage( GenericImage<P>& image1, ImageVariant& image2 )
5683  {
5684  SOLVE_TEMPLATE_2( image2, __TRANSFER_IMAGE_2 )
5685  }
5686 
5687 public:
5688 
5698  {
5699  if ( *this )
5700  if ( image )
5701  SOLVE_TEMPLATE( __TRANSFER_IMAGE_1 )
5702  return *this;
5703  }
5704 
5705 #undef __TRANSFER_IMAGE_1
5706 #undef __TRANSFER_IMAGE_2
5707 
5708  // -------------------------------------------------------------------------
5709 
5710 #define __TRANSFORM( I ) \
5711  static_cast<const pcl::I&>( **this ).Transform( transform, rect, firstChannel, lastChannel )
5712 
5721  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
5722  {
5723  if ( *this )
5724  SOLVE_TEMPLATE( __TRANSFORM )
5725  }
5726 
5727 #undef __TRANSFORM
5728 
5729  // -------------------------------------------------------------------------
5730 
5731 #define __TRUNCATE( I ) \
5732  static_cast<pcl::I&>( **this ).Truncate( lowerBound, upperBound, rect, firstChannel, lastChannel )
5733 
5741  template <typename T>
5742  ImageVariant& Truncate( T lowerBound, T upperBound,
5743  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
5744  {
5745  if ( *this )
5746  SOLVE_TEMPLATE_REAL( __TRUNCATE )
5747  return *this;
5748  }
5749 
5750 #undef __TRUNCATE
5751 
5752  // -------------------------------------------------------------------------
5753 
5754 #define __TRUNCATE( I ) \
5755  static_cast<pcl::I&>( **this ).Truncate( rect, firstChannel, lastChannel )
5756 
5764  ImageVariant& Truncate( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
5765  {
5766  if ( *this )
5767  SOLVE_TEMPLATE_REAL( __TRUNCATE )
5768  return *this;
5769  }
5770 
5771 #undef __TRUNCATE
5772 
5773  // -------------------------------------------------------------------------
5774 
5775 #define __TRUNCATED( I ) \
5776  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Truncated( lowerBound, upperBound, rect, firstChannel, lastChannel ) ) ); \
5777  result.SetOwnership( true )
5778 
5786  template <typename T>
5787  ImageVariant Truncated( T lowerBound, T upperBound,
5788  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
5789  {
5790  ImageVariant result;
5791  if ( *this )
5792  SOLVE_TEMPLATE( __TRUNCATED )
5793  return result;
5794  }
5795 
5796 #undef __TRUNCATED
5797 
5798  // -------------------------------------------------------------------------
5799 
5800 #define __TRUNCATED( I ) \
5801  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Truncated( rect, firstChannel, lastChannel ) ) ); \
5802  result.SetOwnership( true )
5803 
5811  ImageVariant Truncated( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
5812  {
5813  ImageVariant result;
5814  if ( *this )
5815  SOLVE_TEMPLATE( __TRUNCATED )
5816  return result;
5817  }
5818 
5819 #undef __TRUNCATED
5820 
5821  // -------------------------------------------------------------------------
5822 
5823 #define __VARIANCE( I ) \
5824  result = static_cast<const pcl::I&>( **this ).Variance( rect, firstChannel, lastChannel, maxProcessors )
5825 
5831  double Variance( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1, int maxProcessors = 0 ) const
5832  {
5833  double result = 0;
5834  if ( *this )
5835  SOLVE_TEMPLATE( __VARIANCE )
5836  return result;
5837  }
5838 
5839 #undef __VARIANCE
5840 
5841  // -------------------------------------------------------------------------
5842 
5843 #define __WHITE( I ) \
5844  static_cast<pcl::I&>( **this ).White( rect, firstChannel, lastChannel )
5845 
5852  ImageVariant& White( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
5853  {
5854  if ( *this )
5855  SOLVE_TEMPLATE_REAL( __WHITE )
5856  return *this;
5857  }
5858 
5859 #undef __WHITE
5860 
5861  // -------------------------------------------------------------------------
5862 
5863 #define __WRITE( I ) \
5864  static_cast<const pcl::I&>( **this ).Write( file, rect, firstChannel, lastChannel )
5865 
5873  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
5874  {
5875  if ( *this )
5876  SOLVE_TEMPLATE( __WRITE )
5877  return const_cast<ImageVariant&>( *this );
5878  }
5879 
5880 #undef __WRITE
5881 
5882  // -------------------------------------------------------------------------
5883 
5884 #define __WRITE( I ) \
5885  static_cast<const pcl::I&>( **this ).Write( filePath, rect, firstChannel, lastChannel )
5886 
5893  ImageVariant& Write( const String& filePath,
5894  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
5895  {
5896  if ( *this )
5897  SOLVE_TEMPLATE( __WRITE )
5898  return const_cast<ImageVariant&>( *this );
5899  }
5900 
5901 #undef __WRITE
5902 
5903  // -------------------------------------------------------------------------
5904 
5905 #define __XNOR( I ) \
5906  static_cast<pcl::I&>( **this ).Xnor( scalar, rect, firstChannel, lastChannel )
5907 
5915  template <typename T>
5916  ImageVariant& Xnor( T scalar,
5917  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
5918  {
5919  if ( *this )
5920  SOLVE_TEMPLATE_REAL( __XNOR )
5921  return *this;
5922  }
5923 
5924 #undef __XNOR
5925 
5926  // -------------------------------------------------------------------------
5927 
5928 #define __XNOR_1( I ) \
5929  ImageVariant::Xnor( static_cast<pcl::I&>( **this ), image, point, channel, rect, firstChannel, lastChannel )
5930 
5931 #define __XNOR_2( I ) \
5932  image1.Xnor( static_cast<const pcl::I&>( *image2 ), point, channel, rect, firstChannel, lastChannel )
5933 
5934 private:
5935 
5936  template <class P> static
5937  void Xnor( GenericImage<P>& image1, const ImageVariant& image2,
5938  const Point& point, int channel,
5939  const Rect& rect, int firstChannel, int lastChannel )
5940  {
5941  SOLVE_TEMPLATE_REAL_2( image2, __XNOR_2 )
5942  }
5943 
5944 public:
5945 
5954  const Point& point = Point( int_max ), int channel = -1,
5955  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
5956  {
5957  if ( *this )
5958  if ( image )
5959  SOLVE_TEMPLATE_REAL( __XNOR_1 )
5960  return *this;
5961  }
5962 
5963 #undef __XNOR_1
5964 #undef __XNOR_2
5965 
5966  // -------------------------------------------------------------------------
5967 
5968 #define __XOR( I ) \
5969  static_cast<pcl::I&>( **this ).Xor( scalar, rect, firstChannel, lastChannel )
5970 
5978  template <typename T>
5979  ImageVariant& Xor( T scalar,
5980  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
5981  {
5982  if ( *this )
5983  SOLVE_TEMPLATE_REAL( __XOR )
5984  return *this;
5985  }
5986 
5987 #undef __XOR
5988 
5989  // -------------------------------------------------------------------------
5990 
5991 #define __XOR_1( I ) \
5992  ImageVariant::Xor( static_cast<pcl::I&>( **this ), image, point, channel, rect, firstChannel, lastChannel )
5993 
5994 #define __XOR_2( I ) \
5995  image1.Xor( static_cast<const pcl::I&>( *image2 ), point, channel, rect, firstChannel, lastChannel )
5996 
5997 private:
5998 
5999  template <class P> static
6000  void Xor( GenericImage<P>& image1, const ImageVariant& image2,
6001  const Point& point, int channel,
6002  const Rect& rect, int firstChannel, int lastChannel )
6003  {
6004  SOLVE_TEMPLATE_REAL_2( image2, __XOR_2 )
6005  }
6006 
6007 public:
6008 
6017  const Point& point = Point( int_max ), int channel = -1,
6018  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
6019  {
6020  if ( *this )
6021  if ( image )
6022  SOLVE_TEMPLATE_REAL( __XOR_1 )
6023  return *this;
6024  }
6025 
6026 #undef __XOR_1
6027 #undef __XOR_2
6028 
6029  // -------------------------------------------------------------------------
6030 
6031 #define __ZERO( I ) \
6032  static_cast<pcl::I&>( **this ).Zero( rect, firstChannel, lastChannel )
6033 
6041  ImageVariant& Zero( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
6042  {
6043  if ( *this )
6044  SOLVE_TEMPLATE_REAL( __ZERO )
6045  return *this;
6046  }
6047 
6048 #undef __ZERO
6049 
6050  // -------------------------------------------------------------------------
6051 
6052 #define __COMPRESS( I ) \
6053  return static_cast<const pcl::I&>( **this ).Compress( compressor, rect, channel, perf )
6054 
6066  const Rect& rect = Rect( 0 ), int channel = -1,
6067  Compression::Performance* perf = nullptr ) const
6068  {
6069  if ( *this )
6070  SOLVE_TEMPLATE( __COMPRESS )
6071  return Compression::subblock_list();
6072  }
6073 
6074 #undef __COMPRESS
6075 
6076  // -------------------------------------------------------------------------
6077 
6082  template <class P>
6083  bool IsAs( const pcl::GenericImage<P>& ) const
6084  {
6085  return m_data->image && m_data->isFloatSample == P::IsFloatSample() &&
6086  m_data->isComplexSample == P::IsComplexSample() &&
6087  m_data->bitsPerSample == P::BitsPerSample();
6088  }
6089 
6099  {
6100  image.m_data->Attach();
6101  DetachFromData();
6102  m_data = image.m_data;
6103  return *this;
6104  }
6105 
6111  ImageVariant& operator =( const ImageVariant& image )
6112  {
6113  return Assign( image );
6114  }
6115 
6116 #define TRANSFER_BODY() \
6117  if ( &image != this ) /* N.B.: Self-movement incompatible with server-side SharedImage */ \
6118  { \
6119  DetachFromData(); \
6120  m_data = image.m_data; \
6121  image.m_data = nullptr; \
6122  } \
6123  return *this
6124 
6137  {
6138  TRANSFER_BODY();
6139  }
6140 
6153  {
6154  TRANSFER_BODY();
6155  }
6156 
6157 #undef TRANSFER_BODY
6158 
6164  ImageVariant& operator =( ImageVariant&& image )
6165  {
6166  return Transfer( image );
6167  }
6168 
6177  void ReleaseTo( ImageVariant& image )
6178  {
6179  if ( &image != this ) // N.B.: Self-release incompatible with server-side SharedImage.
6180  {
6181  Data* newData = new Data;
6182  image.DetachFromData();
6183  image.m_data = m_data;
6184  m_data = newData;
6185  }
6186  }
6187 
6196  template <class P>
6198  {
6199  if ( &image != m_data->image )
6200  {
6201  Free();
6202  m_data->Update( &image );
6203  }
6204  return *this;
6205  }
6206 
6210  friend void Swap( ImageVariant& x1, ImageVariant& x2 ) noexcept
6211  {
6212  pcl::Swap( x1.m_data, x2.m_data );
6213  }
6214 
6239  ImageVariant& CreateImage( bool isFloat, bool isComplex, int bitSize )
6240  {
6241  if ( isFloat )
6242  {
6243  if ( isComplex )
6244  CreateComplexImage( bitSize );
6245  else
6246  CreateFloatImage( bitSize );
6247  }
6248  else
6249  {
6250  if ( !isComplex )
6251  CreateUIntImage( bitSize );
6252  /*
6253  else
6254  {
6255  ### Yeah this is true, but everybody already knows so we don't want
6256  to replicate this useless message everywhere!
6257  throw Error( "Integer-valued complex images not supported by this PCL version." );
6258  }
6259  */
6260  }
6261 
6262  return *this;
6263  }
6264 
6265 #define CREATE_IMAGE( I ) m_data->Update( new pcl::I )
6266 
6279  ImageVariant& CreateFloatImage( int bitSize = 32 )
6280  {
6281  PCL_PRECONDITION( bitSize == 32 || bitSize == 64 )
6282  Free();
6283  switch ( bitSize )
6284  {
6285  case 32: CREATE_IMAGE( Image ); break;
6286  case 64: CREATE_IMAGE( DImage ); break;
6287  }
6288  m_data->ownsImage = m_data->image != nullptr;
6289  return *this;
6290  }
6291 
6301  {
6302  return CreateFloatImage();
6303  }
6304 
6316  ImageVariant& CreateComplexImage( int bitSize = 32 )
6317  {
6318  PCL_PRECONDITION( bitSize == 32 || bitSize == 64 )
6319  Free();
6320  switch ( bitSize )
6321  {
6322  case 32: CREATE_IMAGE( ComplexImage ); break;
6323  case 64: CREATE_IMAGE( DComplexImage ); break;
6324  }
6325  m_data->ownsImage = m_data->image != nullptr;
6326  return *this;
6327  }
6328 
6340  ImageVariant& CreateUIntImage( int bitSize = 16 )
6341  {
6342  PCL_PRECONDITION( bitSize == 8 || bitSize == 16 || bitSize == 32 )
6343  Free();
6344  switch ( bitSize )
6345  {
6346  case 8: CREATE_IMAGE( UInt8Image ); break;
6347  case 16: CREATE_IMAGE( UInt16Image ); break;
6348  case 32: CREATE_IMAGE( UInt32Image ); break;
6349  }
6350  m_data->ownsImage = m_data->image != nullptr;
6351  return *this;
6352  }
6353 
6354 #undef CREATE_IMAGE
6355 
6369  template <class P>
6371  {
6372  return CreateImage( P::IsFloatSample(), P::IsComplexSample(), P::BitsPerSample() );
6373  }
6374 
6389  {
6390  return CreateImage( image.IsFloatSample(), image.IsComplexSample(), image.BitsPerSample() );
6391  }
6392 
6393 #ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
6394 
6428  ImageVariant& CreateSharedImage( bool isFloat, bool isComplex, int bitSize )
6429  {
6430  if ( isFloat )
6431  {
6432  if ( isComplex )
6433  CreateSharedComplexImage( bitSize );
6434  else
6435  CreateSharedFloatImage( bitSize );
6436  }
6437  else
6438  {
6439  if ( !isComplex )
6440  CreateSharedUIntImage( bitSize );
6441  }
6442 
6443  return *this;
6444  }
6445 
6446 #define CREATE_SHARED_IMAGE( I ) m_data->Update( new pcl::I( (void*)0, 0, 0 ) )
6447 
6463  {
6464  PCL_PRECONDITION( bitSize == 32 || bitSize == 64 )
6465  Free();
6466  switch ( bitSize )
6467  {
6468  case 32: CREATE_SHARED_IMAGE( Image ); break;
6469  case 64: CREATE_SHARED_IMAGE( DImage ); break;
6470  }
6471  m_data->ownsImage = m_data->image != nullptr;
6472  return *this;
6473  }
6474 
6487  {
6488  return CreateSharedFloatImage();
6489  }
6490 
6506  {
6507  PCL_PRECONDITION( bitSize == 32 || bitSize == 64 )
6508  Free();
6509  switch ( bitSize )
6510  {
6511  case 32: CREATE_SHARED_IMAGE( ComplexImage ); break;
6512  case 64: CREATE_SHARED_IMAGE( DComplexImage ); break;
6513  }
6514  m_data->ownsImage = m_data->image != nullptr;
6515  return *this;
6516  }
6517 
6533  {
6534  PCL_PRECONDITION( bitSize == 8 || bitSize == 16 || bitSize == 32 )
6535  Free();
6536  switch ( bitSize )
6537  {
6538  case 8: CREATE_SHARED_IMAGE( UInt8Image ); break;
6539  case 16: CREATE_SHARED_IMAGE( UInt16Image ); break;
6540  case 32: CREATE_SHARED_IMAGE( UInt32Image ); break;
6541  }
6542  m_data->ownsImage = m_data->image != nullptr;
6543  return *this;
6544  }
6545 
6546 #undef CREATE_SHARED_IMAGE
6547 
6564  template <class P>
6566  {
6567  return CreateSharedImage( P::IsFloatSample(), P::IsComplexSample(), P::BitsPerSample() );
6568  }
6569 
6587  {
6588  return CreateSharedImage( image.IsFloatSample(), image.IsComplexSample(), image.BitsPerSample() );
6589  }
6590 
6591 #endif // !__PCL_BUILDING_PIXINSIGHT_APPLICATION
6592 
6593 #define ALLOCATE_IMAGE( I ) \
6594  static_cast<pcl::I&>( **this ).AllocateData( width, height, numberOfChannels, colorSpace )
6595 
6620  ImageVariant& AllocateImage( int width, int height, int numberOfChannels, color_space colorSpace )
6621  {
6622  if ( !*this )
6623  CreateImage();
6624  SOLVE_TEMPLATE( ALLOCATE_IMAGE )
6625  return *this;
6626  }
6627 
6628 #undef ALLOCATE_IMAGE
6629 
6630 #define COPY_IMAGE( I ) static_cast<pcl::I&>( **this ).Assign( image )
6631 
6648  template <class P>
6650  {
6651  if ( !*this )
6652  CreateImageAs( image );
6653  SOLVE_TEMPLATE( COPY_IMAGE )
6654  return *this;
6655  }
6656 
6657 #undef COPY_IMAGE
6658 
6659 #define COPY_IMAGE( I ) CopyImage( static_cast<const pcl::I&>( *image ) )
6660 
6673  {
6674  if ( image )
6675  SOLVE_TEMPLATE_2( image, COPY_IMAGE )
6676  else
6677  FreeImage();
6678  return *this;
6679  }
6680 
6681 #undef COPY_IMAGE
6682 
6683 #define FREE_IMAGE( I ) static_cast<pcl::I&>( **this ).FreeData()
6684 
6701  {
6702  if ( *this )
6703  SOLVE_TEMPLATE( FREE_IMAGE )
6704  return *this;
6705  }
6706 
6713  static Compression* NewCompression( swap_compression algorithm, int itemSize = 1 );
6714 
6715 #undef FREE_IMAGE
6716 
6746  void WriteSwapFile( const String& filePath,
6747  swap_compression compression = SwapCompression::None,
6748  Compression::Performance* perf = nullptr,
6749  bool processEvents = false ) const;
6750 
6795  void WriteSwapFiles( const String& fileName, const StringList& directories,
6796  swap_compression compression = SwapCompression::None,
6797  Compression::Performance* perf = nullptr,
6798  bool processEvents = false ) const;
6827  void ReadSwapFile( const String& filePath,
6828  Compression::Performance* perf = nullptr,
6829  bool processEvents = false );
6830 
6866  void ReadSwapFiles( const String& fileName, const StringList& directories,
6867  Compression::Performance* perf = nullptr,
6868  bool processEvents = false );
6869 
6905  void MaskFromSwapFile( const String& filePath, const ImageVariant& mask, bool invert = false,
6906  bool processEvents = false );
6907 
6941  void MaskFromSwapFiles( const String& fileName, const StringList& directories,
6942  const ImageVariant& mask, bool invert = false,
6943  bool processEvents = false );
6944 
6949  static void DeleteSwapFile( const String& filePath );
6950 
6959  static void DeleteSwapFiles( const String& fileName, const StringList& directories );
6960 
6970  static uint64 SwapFileSize( const String& filePath );
6971 
6984  static uint64 SwapFilesSize( const String& fileName, const StringList& directories );
6985 
7014  void MaskImage( const ImageVariant& src, const ImageVariant& mask, bool invert = false );
7015 
7020  bool OwnsImage() const noexcept
7021  {
7022  return m_data->ownsImage;
7023  }
7024 
7035  ImageVariant& SetOwnership( bool owner = true ) noexcept
7036  {
7037  m_data->ownsImage = owner && m_data->image;
7038  return *this;
7039  }
7040 
7049  {
7050  if ( m_data->IsUnique() )
7051  m_data->Free();
7052  else
7053  {
7054  Data* newData = new Data;
7055  DetachFromData();
7056  m_data = newData;
7057  }
7058  return *this;
7059  }
7060 
7068  const AbstractImage* operator ->() const noexcept
7069  {
7070  PCL_PRECONDITION( m_data->image != nullptr )
7071  return m_data->image;
7072  }
7073 
7081  AbstractImage* operator ->() noexcept
7082  {
7083  PCL_PRECONDITION( m_data->image != nullptr )
7084  return m_data->image;
7085  }
7086 
7094  const AbstractImage& operator *() const noexcept
7095  {
7096  PCL_PRECONDITION( m_data->image != nullptr )
7097  return *m_data->image;
7098  }
7099 
7108  {
7109  PCL_PRECONDITION( m_data->image != nullptr )
7110  return *m_data->image;
7111  }
7112 
7116  operator bool() const noexcept
7117  {
7118  return m_data->image != nullptr;
7119  }
7120 
7121 #define __PIXEL_ACCESS_OPERATOR( I ) \
7122  pcl::I::pixel_traits::FromSample( result, *static_cast<const pcl::I&>( **this ).PixelAddress( x, y, channel ) )
7123 
7149  double operator ()( int x, int y, int channel = 0 ) const noexcept
7150  {
7151  double result = 0;
7152  if ( *this )
7153  SOLVE_TEMPLATE( __PIXEL_ACCESS_OPERATOR )
7154  return result;
7155  }
7156 
7157 #undef __PIXEL_ACCESS_OPERATOR
7158 
7159 #ifdef __PCL_BUILDING_PIXINSIGHT_APPLICATION
7160 
7161  bool IsShared() const noexcept
7162  {
7163  return m_shared != nullptr;
7164  }
7165 
7166  const pi::SharedImage* SharedImage() const
7167  {
7168  return m_shared;
7169  }
7170 
7171  // Implemented in SharedImage.cpp
7172  pi::SharedImage* GetSharedImage( bool rdOnly = false ) const;
7173  pi::SharedImage* NewSharedImage( void* owner, bool rdOnly = false );
7174 
7175 #endif
7176 
7177 private:
7178 
7179  struct Data : public ReferenceCounter
7180  {
7181  AbstractImage* image = nullptr;
7182  bool isFloatSample = false;
7183  bool isComplexSample = false;
7184  uint8 bitsPerSample = 0;
7185  bool ownsImage = false;
7186 
7187  Data() = default;
7188 
7189  ~Data()
7190  {
7191  Free();
7192  }
7193 
7194  template <class P>
7195  void Update( GenericImage<P>* a_image ) noexcept
7196  {
7197  image = a_image;
7198  isFloatSample = P::IsFloatSample();
7199  isComplexSample = P::IsComplexSample();
7200  bitsPerSample = uint8( P::BitsPerSample() );
7201  }
7202 
7203  void Free()
7204  {
7205  if ( ownsImage )
7206  delete image;
7207  image = nullptr;
7208  isFloatSample = isComplexSample = false;
7209  bitsPerSample = 0;
7210  //ownsImage = ownsImage; ### N.B.: Ownership must *not* change here
7211  }
7212  };
7213 
7214  Data* m_data = nullptr;
7215 
7216 #ifdef __PCL_BUILDING_PIXINSIGHT_APPLICATION
7217  // This is the server-side part of the image sharing mechanism
7218  pi::SharedImage* m_shared = nullptr;
7219 #else
7220  const void* m_shared = nullptr;
7221 #endif
7222 
7223  void DetachFromData()
7224  {
7225  if ( !m_data->Detach() )
7226  delete m_data;
7227  }
7228 
7229 #ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
7230  // Server-side private ctor. used by View
7231  template <class P>
7232  ImageVariant( GenericImage<P>* image, int )
7233  {
7234  m_data = new Data;
7235  m_data->Update( image );
7236  m_data->ownsImage = true;
7237  }
7238 #endif
7239 
7240 #ifdef __PCL_BUILDING_PIXINSIGHT_APPLICATION
7241  friend class pi::SharedImage;
7242 #else
7243  friend class View;
7244  friend class ImageView;
7245 #endif
7246 };
7247 
7248 // ----------------------------------------------------------------------------
7249 
7250 /*
7251  * Implementation of member functions of GenericImage requiring a full
7252  * declaration of ImageVariant.
7253  */
7254 
7255 template <class P> inline
7256 void GenericImage<P>::GetLuminance( ImageVariant& Y, const Rect& rect, int maxProcessors ) const
7257 {
7258  ImageVariant( const_cast<GenericImage<P>*>( this ) ).GetLuminance( Y, rect, maxProcessors );
7259 }
7260 
7261 template <class P> inline
7262 void GenericImage<P>::GetLightness( ImageVariant& L, const Rect& rect, int maxProcessors ) const
7263 {
7264  ImageVariant( const_cast<GenericImage<P>*>( this ) ).GetLightness( L, rect, maxProcessors );
7265 }
7266 
7267 template <class P> inline
7268 void GenericImage<P>::GetIntensity( ImageVariant& I, const Rect& rect, int maxProcessors ) const
7269 {
7270  ImageVariant( const_cast<GenericImage<P>*>( this ) ).GetIntensity( I, rect, maxProcessors );
7271 }
7272 
7273 template <class P> inline
7274 GenericImage<P>& GenericImage<P>::SetLuminance( const ImageVariant& Y, const Point& point, const Rect& rect, int maxProcessors )
7275 {
7276  (void)ImageVariant( this ).SetLuminance( Y, point, rect, maxProcessors );
7277  return *this;
7278 }
7279 
7280 template <class P> inline
7281 GenericImage<P>& GenericImage<P>::SetLightness( const ImageVariant& L, const Point& point, const Rect& rect, int maxProcessors )
7282 {
7283  (void)ImageVariant( this ).SetLightness( L, point, rect, maxProcessors );
7284  return *this;
7285 }
7286 
7287 // ----------------------------------------------------------------------------
7288 
7289 } // pcl
7290 
7291 #endif // __PCL_ImageVariant_h
7292 
7293 // ----------------------------------------------------------------------------
7294 // EOF pcl/ImageVariant.h - Released 2024-06-18T15:48:54Z
Base class of all two-dimensional images in PCL.
ImageColor::color_space color_space
Generic dynamic array.
Definition: Array.h:100
Root base class for bidirectional PCL image transformations.
Client-side interface to a PixInsight Bitmap object.
Definition: Bitmap.h:204
Abstract base class of data compression algorithm implementations.
Definition: Compression.h:84
Array< Subblock > subblock_list
Definition: Compression.h:112
A platform-independent interface to the local file system.
Definition: File.h:344
Implements a generic, two-dimensional, shared or local image.
Definition: Image.h:278
void GetIntensity(GenericImage< P1 > &I, const Rect &rect=Rect(0), int maxProcessors=0) const
Definition: Image.h:14673
void GetLightness(GenericImage< P1 > &L, const Rect &rect=Rect(0), int maxProcessors=0) const
Definition: Image.h:14550
GenericImage & SetLightness(const GenericImage< P1 > &L, const Point &point=Point(int_max), const Rect &rect=Rect(0), int maxProcessors=0)
Definition: Image.h:14940
void GetLuminance(GenericImage< P1 > &Y, const Rect &rect=Rect(0), int maxProcessors=0) const
Definition: Image.h:14418
GenericImage & SetLuminance(const GenericImage< P1 > &Y, const Point &point=Point(int_max), const Rect &rect=Rect(0), int maxProcessors=0)
Definition: Image.h:14799
A generic point in the two-dimensional space.
Definition: Point.h:100
A generic rectangle in the two-dimensional space.
Definition: Rectangle.h:314
Generic vector of arbitrary length.
Definition: Vector.h:107
Root base class of all PCL image transformations.
Acts like a union for all types of images in PCL, with optional class-wide ownership of transported i...
Definition: ImageVariant.h:322
ImageVariant & Shift()
void MaskFromSwapFiles(const String &fileName, const StringList &directories, const ImageVariant &mask, bool invert=false, bool processEvents=false)
ImageVariant & CropTo(int x0, int y0, int x1, int y1, const GenericVector< T > &fillValues)
ImageVariant & Read(const String &filePath)
size_type NumberOfSamples() const noexcept
Definition: ImageVariant.h:577
void PopSelections() const
ImageVariant & Blend(const Bitmap &bitmap, const Point &point=Point(int_max), const Rect &rect=Rect(0))
ImageVariant & Dif(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
bool HasAlphaChannels() const noexcept
Definition: ImageVariant.h:553
ImageVariant(const ImageVariant &image)
Definition: ImageVariant.h:378
void GetRow(T *buffer, int y, int channel=-1) const
ImageVariant & EnsureLocalImage()
void PushSelections() const
int NumberOfNominalChannels() const noexcept
Definition: ImageVariant.h:540
ImageVariant & Divide(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
ImageVariant Filled(const GenericVector< T > &values, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1) const
double BendMidvariance(double center, double beta=0.2, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1, int maxProcessors=0) const
ImageVariant & CreateSharedUIntImage(int bitSize=16)
ImageVariant & Fill(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
ImageVariant & AllocateData(const Rect &rect, int numberOfChannels=1, color_space colorSpace=ColorSpace::Gray)
ImageVariant & Xnor(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
ImageVariant & SetOwnership(bool owner=true) noexcept
ImageVariant & SetMinimum(const ImageVariant &image, const Point &point=Point(int_max), int channel=-1, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
ImageVariant & Divide(const ImageVariant &image, const Point &point=Point(int_max), int channel=-1, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
Compression::subblock_list Compress(const Compression &compressor, const Rect &rect=Rect(0), int channel=-1, Compression::Performance *perf=nullptr) const
void SelectChannel(int c) const noexcept
Definition: ImageVariant.h:777
bool IsFullSelection() const noexcept
Definition: ImageVariant.h:989
void DisableParallelProcessing(bool disable=true) noexcept
ImageVariant & White(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
ImageVariant & Mul(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
void GetSelectedChannelRange(int &c0, int &c1) const noexcept
Definition: ImageVariant.h:877
ImageVariant & Raise(const ImageVariant &image, const Point &point=Point(int_max), int channel=-1, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
double StdDev(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1, int maxProcessors=0) const
ImageVariant & Add(const ImageVariant &image, const Point &point=Point(int_max), int channel=-1, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
Point SelectedPoint() const noexcept
Definition: ImageVariant.h:917
void MaskImage(const ImageVariant &src, const ImageVariant &mask, bool invert=false)
double Variance(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1, int maxProcessors=0) const
void MaskFromSwapFile(const String &filePath, const ImageVariant &mask, bool invert=false, bool processEvents=false)
ImageVariant & Shift(const GenericVector< T > &fillValues)
ImageVariant & AllocateData(int width, int height, int numberOfChannels=1, color_space colorSpace=ColorSpace::Gray)
double Qn(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1, int maxProcessors=0) const
ImageVariant Filled(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1) const
void LocateExtremeSampleValues(Point &pmin, T &min, Point &pmax, T &max, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1, int maxProcessors=0) const
ImageVariant & Xchg(ImageVariant &image, const Point &point=Point(int_max), int channel=-1, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
const AbstractImage * ImagePtr() const noexcept
Definition: ImageVariant.h:412
ImageVariant Inverted(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1) const
ImageVariant & Write(const String &filePath, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1) const
double MAD(double center, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1, int maxProcessors=0) const
bool CanPopSelections() const noexcept
void SetRangeClipping(double clipLow, double clipHigh) const noexcept
ImageVariant & CreateSharedFloatImage(int bitSize=32)
bool IsEmptySelection() const noexcept
Definition: ImageVariant.h:979
ImageVariant & Rescale(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
ImageVariant & Div(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
ImageVariant & ShiftToTopLeft(int width, int height, const GenericVector< T > &fillValues)
Rect Bounds() const noexcept
Definition: ImageVariant.h:616
ImageVariant & One(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
ImageVariant & ShiftToTopRight(int width, int height, const GenericVector< T > &fillValues)
ImageVariant & Assign(const ImageVariant &image)
ImageVariant & Move(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
ImageVariant Divided(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1) const
ImageVariant & CreateSharedImage()
ImageVariant Applied(T scalar, image_op op=ImageOp::Mov, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1) const
ImageVariant & And(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
ImageVariant Minimum(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1) const
bool OwnsImage() const noexcept
double SumOfSquares(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1, int maxProcessors=0) const
bool Clip(pcl::GenericRectangle< T > &r) const noexcept
Definition: ImageVariant.h:744
ImageVariant & CreateImage()
ImageVariant & Move(const ImageVariant &image, const Point &point=Point(int_max), int channel=-1, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
void ResetRangeClipping() const noexcept
ImageVariant(ImageVariant &&image)
Definition: ImageVariant.h:387
ImageVariant Applied(const ImageVariant &image, image_op op=ImageOp::Mov, const Point &point=Point(int_max), int channel=-1, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1) const
ImageVariant Rescaled(T lowerBound, T upperBound, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1) const
ImageVariant & Nor(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
ImageVariant Raised(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1) const
ImageVariant & CropTo(int x0, int y0, int x1, int y1)
size_type ImageSize() const noexcept
ImageVariant & Crop(const GenericVector< T > &fillValues)
TwoSidedEstimate TwoSidedMAD(double center, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1, int maxProcessors=0) const
static uint64 SwapFilesSize(const String &fileName, const StringList &directories)
ImageVariant(GenericImage< P > *image)
Definition: ImageVariant.h:363
int LastChannel() const noexcept
Definition: ImageVariant.h:517
ImageVariant & TransferImage(ImageVariant &image)
void SetMaxProcessors(int maxProcessors) noexcept
Rect SelectedRectangle() const noexcept
Definition: ImageVariant.h:998
void EnableRangeClipping(bool enableLow=true, bool enableHigh=true) const noexcept
ImageVariant & Write(File &file, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1) const
void WriteSwapFile(const String &filePath, swap_compression compression=SwapCompression::None, Compression::Performance *perf=nullptr, bool processEvents=false) const
uint64 Count(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1, int maxProcessors=0) const
ImageVariant & SetAbsoluteValue(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
void SelectChannelRange(int c0, int c1) const noexcept
Definition: ImageVariant.h:804
ImageVariant & Multiply(const ImageVariant &image, const Point &point=Point(int_max), int channel=-1, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
void SetRGBWorkingSpace(const RGBColorSystem &rgbws)
ImageVariant & SetLightness(const ImageVariant &L, const Point &point=Point(int_max), const Rect &rect=Rect(0), int maxProcessors=0)
double LocateMaximumSampleValue(Point &pmax, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1, int maxProcessors=0) const
void SetRangeClipHigh(double clipHigh) const noexcept
int Width() const noexcept
Definition: ImageVariant.h:476
size_type NumberOfNominalSamples() const noexcept
Definition: ImageVariant.h:589
bool IsSharedImage() const noexcept
ImageVariant & CreateImageAs(const pcl::GenericImage< P > &image)
void ReleaseTo(ImageVariant &image)
ImageVariant & Not(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
ImageVariant & Transfer(ImageVariant &image)
int LastSelectedChannel() const noexcept
Definition: ImageVariant.h:865
size_type LineSize() const noexcept
static void DeleteSwapFiles(const String &fileName, const StringList &directories)
ImageVariant & SetMaximum(const ImageVariant &image, const Point &point=Point(int_max), int channel=-1, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
ImageVariant & ShiftTo(const Point &p, const GenericVector< T > &fillValues)
double BiweightMidvariance(double center, double sigma, int k=9, bool reducedLength=false, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1, int maxProcessors=0) const
AbstractImage * ImagePtr() noexcept
Definition: ImageVariant.h:420
ImageVariant & Invert(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
ImageVariant & Sub(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
size_type NumberOfAlphaSamples() const noexcept
Definition: ImageVariant.h:601
ImageVariant & CropTo(const Rect &rect)
ImageVariant & Zero(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
int SelectedChannel() const noexcept
Definition: ImageVariant.h:792
ImageVariant & CropTo(const Rect &rect, const GenericVector< T > &fillValues)
ImageVariant Applied(const ImageTransformation &transformation, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1) const
double Norm(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1, int maxProcessors=0) const
bool IsHighRangeClippingEnabled() const noexcept
ImageVariant Truncated(T lowerBound, T upperBound, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1) const
ImageVariant & ShiftToCenter(int width, int height)
ImageVariant & CropBy(int left, int top, int right, int bottom, const GenericVector< T > &fillValues)
double LocateMinimumSampleValue(int &xmin, int &ymin, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1, int maxProcessors=0) const
ImageVariant & Max(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
bool Includes(const GenericRectangle< T > &r) const noexcept
Definition: ImageVariant.h:640
bool IsFloatSample() const noexcept
Definition: ImageVariant.h:441
ImageVariant AbsoluteValue(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1) const
ImageVariant & AllocateImage(int width, int height, int numberOfChannels, color_space colorSpace)
ImageVariant & ShiftToBottomRight(int width, int height, const GenericVector< T > &fillValues)
size_type NumberOfPixels() const noexcept
Definition: ImageVariant.h:496
ImageVariant & Truncate(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
bool Intersects(T x0, T y0, T x1, T y1) const noexcept
Definition: ImageVariant.h:697
void * SharedImageHandle() const noexcept
double LocateMaximumSampleValue(int &xmax, int &ymax, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1, int maxProcessors=0) const
void ForgetAlphaChannel(int channel)
ImageVariant Binarized(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1) const
const RGBColorSystem & RGBWorkingSpace() const noexcept
ImageVariant & Nand(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
bool Clip(T &x, T &y) const noexcept
Definition: ImageVariant.h:728
void DeleteAlphaChannel(int channel)
double MaximumSampleValue(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1, int maxProcessors=0) const
ImageVariant & Invert(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
void WriteSwapFiles(const String &fileName, const StringList &directories, swap_compression compression=SwapCompression::None, Compression::Performance *perf=nullptr, bool processEvents=false) const
ImageVariant & CreateImageAs(const ImageVariant &image)
ImageVariant & Xnor(const ImageVariant &image, const Point &point=Point(int_max), int channel=-1, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
ImageVariant & SetImage(GenericImage< P > &image)
ImageVariant Multiplied(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1) const
bool IsComplexSample() const noexcept
Definition: ImageVariant.h:449
ImageVariant & SetMaximum(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
ImageVariant & CreateSharedComplexImage(int bitSize=32)
void ResetPoint() const noexcept
Definition: ImageVariant.h:907
ImageVariant & Xor(const ImageVariant &image, const Point &point=Point(int_max), int channel=-1, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
ImageVariant & Black(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
TwoSidedEstimate TwoSidedBiweightMidvariance(double center, const TwoSidedEstimate &sigma, int k=9, bool reducedLength=false, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1, int maxProcessors=0) const
bool IsUniqueImage() const noexcept
static uint64 SwapFileSize(const String &filePath)
void ResetChannelRange() const noexcept
Definition: ImageVariant.h:837
void DisableRangeClipping(bool disableLow=true, bool disableHigh=true) const noexcept
double MinimumSampleValue(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1, int maxProcessors=0) const
ImageVariant & Pow(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
ImageVariant Subtracted(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1) const
ImageVariant Added(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1) const
bool IsColor() const noexcept
ImageVariant & AssignImage(const ImageVariant &image, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
void SelectAlphaChannels() const noexcept
Definition: ImageVariant.h:827
ImageVariant & CreateSharedImageAs(const ImageVariant &image)
void GetColumn(T *buffer, int x, int channel=-1) const
ImageVariant & Read(File &file)
void ReadSwapFiles(const String &fileName, const StringList &directories, Compression::Performance *perf=nullptr, bool processEvents=false)
ImageVariant & ShiftTo(int x, int y, const GenericVector< T > &fillValues)
void ResetSelections() const noexcept
ImageVariant & ShiftToBottomLeft(int width, int height)
ImageVariant & Max(const ImageVariant &image, const Point &point=Point(int_max), int channel=-1, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
void SelectRectangle(int x0, int y0, int x1, int y1) const noexcept
Definition: ImageVariant.h:935
int NumberOfSelectedChannels() const noexcept
Definition: ImageVariant.h:847
ImageVariant & SetColumn(const T *buffer, int x, int channel=-1)
bool IsCompletelySelected() const noexcept
size_type ChannelSize() const noexcept
int NumberOfChannels() const noexcept
Definition: ImageVariant.h:505
ImageVariant Blended(const Bitmap &bitmap, const Point &point=Point(int_max), const Rect &rect=Rect(0)) const
bool Includes(T x, T y) const noexcept
Definition: ImageVariant.h:670
String ChannelId(int c) const noexcept
ImageVariant & Free()
int BytesPerSample() const noexcept
Definition: ImageVariant.h:467
void DeleteAlphaChannels()
bool Clip(pcl::GenericPoint< T > &p) const noexcept
Definition: ImageVariant.h:710
ImageVariant & Binarize(T threshold, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
ImageVariant & Mul(const ImageVariant &image, const Point &point=Point(int_max), int channel=-1, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
ImageVariant & Nor(const ImageVariant &image, const Point &point=Point(int_max), int channel=-1, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
static Compression * NewCompression(swap_compression algorithm, int itemSize=1)
void ReadSwapFile(const String &filePath, Compression::Performance *perf=nullptr, bool processEvents=false)
ImageVariant & Crop()
double RangeClipHigh() const noexcept
int Height() const noexcept
Definition: ImageVariant.h:485
ImageVariant & Exchange(ImageVariant &image, const Point &point=Point(int_max), int channel=-1, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
bool IsParallelProcessingEnabled() const noexcept
void CreateAlphaChannels(int n)
ImageVariant & CopyImage(const ImageVariant &image)
int BitsPerSample() const noexcept
Definition: ImageVariant.h:458
color_space ColorSpace() const noexcept
ImageVariant & Rescale(T lowerBound, T upperBound, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
ImageVariant & Truncate(T lowerBound, T upperBound, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
size_type NumberOfSelectedPixels() const noexcept
ImageVariant Normalized(T lowerBound, T upperBound, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1) const
double Modulus(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1, int maxProcessors=0) const
static void DeleteSwapFile(const String &filePath)
ImageVariant & Normalize(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
ImageVariant & CreateSharedImage(bool isFloat, bool isComplex, int bitSize)
ImageVariant & SetAbsoluteDifference(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
bool IsValidChannelIndex(int c) const noexcept
Definition: ImageVariant.h:527
ImageVariant & FreeImage()
ImageVariant & Subtract(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
void SelectPoint(int x, int y) const noexcept
Definition: ImageVariant.h:889
ImageVariant & ShiftToTopRight(int width, int height)
ImageVariant & SetAbsoluteDifference(const ImageVariant &image, const Point &point=Point(int_max), int channel=-1, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
ImageVariant & Pow(const ImageVariant &image, const Point &point=Point(int_max), int channel=-1, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
void GetIntensity(ImageVariant &Y, const Rect &rect=Rect(0), int maxProcessors=0) const
ImageVariant & ShiftToTopLeft(int width, int height)
size_type NominalSize() const noexcept
size_type AlphaSize() const noexcept
Vector Norms(int maxDegree, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1, int maxProcessors=0) const
ImageVariant & Apply(const ImageTransformation &transformation, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
void SetRangeClipLow(double clipLow) const noexcept
ImageVariant & ShiftToBottomRight(int width, int height)
ImageSelections & Selections() const noexcept
ImageVariant & Add(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
void GetLuminance(ImageVariant &Y, const Rect &rect=Rect(0), int maxProcessors=0) const
double Mean(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1, int maxProcessors=0) const
bool Includes(const GenericPoint< T > &p) const noexcept
Definition: ImageVariant.h:628
double Sn(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1, int maxProcessors=0) const
ImageVariant & SetRow(const T *buffer, int y, int channel=-1)
ImageVariant & Binarize(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
ImageVariant Truncated(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1) const
ImageVariant & CreateSharedImageAs(const pcl::GenericImage< P > &image)
ImageVariant & Subtract(const ImageVariant &image, const Point &point=Point(int_max), int channel=-1, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
ImageVariant & Xor(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
ImageVariant & SetMinimum(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
void SelectNominalChannels() const noexcept
Definition: ImageVariant.h:814
void GetExtremeSampleValues(T &min, T &max, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1, int maxProcessors=0) const
ImageVariant & CreateComplexImage(int bitSize=32)
ImageVariant & CreateUIntImage(int bitSize=16)
ImageVariant & Transfer(ImageVariant &&image)
ImageVariant & ShiftBy(int dx, int dy, const GenericVector< T > &fillValues)
void SetStatusCallback(pcl::StatusCallback *callback) const noexcept
void EnableParallelProcessing(bool enable=true, int maxProcessors=0) noexcept
ImageVariant & SetColorSpace(color_space colorSpace, int maxProcessors=0)
ImageVariant & Raise(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
ImageVariant & Min(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
bool Intersects(const pcl::GenericRectangle< T > &r) const noexcept
Definition: ImageVariant.h:682
ImageVariant Binarized(T threshold, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1) const
double MeanOfSquares(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1, int maxProcessors=0) const
ImageVariant & ShiftTo(const Point &p)
double OrderStatistic(double k, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1, int maxProcessors=0) const
ImageVariant Maximum(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1) const
ImageVariant & Apply(T scalar, image_op op=ImageOp::Mov, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
bool IsLowRangeClippingEnabled() const noexcept
ImageVariant & Sub(const ImageVariant &image, const Point &point=Point(int_max), int channel=-1, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
ImageVariant & Apply(const ImageVariant &image, image_op op=ImageOp::Mov, const Point &point=Point(int_max), int channel=-1, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
ImageVariant & CreateImage(bool isFloat, bool isComplex, int bitSize)
int MaxProcessors() const noexcept
ImageVariant & CropBy(int left, int top, int right, int bottom)
ImageVariant & CreateFloatImage(int bitSize=32)
bool Clip(T &x0, T &y0, T &x1, T &y1) const noexcept
Definition: ImageVariant.h:766
int NumberOfAlphaChannels() const noexcept
Definition: ImageVariant.h:566
bool Includes(T x0, T y0, T x1, T y1) const noexcept
Definition: ImageVariant.h:655
double AvgDev(double center, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1, int maxProcessors=0) const
virtual ~ImageVariant()
Definition: ImageVariant.h:399
TwoSidedEstimate TwoSidedAvgDev(double center, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1, int maxProcessors=0) const
void ResetSelection() const noexcept
Definition: ImageVariant.h:968
double Median(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1, int maxProcessors=0) const
void Transform(BidirectionalImageTransformation &transform, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1) const
ImageVariant & Div(const ImageVariant &image, const Point &point=Point(int_max), int channel=-1, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
ImageVariant & ShiftBy(int dx, int dy)
ImageVariant & Nand(const ImageVariant &image, const Point &point=Point(int_max), int channel=-1, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
ImageVariant & ShiftTo(int x, int y)
ImageVariant Inverted(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1) const
ImageVariant & Normalize(T lowerBound, T upperBound, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
ImageVariant AbsoluteDifference(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1) const
void GetLightness(ImageVariant &L, const Rect &rect=Rect(0), int maxProcessors=0) const
bool IsRangeClippingEnabled() const noexcept
bool IsAs(const pcl::GenericImage< P > &) const
ImageVariant Rescaled(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1) const
ImageVariant & Min(const ImageVariant &image, const Point &point=Point(int_max), int channel=-1, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
ImageVariant & CopyImage(const GenericImage< P > &image)
double RangeClipLow() const noexcept
StatusMonitor & Status() const noexcept
pcl::StatusCallback * StatusCallback() const noexcept
ImageVariant & EnsureUniqueImage()
void SelectRectangle(const Point &p0, const Point &p1) const noexcept
Definition: ImageVariant.h:949
ImageVariant & And(const ImageVariant &image, const Point &point=Point(int_max), int channel=-1, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
friend void Swap(ImageVariant &x1, ImageVariant &x2) noexcept
void LocateExtremeSampleValues(int &xmin, int &ymin, T &min, int &xmax, int &ymax, T &max, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1, int maxProcessors=0) const
ImageVariant & Or(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
ImageVariant & Mov(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
ImageVariant & ShiftToBottomLeft(int width, int height, const GenericVector< T > &fillValues)
double LocateMinimumSampleValue(Point &pmin, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1, int maxProcessors=0) const
ImageVariant & Multiply(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
int FirstSelectedChannel() const noexcept
Definition: ImageVariant.h:856
ImageVariant & Fill(const GenericVector< T > &values, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
size_type NumberOfSelectedSamples() const noexcept
ImageVariant & Or(const ImageVariant &image, const Point &point=Point(int_max), int channel=-1, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
bool IsSameImage(const ImageVariant &image) const noexcept
Definition: ImageVariant.h:432
ImageVariant & ShiftToCenter(int width, int height, const GenericVector< T > &fillValues)
ImageVariant & SetLuminance(const ImageVariant &Y, const Point &point=Point(int_max), const Rect &rect=Rect(0), int maxProcessors=0)
void ForgetAlphaChannels()
void SelectPoint(const Point &p) const noexcept
Definition: ImageVariant.h:898
void SelectRectangle(const Rect &r) const noexcept
Definition: ImageVariant.h:959
ImageVariant Normalized(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1) const
Colorimetrically defined RGB working color space.
Provides status monitoring callback functions.
Definition: StatusMonitor.h:98
An asynchronous status monitoring system.
Unicode (UTF-16) string.
Definition: String.h:8113
Complex< T1 > operator*(const Complex< T1 > &c1, const Complex< T2 > &c2) noexcept
Definition: Complex.h:548
T Abs(const Complex< T > &c) noexcept
Definition: Complex.h:429
void Swap(GenericPoint< T > &p1, GenericPoint< T > &p2) noexcept
Definition: Point.h:1459
unsigned long long uint64
Definition: Defs.h:682
unsigned char uint8
Definition: Defs.h:642
size_t size_type
Definition: Defs.h:609
void Apply(FI i, FI j, F f) noexcept(noexcept(f))
Definition: Utility.h:249
int NumberOfNominalChannels(int colorSpace)
Definition: ColorSpace.h:102
PCL root namespace.
Definition: AbstractImage.h:77
Compression/decompression performance measurements.
Definition: Compression.h:103
A structure used to store rectangular image selections, channel ranges, anchor points,...
Two-sided descriptive statistical estimate.
Definition: Math.h:3528