PCL
ImageVariant.h
Go to the documentation of this file.
1 // ____ ______ __
2 // / __ \ / ____// /
3 // / /_/ // / / /
4 // / ____// /___ / /___ PixInsight Class Library
5 // /_/ \____//_____/ PCL 2.4.9
6 // ----------------------------------------------------------------------------
7 // pcl/ImageVariant.h - Released 2021-04-09T19:40:59Z
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-2021 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 
165 namespace SwapCompression
166 {
167  enum value_type
168  {
169  None, // Do not use compression.
170  ZLib, // ZLib (deflate) compression.
171  ZLib_SH, // ZLib (deflate) compression with byte shuffling.
172  LZ4, // LZ4 fast compression.
173  LZ4_Sh, // LZ4 fast compression with byte shuffling.
174  LZ4HC, // LZ4-HC compression.
175  LZ4HC_Sh, // LZ4-HC compression with byte shuffling.
176 
177  NumberOfAlgorithms
178  };
179 }
180 
317 class PCL_CLASS ImageVariant
318 {
319 public:
320 
326  typedef AbstractImage::color_space color_space;
327 
333  typedef ImageOp::value_type image_op;
334 
335  /*
336  * An enumerated type that represents a compression algorithm for raw
337  * storage file generation. Valid constants for this enumeration are defined
338  * in the SwapCompression namespace.
339  */
340  typedef SwapCompression::value_type swap_compression;
341 
347  {
348  m_data = new Data;
349  }
350 
358  template <class P>
360  {
361  m_data = new Data;
362  m_data->Update( image );
363  }
364 
374  ImageVariant( const ImageVariant& image )
375  : m_data( image.m_data )
376  {
377  m_data->Attach();
378  }
379 
384  : m_data( image.m_data )
385  {
386  image.m_data = nullptr;
387  }
388 
395  virtual ~ImageVariant()
396  {
397  if ( m_data != nullptr )
398  {
399  DetachFromData();
400  m_data = nullptr;
401  }
402  }
403 
408  const AbstractImage* ImagePtr() const noexcept
409  {
410  return m_data->image;
411  }
412 
417  {
418  return m_data->image;
419  }
420 
428  bool IsSameImage( const ImageVariant& image ) const noexcept
429  {
430  return m_data->image == image.m_data->image;
431  }
432 
437  bool IsFloatSample() const noexcept
438  {
439  return m_data->isFloatSample;
440  }
441 
445  bool IsComplexSample() const noexcept
446  {
447  return m_data->isComplexSample;
448  }
449 
454  int BitsPerSample() const noexcept
455  {
456  return m_data->bitsPerSample;
457  }
458 
463  int BytesPerSample() const noexcept
464  {
465  return m_data->bitsPerSample >> 3;
466  }
467 
472  int Width() const noexcept
473  {
474  return m_data->image ? m_data->image->Width() : 0;
475  }
476 
481  int Height() const noexcept
482  {
483  return m_data->image ? m_data->image->Height() : 0;
484  }
485 
492  size_type NumberOfPixels() const noexcept
493  {
494  return m_data->image ? m_data->image->NumberOfPixels() : 0;
495  }
496 
501  int NumberOfChannels() const noexcept
502  {
503  return m_data->image ? m_data->image->NumberOfChannels() : 0;
504  }
505 
513  int LastChannel() const noexcept
514  {
515  return m_data->image ? m_data->image->LastChannel() : -1;
516  }
517 
523  bool IsValidChannelIndex( int c ) const noexcept
524  {
525  return m_data->image && m_data->image->IsValidChannelIndex( c );
526  }
527 
536  int NumberOfNominalChannels() const noexcept
537  {
538  return m_data->image ? m_data->image->NumberOfNominalChannels() : 0;
539  }
540 
549  bool HasAlphaChannels() const noexcept
550  {
551  return m_data->image && m_data->image->HasAlphaChannels();
552  }
553 
562  int NumberOfAlphaChannels() const noexcept
563  {
564  return m_data->image ? m_data->image->NumberOfAlphaChannels() : 0;
565  }
566 
573  size_type NumberOfSamples() const noexcept
574  {
575  return m_data->image ? m_data->image->NumberOfSamples() : 0;
576  }
577 
586  {
587  return m_data->image ? m_data->image->NumberOfNominalSamples() : 0;
588  }
589 
598  {
599  return m_data->image ? m_data->image->NumberOfAlphaSamples() : 0;
600  }
601 
612  Rect Bounds() const noexcept
613  {
614  return m_data->image ? m_data->image->Bounds() : Rect( 0 );
615  }
616 
623  template <typename T>
624  bool Includes( const GenericPoint<T>& p ) const noexcept
625  {
626  return m_data->image && m_data->image->Includes( p );
627  }
628 
635  template <typename T>
636  bool Includes( const GenericRectangle<T>& r ) const noexcept
637  {
638  return m_data->image && m_data->image->Includes( r );
639  }
640 
650  template <typename T>
651  bool Includes( T x0, T y0, T x1, T y1 ) const noexcept
652  {
653  return m_data->image && m_data->image->Includes( x0, y0, x1, y1 );
654  }
655 
665  template <typename T>
666  bool Includes( T x, T y ) const noexcept
667  {
668  return m_data->image && m_data->image->Includes( x, y );
669  }
670 
677  template <typename T>
678  bool Intersects( const pcl::GenericRectangle<T>& r ) const noexcept
679  {
680  return m_data->image && m_data->image->Intersects( r );
681  }
682 
692  template <typename T>
693  bool Intersects( T x0, T y0, T x1, T y1 ) const noexcept
694  {
695  return m_data->image && m_data->image->Intersects( x0, y0, x1, y1 );
696  }
697 
705  template <typename T>
706  bool Clip( pcl::GenericPoint<T>& p ) const noexcept
707  {
708  return m_data->image && m_data->image->Clip( p );
709  }
710 
723  template <typename T>
724  bool Clip( T& x, T& y ) const noexcept
725  {
726  return m_data->image && m_data->image->Clip( x, y );
727  }
728 
739  template <typename T>
740  bool Clip( pcl::GenericRectangle<T>& r ) const noexcept
741  {
742  return m_data->image && m_data->image->Clip( r );
743  }
744 
761  template <typename T>
762  bool Clip( T& x0, T& y0, T& x1, T& y1 ) const noexcept
763  {
764  return m_data->image && m_data->image->Clip( x0, y0, x1, y1 );
765  }
766 
773  void SelectChannel( int c ) const noexcept
774  {
775  if ( m_data->image )
776  m_data->image->SelectChannel( c );
777  }
778 
788  int SelectedChannel() const noexcept
789  {
790  return m_data->image ? m_data->image->SelectedChannel() : -1;
791  }
792 
800  void SelectChannelRange( int c0, int c1 ) const noexcept
801  {
802  if ( m_data->image )
803  m_data->image->SelectChannelRange( c0, c1 );
804  }
805 
810  void SelectNominalChannels() const noexcept
811  {
812  if ( m_data->image )
813  m_data->image->SelectNominalChannels();
814  }
815 
823  void SelectAlphaChannels() const noexcept
824  {
825  if ( m_data->image )
826  m_data->image->SelectAlphaChannels();
827  }
828 
833  void ResetChannelRange() const noexcept
834  {
835  if ( m_data->image )
836  m_data->image->ResetChannelRange();
837  }
838 
843  int NumberOfSelectedChannels() const noexcept
844  {
845  return m_data->image ? m_data->image->NumberOfSelectedChannels() : 0;
846  }
847 
852  int FirstSelectedChannel() const noexcept
853  {
854  return m_data->image ? m_data->image->FirstSelectedChannel() : -1;
855  }
856 
861  int LastSelectedChannel() const noexcept
862  {
863  return m_data->image ? m_data->image->LastSelectedChannel() : -1;
864  }
865 
873  void GetSelectedChannelRange( int& c0, int& c1 ) const noexcept
874  {
875  if ( m_data->image )
876  m_data->image->GetSelectedChannelRange( c0, c1 );
877  }
878 
885  void SelectPoint( int x, int y ) const noexcept
886  {
887  if ( m_data->image )
888  m_data->image->SelectPoint( x, y );
889  }
890 
894  void SelectPoint( const Point& p ) const noexcept
895  {
896  if ( m_data->image )
897  m_data->image->SelectPoint( p );
898  }
899 
903  void ResetPoint() const noexcept
904  {
905  if ( m_data->image )
906  m_data->image->ResetPoint();
907  }
908 
913  Point SelectedPoint() const noexcept
914  {
915  return m_data->image ? m_data->image->SelectedPoint() : Point( 0 );
916  }
917 
931  void SelectRectangle( int x0, int y0, int x1, int y1 ) const noexcept
932  {
933  if ( m_data->image )
934  m_data->image->SelectRectangle( x0, y0, x1, y1 );
935  }
936 
945  void SelectRectangle( const Point& p0, const Point& p1 ) const noexcept
946  {
947  if ( m_data->image )
948  m_data->image->SelectRectangle( p0, p1 );
949  }
950 
955  void SelectRectangle( const Rect& r ) const noexcept
956  {
957  if ( m_data->image )
958  m_data->image->SelectRectangle( r );
959  }
960 
964  void ResetSelection() const noexcept
965  {
966  if ( m_data->image )
967  m_data->image->ResetSelection();
968  }
969 
975  bool IsEmptySelection() const noexcept
976  {
977  return m_data->image ? m_data->image->IsEmptySelection() : false;
978  }
979 
985  bool IsFullSelection() const noexcept
986  {
987  return m_data->image ? m_data->image->IsFullSelection() : false;
988  }
989 
994  Rect SelectedRectangle() const noexcept
995  {
996  return m_data->image ? m_data->image->SelectedRectangle() : Rect( 0 );
997  }
998 
1007  bool IsCompletelySelected() const noexcept
1008  {
1009  return m_data->image ? m_data->image->IsCompletelySelected() : false;
1010  }
1011 
1018  {
1019  return m_data->image ? m_data->image->NumberOfSelectedPixels() : 0;
1020  }
1021 
1028  {
1029  return m_data->image ? m_data->image->NumberOfSelectedSamples() : 0;
1030  }
1031 
1056  bool IsRangeClippingEnabled() const noexcept
1057  {
1058  return m_data->image ? m_data->image->IsRangeClippingEnabled() : false;
1059  }
1060 
1071  bool IsLowRangeClippingEnabled() const noexcept
1072  {
1073  return m_data->image ? m_data->image->IsLowRangeClippingEnabled() : false;
1074  }
1075 
1086  bool IsHighRangeClippingEnabled() const noexcept
1087  {
1088  return m_data->image ? m_data->image->IsHighRangeClippingEnabled() : false;
1089  }
1090 
1096  void EnableRangeClipping( bool enableLow = true, bool enableHigh = true ) const noexcept
1097  {
1098  if ( m_data->image )
1099  m_data->image->EnableRangeClipping( enableLow, enableHigh );
1100  }
1101 
1107  void DisableRangeClipping( bool disableLow = true, bool disableHigh = true ) const noexcept
1108  {
1109  if ( m_data->image )
1110  m_data->image->DisableRangeClipping( disableLow, disableHigh );
1111  }
1112 
1119  double RangeClipLow() const noexcept
1120  {
1121  return m_data->image ? m_data->image->RangeClipLow() : 0.0;
1122  }
1123 
1130  double RangeClipHigh() const noexcept
1131  {
1132  return m_data->image ? m_data->image->RangeClipHigh() : 0.0;
1133  }
1134 
1140  void SetRangeClipLow( double clipLow ) const noexcept
1141  {
1142  if ( m_data->image )
1143  m_data->image->SetRangeClipLow( clipLow );
1144  }
1145 
1151  void SetRangeClipHigh( double clipHigh ) const noexcept
1152  {
1153  if ( m_data->image )
1154  m_data->image->SetRangeClipHigh( clipHigh );
1155  }
1156 
1163  void SetRangeClipping( double clipLow, double clipHigh ) const noexcept
1164  {
1165  if ( m_data->image )
1166  m_data->image->SetRangeClipping( clipLow, clipHigh );
1167  }
1168 
1176  void ResetRangeClipping() const noexcept
1177  {
1178  if ( m_data->image )
1179  m_data->image->ResetRangeClipping();
1180  }
1181 
1200  void ResetSelections() const noexcept
1201  {
1202  if ( m_data->image )
1203  m_data->image->ResetSelections();
1204  }
1205 
1213  ImageSelections& Selections() const noexcept
1214  {
1215  return m_data->image->Selections();
1216  }
1217 
1222  void PushSelections() const
1223  {
1224  if ( m_data->image )
1225  m_data->image->PushSelections();
1226  }
1227 
1236  void PopSelections() const
1237  {
1238  if ( m_data->image )
1239  m_data->image->PopSelections();
1240  }
1241 
1248  bool CanPopSelections() const noexcept
1249  {
1250  return m_data->image ? m_data->image->CanPopSelections() : false;
1251  }
1252 
1260  StatusMonitor& Status() const noexcept
1261  {
1262  PCL_PRECONDITION( m_data->image != nullptr )
1263  return m_data->image->Status();
1264  }
1265 
1272  {
1273  return m_data->image ? m_data->image->StatusCallback() : nullptr;
1274  }
1275 
1283  void SetStatusCallback( pcl::StatusCallback* callback ) const noexcept
1284  {
1285  if ( m_data->image )
1286  m_data->image->SetStatusCallback( callback );
1287  }
1288 
1297  bool IsParallelProcessingEnabled() const noexcept
1298  {
1299  return m_data->image != nullptr && m_data->image->IsParallelProcessingEnabled();
1300  }
1301 
1315  void EnableParallelProcessing( bool enable = true, int maxProcessors = 0 ) noexcept
1316  {
1317  if ( m_data->image )
1318  m_data->image->EnableParallelProcessing( enable, maxProcessors );
1319  }
1320 
1330  void DisableParallelProcessing( bool disable = true ) noexcept
1331  {
1332  if ( m_data->image )
1333  m_data->image->DisableParallelProcessing( disable );
1334  }
1335 
1349  int MaxProcessors() const noexcept
1350  {
1351  return m_data->image ? m_data->image->MaxProcessors() : 0;
1352  }
1353 
1374  void SetMaxProcessors( int maxProcessors ) noexcept
1375  {
1376  if ( m_data->image )
1377  m_data->image->SetMaxProcessors( maxProcessors );
1378  }
1379 
1387  size_type LineSize() const noexcept
1388  {
1389  return m_data->image ? BytesPerSample() * size_type( m_data->image->Width() ) : 0;
1390  }
1391 
1398  size_type ChannelSize() const noexcept
1399  {
1400  return BytesPerSample() * NumberOfPixels();
1401  }
1402 
1410  size_type ImageSize() const noexcept
1411  {
1412  return ChannelSize() * size_type( NumberOfChannels() );
1413  }
1414 
1423  size_type NominalSize() const noexcept
1424  {
1425  return ChannelSize() * size_type( NumberOfNominalChannels() );
1426  }
1427 
1436  size_type AlphaSize() const noexcept
1437  {
1438  return ChannelSize() * size_type( NumberOfAlphaChannels() );
1439  }
1440 
1446  bool IsColor() const noexcept
1447  {
1448  return m_data->image && m_data->image->IsColor();
1449  }
1450 
1459  color_space ColorSpace() const noexcept
1460  {
1461  return m_data->image ? m_data->image->ColorSpace() : ColorSpace::Unknown;
1462  }
1463 
1469  String ChannelId( int c ) const noexcept
1470  {
1471  return m_data->image ? m_data->image->ChannelId( c ) : String();
1472  }
1473 
1481  const RGBColorSystem& RGBWorkingSpace() const noexcept
1482  {
1483  PCL_PRECONDITION( m_data->image != nullptr )
1484  return m_data->image->RGBWorkingSpace();
1485  }
1486 
1498  void SetRGBWorkingSpace( const RGBColorSystem& rgbws )
1499  {
1500  if ( m_data->image )
1501  m_data->image->SetRGBWorkingSpace( rgbws );
1502  }
1503 
1504  // -------------------------------------------------------------------------
1505 
1506 #define __ABSOLUTE_DIFFERENCE( I ) \
1507  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).AbsoluteDifference( scalar, rect, firstChannel, lastChannel ) ) ); \
1508  result.SetOwnership( true )
1509 
1518  template <typename T>
1520  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
1521  {
1522  ImageVariant result;
1523  if ( *this )
1524  SOLVE_TEMPLATE( __ABSOLUTE_DIFFERENCE )
1525  return result;
1526  }
1527 
1528 #undef __ABSOLUTE_DIFFERENCE
1529 
1530  // -------------------------------------------------------------------------
1531 
1532 #define __ABSOLUTE_VALUE( I ) \
1533  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).AbsoluteValue( rect, firstChannel, lastChannel ) ) ); \
1534  result.SetOwnership( true )
1535 
1543  ImageVariant AbsoluteValue( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
1544  {
1545  ImageVariant result;
1546  if ( *this )
1547  SOLVE_TEMPLATE( __ABSOLUTE_VALUE )
1548  return result;
1549  }
1550 
1551 #undef __ABSOLUTE_VALUE
1552 
1553  // -------------------------------------------------------------------------
1554 
1555 #define __ADD( I ) \
1556  static_cast<pcl::I&>( **this ).Add( scalar, rect, firstChannel, lastChannel )
1557 
1564  template <typename T>
1565  ImageVariant& Add( T scalar,
1566  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
1567  {
1568  if ( *this )
1569  SOLVE_TEMPLATE( __ADD )
1570  return *this;
1571  }
1572 
1573 #undef __ADD
1574 
1575  // -------------------------------------------------------------------------
1576 
1577 #define __ADD_1( I ) \
1578  ImageVariant::Add( static_cast<pcl::I&>( **this ), image, point, channel, rect, firstChannel, lastChannel )
1579 
1580 #define __ADD_2( I ) \
1581  image1.Add( static_cast<const pcl::I&>( *image2 ), point, channel, rect, firstChannel, lastChannel )
1582 
1583 private:
1584 
1585  template <class P> static
1586  void Add( GenericImage<P>& image1, const ImageVariant& image2,
1587  const Point& point, int channel,
1588  const Rect& rect, int firstChannel, int lastChannel )
1589  {
1590  SOLVE_TEMPLATE_2( image2, __ADD_2 )
1591  }
1592 
1593 public:
1594 
1602  const Point& point = Point( int_max ), int channel = -1,
1603  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
1604  {
1605  if ( *this )
1606  if ( image )
1607  SOLVE_TEMPLATE( __ADD_1 )
1608  return *this;
1609  }
1610 
1611 #undef __ADD_1
1612 #undef __ADD_2
1613 
1614  // -------------------------------------------------------------------------
1615 
1616 #define __ADDED( I ) \
1617  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Added( scalar, rect, firstChannel, lastChannel ) ) ); \
1618  result.SetOwnership( true )
1619 
1626  template <typename T>
1627  ImageVariant Added( T scalar,
1628  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
1629  {
1630  ImageVariant result;
1631  if ( *this )
1632  SOLVE_TEMPLATE( __ADDED )
1633  return result;
1634  }
1635 
1636 #undef __ADDED
1637 
1638  // -------------------------------------------------------------------------
1639 
1640 #define __ALLOCATE_DATA( I ) \
1641  static_cast<pcl::I&>( **this ).AllocateData( width, height, numberOfChannels, colorSpace )
1642 
1653  ImageVariant& AllocateData( int width, int height, int numberOfChannels = 1, color_space colorSpace = ColorSpace::Gray )
1654  {
1655  if ( !*this )
1656  CreateImage();
1657  SOLVE_TEMPLATE( __ALLOCATE_DATA )
1658  return *this;
1659  }
1660 
1661 #undef __ALLOCATE_DATA
1662 
1663  // -------------------------------------------------------------------------
1664 
1665 #define __ALLOCATE_DATA( I ) \
1666  static_cast<pcl::I&>( **this ).AllocateData( rect, numberOfChannels, colorSpace )
1667 
1678  ImageVariant& AllocateData( const Rect& rect, int numberOfChannels = 1, color_space colorSpace = ColorSpace::Gray )
1679  {
1680  if ( !*this )
1681  CreateImage();
1682  SOLVE_TEMPLATE( __ALLOCATE_DATA )
1683  return *this;
1684  }
1685 
1686 #undef __ALLOCATE_DATA
1687 
1688  // -------------------------------------------------------------------------
1689 
1690 #define __AND( I ) \
1691  static_cast<pcl::I&>( **this ).And( scalar, rect, firstChannel, lastChannel )
1692 
1700  template <typename T>
1701  ImageVariant& And( T scalar,
1702  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
1703  {
1704  if ( *this )
1705  SOLVE_TEMPLATE_REAL( __AND )
1706  return *this;
1707  }
1708 
1709 #undef __AND
1710 
1711  // -------------------------------------------------------------------------
1712 
1713 #define __AND_1( I ) \
1714  ImageVariant::And( static_cast<pcl::I&>( **this ), image, point, channel, rect, firstChannel, lastChannel )
1715 
1716 #define __AND_2( I ) \
1717  image1.And( static_cast<const pcl::I&>( *image2 ), point, channel, rect, firstChannel, lastChannel )
1718 
1719 private:
1720 
1721  template <class P> static
1722  void And( GenericImage<P>& image1, const ImageVariant& image2,
1723  const Point& point, int channel,
1724  const Rect& rect, int firstChannel, int lastChannel )
1725  {
1726  SOLVE_TEMPLATE_REAL_2( image2, __AND_2 )
1727  }
1728 
1729 public:
1730 
1739  const Point& point = Point( int_max ), int channel = -1,
1740  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
1741  {
1742  if ( *this )
1743  if ( image )
1744  SOLVE_TEMPLATE_REAL( __AND_1 )
1745  return *this;
1746  }
1747 
1748 #undef __AND_1
1749 #undef __AND_2
1750 
1751  // -------------------------------------------------------------------------
1752 
1753 #define __APPLIED( I ) \
1754  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Applied( scalar, op, rect, firstChannel, lastChannel ) ) ); \
1755  result.SetOwnership( true )
1756 
1765  template <typename T>
1766  ImageVariant Applied( T scalar, image_op op = ImageOp::Mov,
1767  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
1768  {
1769  ImageVariant result;
1770  if ( *this )
1771  SOLVE_TEMPLATE( __APPLIED )
1772  return result;
1773  }
1774 
1775 #undef __APPLIED
1776 
1777  // -------------------------------------------------------------------------
1778 
1779 #define __APPLIED_1( I ) \
1780  result = ImageVariant::Applied( static_cast<const pcl::I&>( **this ), image, op, point, channel, rect, firstChannel, lastChannel )
1781 
1782 #define __APPLIED_2( I ) \
1783  result.SetImage( *new pcl::I( image1.Applied( static_cast<const pcl::I&>( *image2 ), op, point, channel, rect, firstChannel, lastChannel ) ) ); \
1784  result.SetOwnership( true )
1785 
1786 private:
1787 
1788  template <class P> static
1789  ImageVariant Applied( const GenericImage<P>& image1, const ImageVariant& image2,
1790  image_op op, const Point& point, int channel,
1791  const Rect& rect, int firstChannel, int lastChannel )
1792  {
1793  ImageVariant result;
1794  SOLVE_TEMPLATE_2( image2, __APPLIED_2 )
1795  return result;
1796  }
1797 
1798 public:
1799 
1808  ImageVariant Applied( const ImageVariant& image, image_op op = ImageOp::Mov,
1809  const Point& point = Point( int_max ), int channel = -1,
1810  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
1811  {
1812  ImageVariant result;
1813  if ( *this )
1814  if ( image )
1815  SOLVE_TEMPLATE( __APPLIED_1 )
1816  return result;
1817  }
1818 
1819 #undef __APPLIED_1
1820 #undef __APPLIED_2
1821 
1822  // -------------------------------------------------------------------------
1823 
1824 #define __APPLIED( I ) \
1825  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Applied( transformation, rect, firstChannel, lastChannel ) ) ); \
1826  result.SetOwnership( true )
1827 
1835  ImageVariant Applied( const ImageTransformation& transformation,
1836  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
1837  {
1838  ImageVariant result;
1839  if ( *this )
1840  SOLVE_TEMPLATE( __APPLIED )
1841  return result;
1842  }
1843 
1844 #undef __APPLIED
1845 
1846  // -------------------------------------------------------------------------
1847 
1848 #define __APPLY( I ) \
1849  static_cast<pcl::I&>( **this ).Apply( scalar, op, rect, firstChannel, lastChannel )
1850 
1859  template <typename T>
1860  ImageVariant& Apply( T scalar, image_op op = ImageOp::Mov,
1861  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
1862  {
1863  if ( *this )
1864  SOLVE_TEMPLATE( __APPLY )
1865  return *this;
1866  }
1867 
1868 #undef __APPLY
1869 
1870  // -------------------------------------------------------------------------
1871 
1872 #define __APPLY_1( I ) \
1873  ImageVariant::Apply( static_cast<pcl::I&>( **this ), image, op, point, channel, rect, firstChannel, lastChannel )
1874 
1875 #define __APPLY_2( I ) \
1876  image1.Apply( static_cast<const pcl::I&>( *image2 ), op, point, channel, rect, firstChannel, lastChannel )
1877 
1878 private:
1879 
1880  template <class P> static
1881  void Apply( GenericImage<P>& image1, const ImageVariant& image2,
1882  image_op op, const Point& point, int channel,
1883  const Rect& rect, int firstChannel, int lastChannel )
1884  {
1885  SOLVE_TEMPLATE_2( image2, __APPLY_2 )
1886  }
1887 
1888 public:
1889 
1898  ImageVariant& Apply( const ImageVariant& image, image_op op = ImageOp::Mov,
1899  const Point& point = Point( int_max ), int channel = -1,
1900  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
1901  {
1902  if ( *this )
1903  if ( image )
1904  SOLVE_TEMPLATE( __APPLY_1 )
1905  return *this;
1906  }
1907 
1908 #undef __APPLY_1
1909 #undef __APPLY_2
1910 
1911  // -------------------------------------------------------------------------
1912 
1913 #define __APPLY( I ) \
1914  static_cast<pcl::I&>( **this ).Apply( transformation, rect, firstChannel, lastChannel )
1915 
1923  ImageVariant& Apply( const ImageTransformation& transformation,
1924  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
1925  {
1926  if ( *this )
1927  SOLVE_TEMPLATE( __APPLY )
1928  return *this;
1929  }
1930 
1931 #undef __APPLY
1932 
1933  // -------------------------------------------------------------------------
1934 
1935 #define __ASSIGN_IMAGE_1( I ) \
1936  ImageVariant::AssignImage( static_cast<pcl::I&>( **this ), image, rect, firstChannel, lastChannel )
1937 
1938 #define __ASSIGN_IMAGE_2( I ) \
1939  image1.Assign( static_cast<const pcl::I&>( *image2 ), rect, firstChannel, lastChannel )
1940 
1941 private:
1942 
1943  template <class P> static
1944  void AssignImage( GenericImage<P>& image1, const ImageVariant& image2,
1945  const Rect& rect, int firstChannel, int lastChannel )
1946  {
1947  SOLVE_TEMPLATE_2( image2, __ASSIGN_IMAGE_2 )
1948  }
1949 
1950 public:
1951 
1959  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
1960  {
1961  if ( *this )
1962  if ( image )
1963  SOLVE_TEMPLATE( __ASSIGN_IMAGE_1 )
1964  return *this;
1965  }
1966 
1967 #undef __ASSIGN_IMAGE_1
1968 #undef __ASSIGN_IMAGE_2
1969 
1970  // -------------------------------------------------------------------------
1971 
1972 #define __AVG_DEV( I ) \
1973  result = static_cast<const pcl::I&>( **this ).AvgDev( center, rect, firstChannel, lastChannel, maxProcessors )
1974 
1981  double AvgDev( double center,
1982  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
1983  int maxProcessors = 0 ) const
1984  {
1985  double result = 0;
1986  if ( *this )
1987  SOLVE_TEMPLATE( __AVG_DEV )
1988  return result;
1989  }
1990 
1991 #undef __AVG_DEV
1992 
1993  // -------------------------------------------------------------------------
1994 
1995 #define __2SIDED_AVG_DEV( I ) \
1996  result = static_cast<const pcl::I&>( **this ).TwoSidedAvgDev( center, rect, firstChannel, lastChannel, maxProcessors )
1997 
2006  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
2007  int maxProcessors = 0 ) const
2008  {
2009  TwoSidedEstimate result( 0 );
2010  if ( *this )
2011  SOLVE_TEMPLATE( __2SIDED_AVG_DEV )
2012  return result;
2013  }
2014 
2015 #undef __2SIDED_AVG_DEV
2016 
2017  // -------------------------------------------------------------------------
2018 
2019 #define __BINARIZE( I ) \
2020  static_cast<pcl::I&>( **this ).Binarize( threshold, rect, firstChannel, lastChannel )
2021 
2029  template <typename T>
2030  ImageVariant& Binarize( T threshold, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
2031  {
2032  if ( *this )
2033  SOLVE_TEMPLATE_REAL( __BINARIZE )
2034  return *this;
2035  }
2036 
2037 #undef __BINARIZE
2038 
2039  // -------------------------------------------------------------------------
2040 
2041 #define __BINARIZE( I ) \
2042  static_cast<pcl::I&>( **this ).Binarize( rect, firstChannel, lastChannel )
2043 
2051  ImageVariant& Binarize( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
2052  {
2053  if ( *this )
2054  SOLVE_TEMPLATE_REAL( __BINARIZE )
2055  return *this;
2056  }
2057 
2058 #undef __BINARIZE
2059 
2060  // -------------------------------------------------------------------------
2061 
2062 #define __BINARIZED( I ) \
2063  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Binarized( threshold, rect, firstChannel, lastChannel ) ) ); \
2064  result.SetOwnership( true )
2065 
2073  template <typename T>
2074  ImageVariant Binarized( T threshold, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
2075  {
2076  ImageVariant result;
2077  if ( *this )
2078  SOLVE_TEMPLATE_REAL( __BINARIZED )
2079  return result;
2080  }
2081 
2082 #undef __BINARIZED
2083 
2084  // -------------------------------------------------------------------------
2085 
2086 #define __BINARIZED( I ) \
2087  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Binarized( rect, firstChannel, lastChannel ) ) ); \
2088  result.SetOwnership( true )
2089 
2097  ImageVariant Binarized( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
2098  {
2099  ImageVariant result;
2100  if ( *this )
2101  SOLVE_TEMPLATE_REAL( __BINARIZED )
2102  return result;
2103  }
2104 
2105 #undef __BINARIZED
2106 
2107  // -------------------------------------------------------------------------
2108 
2109 #define __PBMV( I ) \
2110  result = static_cast<const pcl::I&>( **this ).BendMidvariance( center, beta, rect, firstChannel, lastChannel, maxProcessors )
2111 
2120  double BendMidvariance( double center, double beta = 0.2,
2121  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
2122  int maxProcessors = 0 ) const
2123  {
2124  double result = 0;
2125  if ( *this )
2126  SOLVE_TEMPLATE( __PBMV )
2127  return result;
2128  }
2129 
2130 #undef __PBMV
2131 
2132  // -------------------------------------------------------------------------
2133 
2134 #define __BWMV( I ) \
2135  result = static_cast<const pcl::I&>( **this ).BiweightMidvariance( center, sigma, k, reducedLength, rect, firstChannel, lastChannel, maxProcessors )
2136 
2145  double BiweightMidvariance( double center, double sigma, int k = 9, bool reducedLength = false,
2146  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
2147  int maxProcessors = 0 ) const
2148  {
2149  double result = 0;
2150  if ( *this )
2151  SOLVE_TEMPLATE( __BWMV )
2152  return result;
2153  }
2154 
2155 #undef __BWMV
2156 
2157  // -------------------------------------------------------------------------
2158 
2159 #define __2SIDED_BWMV( I ) \
2160  result = static_cast<const pcl::I&>( **this ).TwoSidedBiweightMidvariance( center, sigma, k, reducedLength, rect, firstChannel, lastChannel, maxProcessors )
2161 
2170  TwoSidedEstimate TwoSidedBiweightMidvariance( double center, const TwoSidedEstimate& sigma, int k = 9, bool reducedLength = false,
2171  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
2172  int maxProcessors = 0 ) const
2173  {
2174  TwoSidedEstimate result( 0 );
2175  if ( *this )
2176  SOLVE_TEMPLATE( __2SIDED_BWMV )
2177  return result;
2178  }
2179 
2180 #undef __2SIDED_BWMV
2181 
2182  // -------------------------------------------------------------------------
2183 
2184 #define __BLACK( I ) \
2185  static_cast<pcl::I&>( **this ).Black( rect, firstChannel, lastChannel )
2186 
2193  ImageVariant& Black( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
2194  {
2195  if ( *this )
2196  SOLVE_TEMPLATE( __BLACK )
2197  return *this;
2198  }
2199 
2200 #undef __BLACK
2201 
2202  // -------------------------------------------------------------------------
2203 
2204 #define __BLEND( I ) \
2205  static_cast<pcl::I&>( **this ).Blend( bitmap, point, rect )
2206 
2213  ImageVariant& Blend( const Bitmap& bitmap,
2214  const Point& point = Point( int_max ), const Rect& rect = Rect( 0 ) )
2215  {
2216  if ( *this )
2217  SOLVE_TEMPLATE_REAL( __BLEND )
2218  return *this;
2219  }
2220 
2221 #undef __BLEND
2222 
2223  // -------------------------------------------------------------------------
2224 
2225 #define __BLENDED( I ) \
2226  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Blended( bitmap, point, rect ) ) ); \
2227  result.SetOwnership( true )
2228 
2235  ImageVariant Blended( const Bitmap& bitmap, const Point& point = Point( int_max ), const Rect& rect = Rect( 0 ) ) const
2236  {
2237  ImageVariant result;
2238  if ( *this )
2239  SOLVE_TEMPLATE_REAL( __BLENDED )
2240  return result;
2241  }
2242 
2243 #undef __BLENDED
2244 
2245  // -------------------------------------------------------------------------
2246 
2247 #define __COUNT( I ) \
2248  result = static_cast<const pcl::I&>( **this ).Count( rect, firstChannel, lastChannel, maxProcessors )
2249 
2256  uint64 Count( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1, int maxProcessors = 0 ) const
2257  {
2258  uint64 result = 0;
2259  if ( *this )
2260  SOLVE_TEMPLATE( __COUNT )
2261  return result;
2262  }
2263 
2264 #undef __COUNT
2265 
2266  // -------------------------------------------------------------------------
2267 
2268 #define __CREATE_ALPHA_CHANNELS( I ) \
2269  static_cast<pcl::I&>( **this ).CreateAlphaChannels( n )
2270 
2283  void CreateAlphaChannels( int n )
2284  {
2285  if ( *this )
2286  SOLVE_TEMPLATE( __CREATE_ALPHA_CHANNELS )
2287  }
2288 
2289 #undef __CREATE_ALPHA_CHANNELS
2290 
2291  // -------------------------------------------------------------------------
2292 
2293 #define __CROP( I ) \
2294  static_cast<pcl::I&>( **this ).Crop( fillValues )
2295 
2302  template <typename T>
2303  ImageVariant& Crop( const GenericVector<T>& fillValues )
2304  {
2305  if ( *this )
2306  SOLVE_TEMPLATE( __CROP )
2307  return *this;
2308  }
2309 
2310 #undef __CROP
2311 
2312  // -------------------------------------------------------------------------
2313 
2314 #define __CROP( I ) \
2315  static_cast<pcl::I&>( **this ).Crop()
2316 
2325  {
2326  if ( *this )
2327  SOLVE_TEMPLATE( __CROP )
2328  return *this;
2329  }
2330 
2331 #undef __CROP
2332 
2333  // -------------------------------------------------------------------------
2334 
2335 #define __CROP_BY( I ) \
2336  static_cast<pcl::I&>( **this ).CropBy( left, top, right, bottom, fillValues )
2337 
2344  template <typename T>
2345  ImageVariant& CropBy( int left, int top, int right, int bottom, const GenericVector<T>& fillValues )
2346  {
2347  if ( *this )
2348  SOLVE_TEMPLATE( __CROP_BY )
2349  return *this;
2350  }
2351 
2352 #undef __CROP_BY
2353 
2354  // -------------------------------------------------------------------------
2355 
2356 #define __CROP_BY( I ) \
2357  static_cast<pcl::I&>( **this ).CropBy( left, top, right, bottom )
2358 
2365  ImageVariant& CropBy( int left, int top, int right, int bottom )
2366  {
2367  if ( *this )
2368  SOLVE_TEMPLATE( __CROP_BY )
2369  return *this;
2370  }
2371 
2372 #undef __CROP_BY
2373 
2374  // -------------------------------------------------------------------------
2375 
2376 #define __CROP_TO( I ) \
2377  static_cast<pcl::I&>( **this ).CropTo( rect, fillValues )
2378 
2385  template <typename T>
2386  ImageVariant& CropTo( const Rect& rect, const GenericVector<T>& fillValues )
2387  {
2388  if ( *this )
2389  SOLVE_TEMPLATE( __CROP_TO )
2390  return *this;
2391  }
2392 
2393 #undef __CROP_TO
2394 
2395  // -------------------------------------------------------------------------
2396 
2397 #define __CROP_TO( I ) \
2398  static_cast<pcl::I&>( **this ).CropTo( rect )
2399 
2407  ImageVariant& CropTo( const Rect& rect )
2408  {
2409  if ( *this )
2410  SOLVE_TEMPLATE( __CROP_TO )
2411  return *this;
2412  }
2413 
2414 #undef __CROP_TO
2415 
2416  // -------------------------------------------------------------------------
2417 
2418 #define __CROP_TO( I ) \
2419  static_cast<pcl::I&>( **this ).CropTo( x0, y0, x1, y1, fillValues )
2420 
2427  template <typename T>
2428  ImageVariant& CropTo( int x0, int y0, int x1, int y1, const GenericVector<T>& fillValues )
2429  {
2430  if ( *this )
2431  SOLVE_TEMPLATE( __CROP_TO )
2432  return *this;
2433  }
2434 
2435 #undef __CROP_TO
2436 
2437  // -------------------------------------------------------------------------
2438 
2439 #define __CROP_TO( I ) \
2440  static_cast<pcl::I&>( **this ).CropTo( x0, y0, x1, y1 )
2441 
2449  ImageVariant& CropTo( int x0, int y0, int x1, int y1 )
2450  {
2451  if ( *this )
2452  SOLVE_TEMPLATE( __CROP_TO )
2453  return *this;
2454  }
2455 
2456 #undef __CROP_TO
2457 
2458  // -------------------------------------------------------------------------
2459 
2460 #define __DELETE_ALPHA_CHANNEL( I ) \
2461  static_cast<pcl::I&>( **this ).DeleteAlphaChannel( channel )
2462 
2469  void DeleteAlphaChannel( int channel )
2470  {
2471  if ( *this )
2472  SOLVE_TEMPLATE( __DELETE_ALPHA_CHANNEL )
2473  }
2474 
2475 #undef __DELETE_ALPHA_CHANNEL
2476 
2477  // -------------------------------------------------------------------------
2478 
2479 #define __DELETE_ALPHA_CHANNELS( I ) \
2480  static_cast<pcl::I&>( **this ).DeleteAlphaChannels()
2481 
2490  {
2491  if ( *this )
2492  SOLVE_TEMPLATE( __DELETE_ALPHA_CHANNELS )
2493  }
2494 
2495 #undef __DELETE_ALPHA_CHANNELS
2496 
2497  // -------------------------------------------------------------------------
2498 
2499 #define __DIVIDE( I ) \
2500  static_cast<pcl::I&>( **this ).Divide( scalar, rect, firstChannel, lastChannel )
2501 
2508  template <typename T>
2509  ImageVariant& Divide( T scalar, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
2510  {
2511  if ( *this )
2512  SOLVE_TEMPLATE( __DIVIDE )
2513  return *this;
2514  }
2515 
2516 #undef __DIVIDE
2517 
2521  template <typename T>
2522  ImageVariant& Div( T scalar, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
2523  {
2524  return Divide( scalar, rect, firstChannel, lastChannel );
2525  }
2526 
2527  // -------------------------------------------------------------------------
2528 
2529 #define __DIVIDE_1( I ) \
2530  ImageVariant::Divide( static_cast<pcl::I&>( **this ), image, point, channel, rect, firstChannel, lastChannel )
2531 
2532 #define __DIVIDE_2( I ) \
2533  image1.Divide( static_cast<const pcl::I&>( *image2 ), point, channel, rect, firstChannel, lastChannel )
2534 
2535 private:
2536 
2537  template <class P> static
2538  void Divide( GenericImage<P>& image1, const ImageVariant& image2,
2539  const Point& point, int channel,
2540  const Rect& rect, int firstChannel, int lastChannel )
2541  {
2542  SOLVE_TEMPLATE_2( image2, __DIVIDE_2 )
2543  }
2544 
2545 public:
2546 
2554  const Point& point = Point( int_max ), int channel = -1,
2555  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
2556  {
2557  if ( *this )
2558  if ( image )
2559  SOLVE_TEMPLATE( __DIVIDE_1 )
2560  return *this;
2561  }
2562 
2563 #undef __DIVIDE_1
2564 #undef __DIVIDE_2
2565 
2570  const Point& point = Point( int_max ), int channel = -1,
2571  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
2572  {
2573  return Divide( image, point, channel, rect, firstChannel, lastChannel );
2574  }
2575 
2576  // -------------------------------------------------------------------------
2577 
2578 #define __DIVIDED( I ) \
2579  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Divided( scalar, rect, firstChannel, lastChannel ) ) ); \
2580  result.SetOwnership( true )
2581 
2588  template <typename T>
2590  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
2591  {
2592  ImageVariant result;
2593  if ( *this )
2594  SOLVE_TEMPLATE( __DIVIDED )
2595  return result;
2596  }
2597 
2598 #undef __DIVIDED
2599 
2600  // -------------------------------------------------------------------------
2601 
2602 #define __EXCHANGE_1( I ) \
2603  ImageVariant::Exchange( static_cast<pcl::I&>( **this ), image, point, channel, rect, firstChannel, lastChannel )
2604 
2605 #define __EXCHANGE_2( I ) \
2606  image1.Exchange( static_cast<pcl::I&>( *image2 ), point, channel, rect, firstChannel, lastChannel )
2607 
2608 private:
2609 
2610  template <class P> static
2611  void Exchange( GenericImage<P>& image1, ImageVariant& image2,
2612  const Point& point, int channel,
2613  const Rect& rect, int firstChannel, int lastChannel )
2614  {
2615  SOLVE_TEMPLATE_2( image2, __EXCHANGE_2 )
2616  }
2617 
2618 public:
2619 
2628  const Point& point = Point( int_max ), int channel = -1,
2629  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
2630  {
2631  if ( *this )
2632  if ( image )
2633  SOLVE_TEMPLATE( __EXCHANGE_1 )
2634  return *this;
2635  }
2636 
2637 #undef __EXCHANGE_1
2638 #undef __EXCHANGE_2
2639 
2644  const Point& point = Point( int_max ), int channel = -1,
2645  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
2646  {
2647  return Exchange( image, point, channel, rect, firstChannel, lastChannel );
2648  }
2649 
2650  // -------------------------------------------------------------------------
2651 
2652 #define __FILL( I ) \
2653  static_cast<pcl::I&>( **this ).Fill( scalar, rect, firstChannel, lastChannel )
2654 
2661  template <typename T>
2662  ImageVariant& Fill( T scalar,
2663  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
2664  {
2665  if ( *this )
2666  SOLVE_TEMPLATE( __FILL )
2667  return *this;
2668  }
2669 
2670 #undef __FILL
2671 
2672  // -------------------------------------------------------------------------
2673 
2674 #define __FILL( I ) \
2675  static_cast<pcl::I&>( **this ).Fill( values, rect, firstChannel, lastChannel )
2676 
2684  template <typename T>
2686  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
2687  {
2688  if ( *this )
2689  SOLVE_TEMPLATE( __FILL )
2690  return *this;
2691  }
2692 
2693 #undef __FILL
2694 
2695  // -------------------------------------------------------------------------
2696 
2697 #define __FILLED( I ) \
2698  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Filled( scalar, rect, firstChannel, lastChannel ) ) ); \
2699  result.SetOwnership( true )
2700 
2707  template <typename T>
2709  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
2710  {
2711  ImageVariant result;
2712  if ( *this )
2713  SOLVE_TEMPLATE( __FILLED )
2714  return result;
2715  }
2716 
2717 #undef __FILLED
2718 
2719  // -------------------------------------------------------------------------
2720 
2721 #define __FILLED( I ) \
2722  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Filled( values, rect, firstChannel, lastChannel ) ) ); \
2723  result.SetOwnership( true )
2724 
2732  template <typename T>
2734  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
2735  {
2736  ImageVariant result;
2737  if ( *this )
2738  SOLVE_TEMPLATE( __FILLED )
2739  return result;
2740  }
2741 
2742 #undef __FILLED
2743 
2744  // -------------------------------------------------------------------------
2745 
2746 #define __FORGET_ALPHA_CHANNEL( I ) \
2747  static_cast<pcl::I&>( **this ).ForgetAlphaChannel( channel )
2748 
2756  void ForgetAlphaChannel( int channel )
2757  {
2758  if ( *this )
2759  SOLVE_TEMPLATE( __FORGET_ALPHA_CHANNEL )
2760  }
2761 
2762 #undef __FORGET_ALPHA_CHANNEL
2763 
2764  // -------------------------------------------------------------------------
2765 
2766 #define __FORGET_ALPHA_CHANNELS( I ) \
2767  static_cast<pcl::I&>( **this ).ForgetAlphaChannels()
2768 
2777  {
2778  if ( *this )
2779  SOLVE_TEMPLATE( __FORGET_ALPHA_CHANNELS )
2780  }
2781 
2782 #undef __FORGET_ALPHA_CHANNELS
2783 
2784  // -------------------------------------------------------------------------
2785 
2786 #define __GET_COLUMN( I ) \
2787  static_cast<const pcl::I&>( **this ).GetColumn( buffer, x, channel )
2788 
2796  template <typename T>
2797  void GetColumn( T* buffer, int x, int channel = -1 ) const
2798  {
2799  PCL_PRECONDITION( buffer != 0 )
2800  if ( *this )
2801  SOLVE_TEMPLATE( __GET_COLUMN )
2802  }
2803 
2804 #undef __GET_COLUMN
2805 
2806  // -------------------------------------------------------------------------
2807 
2808 #define __GET_EXTREME_SAMPLE_VALUES( I ) \
2809  static_cast<const pcl::I&>( **this ).GetExtremeSampleValues( min, max, rect, firstChannel, lastChannel, maxProcessors )
2810 
2817  template <typename T>
2818  void GetExtremeSampleValues( T& min, T& max,
2819  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
2820  int maxProcessors = 0 ) const
2821  {
2822  PCL_PRECONDITION( buffer != 0 )
2823  if ( *this )
2824  SOLVE_TEMPLATE( __GET_EXTREME_SAMPLE_VALUES )
2825  }
2826 
2827 #undef __GET_EXTREME_SAMPLE_VALUES
2828 
2829  // -------------------------------------------------------------------------
2830 
2831 #define __GET_INTENSITY_1( I ) \
2832  ImageVariant::GetIntensity( Y, static_cast<const pcl::I&>( **this ), rect, maxProcessors )
2833 
2834 #define __GET_INTENSITY_2( I ) \
2835  image.GetIntensity( static_cast<pcl::I&>( *Y ), rect, maxProcessors )
2836 
2837 private:
2838 
2839  template <class P> static
2840  void GetIntensity( ImageVariant& Y, const GenericImage<P>& image, const Rect& rect, int maxProcessors )
2841  {
2842  if ( !Y.IsComplexSample() )
2843  SOLVE_TEMPLATE_REAL_2( Y, __GET_INTENSITY_2 )
2844  }
2845 
2846 public:
2847 
2860  void GetIntensity( ImageVariant& Y, const Rect& rect = Rect( 0 ), int maxProcessors = 0 ) const
2861  {
2862  if ( *this )
2863  if ( !IsComplexSample() )
2864  {
2865  if ( !Y )
2866  Y.CreateFloatImage( 32 );
2867 
2868  SOLVE_TEMPLATE_REAL( __GET_INTENSITY_1 )
2869  }
2870  }
2871 
2872 #undef __GET_INTENSITY_1
2873 #undef __GET_INTENSITY_2
2874 
2875  // -------------------------------------------------------------------------
2876 
2877 #define __GET_LIGHTNESS_1( I ) \
2878  ImageVariant::GetLightness( L, static_cast<const pcl::I&>( **this ), rect, maxProcessors )
2879 
2880 #define __GET_LIGHTNESS_2( I ) \
2881  image.GetLightness( static_cast<pcl::I&>( *L ), rect, maxProcessors )
2882 
2883 private:
2884 
2885  template <class P> static
2886  void GetLightness( ImageVariant& L, const GenericImage<P>& image, const Rect& rect, int maxProcessors )
2887  {
2888  if ( !L.IsComplexSample() )
2889  SOLVE_TEMPLATE_REAL_2( L, __GET_LIGHTNESS_2 )
2890  }
2891 
2892 public:
2893 
2908  void GetLightness( ImageVariant& L, const Rect& rect = Rect( 0 ), int maxProcessors = 0 ) const
2909  {
2910  if ( *this )
2911  if ( !IsComplexSample() )
2912  {
2913  if ( !L )
2914  L.CreateFloatImage( ( BitsPerSample() < 32 ) ? 32 : ( IsFloatSample() ? BitsPerSample() : 64 ) );
2915 
2916  SOLVE_TEMPLATE_REAL( __GET_LIGHTNESS_1 )
2917  }
2918  }
2919 
2920 #undef __GET_LIGHTNESS_1
2921 #undef __GET_LIGHTNESS_2
2922 
2923  // -------------------------------------------------------------------------
2924 
2925 #define __GET_LUMINANCE_1( I ) \
2926  ImageVariant::GetLuminance( Y, static_cast<const pcl::I&>( **this ), rect, maxProcessors )
2927 
2928 #define __GET_LUMINANCE_2( I ) \
2929  image.GetLuminance( static_cast<pcl::I&>( *Y ), rect, maxProcessors )
2930 
2931 private:
2932 
2933  template <class P> static
2934  void GetLuminance( ImageVariant& Y, const GenericImage<P>& image, const Rect& rect, int maxProcessors )
2935  {
2936  if ( !Y.IsComplexSample() )
2937  SOLVE_TEMPLATE_REAL_2( Y, __GET_LUMINANCE_2 )
2938  }
2939 
2940 public:
2941 
2956  void GetLuminance( ImageVariant& Y, const Rect& rect = Rect( 0 ), int maxProcessors = 0 ) const
2957  {
2958  if ( *this )
2959  if ( !IsComplexSample() )
2960  {
2961  if ( !Y )
2962  Y.CreateFloatImage( ( BitsPerSample() < 32 ) ? 32 : ( IsFloatSample() ? BitsPerSample() : 64 ) );
2963 
2964  SOLVE_TEMPLATE_REAL( __GET_LUMINANCE_1 )
2965  }
2966  }
2967 
2968 #undef __GET_LUMINANCE_1
2969 #undef __GET_LUMINANCE_2
2970 
2971  // -------------------------------------------------------------------------
2972 
2973 #define __GET_ROW( I ) \
2974  static_cast<const pcl::I&>( **this ).GetRow( buffer, y, channel )
2975 
2982  template <typename T>
2983  void GetRow( T* buffer, int y, int channel = -1 ) const
2984  {
2985  PCL_PRECONDITION( buffer != 0 )
2986  if ( *this )
2987  SOLVE_TEMPLATE( __GET_ROW )
2988  }
2989 
2990 #undef __GET_ROW
2991 
2992  // -------------------------------------------------------------------------
2993 
2994 #define __INVERT( I ) \
2995  static_cast<pcl::I&>( **this ).Invert( scalar, rect, firstChannel, lastChannel )
2996 
3003  template <typename T>
3004  ImageVariant& Invert( T scalar, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
3005  {
3006  if ( *this )
3007  SOLVE_TEMPLATE_REAL( __INVERT )
3008  return *this;
3009  }
3010 
3011 #undef __INVERT
3012 
3013  // -------------------------------------------------------------------------
3014 
3015 #define __INVERT( I ) \
3016  static_cast<pcl::I&>( **this ).Invert( rect, firstChannel, lastChannel )
3017 
3025  ImageVariant& Invert( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
3026  {
3027  if ( *this )
3028  SOLVE_TEMPLATE_REAL( __INVERT )
3029  return *this;
3030  }
3031 
3032 #undef __INVERT
3033 
3034  // -------------------------------------------------------------------------
3035 
3036 #define __INVERTED( I ) \
3037  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Inverted( scalar, rect, firstChannel, lastChannel ) ) ); \
3038  result.SetOwnership( true )
3039 
3047  template <typename T>
3049  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
3050  {
3051  ImageVariant result;
3052  if ( *this )
3053  SOLVE_TEMPLATE( __INVERTED )
3054  return result;
3055  }
3056 
3057 #undef __INVERTED
3058 
3059  // -------------------------------------------------------------------------
3060 
3061 #define __INVERTED( I ) \
3062  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Inverted( rect, firstChannel, lastChannel ) ) ); \
3063  result.SetOwnership( true )
3064 
3073  ImageVariant Inverted( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
3074  {
3075  ImageVariant result;
3076  if ( *this )
3077  SOLVE_TEMPLATE( __INVERTED )
3078  return result;
3079  }
3080 
3081 #undef __INVERTED
3082 
3083  // -------------------------------------------------------------------------
3084 
3085 #ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
3086 
3087 #define __IS_SHARED_IMAGE( I ) \
3088  result = static_cast<const pcl::I&>( **this ).IsShared()
3089 
3098  bool IsSharedImage() const noexcept
3099  {
3100  bool result = false;
3101  if ( *this )
3102  SOLVE_TEMPLATE( __IS_SHARED_IMAGE )
3103  return result;
3104  }
3105 
3106 #undef __IS_SHARED_IMAGE
3107 
3108 #endif // !__PCL_BUILDING_PIXINSIGHT_APPLICATION
3109 
3110  // -------------------------------------------------------------------------
3111 
3112 #ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
3113 
3114 #define __SHARED_IMAGE_HANDLE( I ) \
3115  handle = static_cast<const pcl::I&>( **this ).Allocator().Handle()
3116 
3122  void* SharedImageHandle() const noexcept
3123  {
3124  void* handle = nullptr;
3125  if ( *this )
3126  SOLVE_TEMPLATE( __SHARED_IMAGE_HANDLE )
3127  return handle;
3128  }
3129 
3130 #undef __SHARED_IMAGE_HANDLE
3131 
3132 #endif // !__PCL_BUILDING_PIXINSIGHT_APPLICATION
3133 
3134  // -------------------------------------------------------------------------
3135 
3136 #define __IS_UNIQUE_IMAGE( I ) \
3137  result = static_cast<const pcl::I&>( **this ).IsUnique()
3138 
3148  bool IsUniqueImage() const noexcept
3149  {
3150  bool result = false;
3151  if ( *this )
3152  SOLVE_TEMPLATE( __IS_UNIQUE_IMAGE )
3153  return result;
3154  }
3155 
3156 #undef __IS_UNIQUE_IMAGE
3157 
3158  // -------------------------------------------------------------------------
3159 
3160 #define __LOCATE_EXTREME_SAMPLE_VALUES( I ) \
3161  static_cast<const pcl::I&>( **this ).LocateExtremeSampleValues( xmin, ymin, min, xmax, ymax, max, rect, firstChannel, lastChannel, maxProcessors )
3162 
3170  template <typename T>
3171  void LocateExtremeSampleValues( int& xmin, int& ymin, T& min,
3172  int& xmax, int& ymax, T& max,
3173  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
3174  int maxProcessors = 0 ) const
3175  {
3176  if ( *this )
3177  SOLVE_TEMPLATE_REAL( __LOCATE_EXTREME_SAMPLE_VALUES )
3178  }
3179 
3180 #undef __LOCATE_EXTREME_SAMPLE_VALUES
3181 
3182  // -------------------------------------------------------------------------
3183 
3184 #define __LOCATE_EXTREME_SAMPLE_VALUES( I ) \
3185  static_cast<const pcl::I&>( **this ).LocateExtremeSampleValues( pmin, min, pmax, max, rect, firstChannel, lastChannel, maxProcessors )
3186 
3194  template <typename T>
3195  void LocateExtremeSampleValues( Point& pmin, T& min,
3196  Point& pmax, T& max,
3197  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
3198  int maxProcessors = 0 ) const
3199  {
3200  if ( *this )
3201  SOLVE_TEMPLATE_REAL( __LOCATE_EXTREME_SAMPLE_VALUES )
3202  }
3203 
3204 #undef __LOCATE_EXTREME_SAMPLE_VALUES
3205 
3206  // -------------------------------------------------------------------------
3207 
3208 #define __LOCATE_MAXIMUM_SAMPLE_VALUE( I ) \
3209  pcl::I::pixel_traits::FromSample( result, static_cast<const pcl::I&>( **this ).LocateMaximumSampleValue( xmax, ymax, rect, firstChannel, lastChannel, maxProcessors ) )
3210 
3218  double LocateMaximumSampleValue( int& xmax, int& ymax,
3219  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
3220  int maxProcessors = 0 ) const
3221  {
3222  double result = 0;
3223  if ( *this )
3224  SOLVE_TEMPLATE( __LOCATE_MAXIMUM_SAMPLE_VALUE )
3225  return result;
3226  }
3227 
3228 #undef __LOCATE_MAXIMUM_SAMPLE_VALUE
3229 
3230  // -------------------------------------------------------------------------
3231 
3232 #define __LOCATE_MAXIMUM_SAMPLE_VALUE( I ) \
3233  pcl::I::pixel_traits::FromSample( result, static_cast<const pcl::I&>( **this ).LocateMaximumSampleValue( pmax, rect, firstChannel, lastChannel, maxProcessors ) )
3234 
3243  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
3244  int maxProcessors = 0 ) const
3245  {
3246  double result = 0;
3247  if ( *this )
3248  SOLVE_TEMPLATE( __LOCATE_MAXIMUM_SAMPLE_VALUE )
3249  return result;
3250  }
3251 
3252 #undef __LOCATE_MAXIMUM_SAMPLE_VALUE
3253 
3254  // -------------------------------------------------------------------------
3255 
3256 #define __LOCATE_MINIMUM_SAMPLE_VALUE( I ) \
3257  pcl::I::pixel_traits::FromSample( result, static_cast<const pcl::I&>( **this ).LocateMinimumSampleValue( xmin, ymin, rect, firstChannel, lastChannel, maxProcessors ) )
3258 
3266  double LocateMinimumSampleValue( int& xmin, int& ymin,
3267  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
3268  int maxProcessors = 0 ) const
3269  {
3270  double result = 0;
3271  if ( *this )
3272  SOLVE_TEMPLATE( __LOCATE_MINIMUM_SAMPLE_VALUE )
3273  return result;
3274  }
3275 
3276 #undef __LOCATE_MINIMUM_SAMPLE_VALUE
3277 
3278  // -------------------------------------------------------------------------
3279 
3280 #define __LOCATE_MINIMUM_SAMPLE_VALUE( I ) \
3281  pcl::I::pixel_traits::FromSample( result, static_cast<const pcl::I&>( **this ).LocateMinimumSampleValue( pmin, rect, firstChannel, lastChannel, maxProcessors ) )
3282 
3291  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
3292  int maxProcessors = 0 ) const
3293  {
3294  double result = 0;
3295  if ( *this )
3296  SOLVE_TEMPLATE( __LOCATE_MINIMUM_SAMPLE_VALUE )
3297  return result;
3298  }
3299 
3300 #undef __LOCATE_MINIMUM_SAMPLE_VALUE
3301 
3302  // -------------------------------------------------------------------------
3303 
3304 #define __MAD( I ) \
3305  result = static_cast<const pcl::I&>( **this ).MAD( center, rect, firstChannel, lastChannel, maxProcessors )
3306 
3313  double MAD( double center,
3314  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
3315  int maxProcessors = 0 ) const
3316  {
3317  double result = 0;
3318  if ( *this )
3319  SOLVE_TEMPLATE( __MAD )
3320  return result;
3321  }
3322 
3323 #undef __MAD
3324 
3325 // -------------------------------------------------------------------------
3326 
3327 #define __2SIDED_MAD( I ) \
3328  result = static_cast<const pcl::I&>( **this ).TwoSidedMAD( center, rect, firstChannel, lastChannel, maxProcessors )
3329 
3338  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
3339  int maxProcessors = 0 ) const
3340  {
3341  TwoSidedEstimate result( 0 );
3342  if ( *this )
3343  SOLVE_TEMPLATE( __2SIDED_MAD )
3344  return result;
3345  }
3346 
3347 #undef __2SIDED_MAD
3348 
3349 // -------------------------------------------------------------------------
3350 
3351 #define __MAXIMUM( I ) \
3352  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Maximum( scalar, rect, firstChannel, lastChannel ) ) ); \
3353  result.SetOwnership( true )
3354 
3362  template <typename T>
3364  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
3365  {
3366  ImageVariant result;
3367  if ( *this )
3368  SOLVE_TEMPLATE( __MAXIMUM )
3369  return result;
3370  }
3371 
3372 #undef __MAXIMUM
3373 
3374  // -------------------------------------------------------------------------
3375 
3376 #define __MAXIMUM_SAMPLE_VALUE( I ) \
3377  pcl::I::pixel_traits::FromSample( result, static_cast<const pcl::I&>( **this ).MaximumSampleValue( rect, firstChannel, lastChannel, maxProcessors ) )
3378 
3385  double MaximumSampleValue( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
3386  int maxProcessors = 0 ) const
3387  {
3388  double result = 0;
3389  if ( *this )
3390  SOLVE_TEMPLATE( __MAXIMUM_SAMPLE_VALUE )
3391  return result;
3392  }
3393 
3394 #undef __MAXIMUM_SAMPLE_VALUE
3395 
3396  // -------------------------------------------------------------------------
3397 
3398 #define __MEAN( I ) \
3399  result = static_cast<const pcl::I&>( **this ).Mean( rect, firstChannel, lastChannel, maxProcessors )
3400 
3406  double Mean( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
3407  int maxProcessors = 0 ) const
3408  {
3409  double result = 0;
3410  if ( *this )
3411  SOLVE_TEMPLATE( __MEAN )
3412  return result;
3413  }
3414 
3415 #undef __MEAN
3416 
3417  // -------------------------------------------------------------------------
3418 
3419 #define __MEAN_OF_SQUARES( I ) \
3420  result = static_cast<const pcl::I&>( **this ).MeanOfSquares( rect, firstChannel, lastChannel, maxProcessors )
3421 
3428  double MeanOfSquares( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
3429  int maxProcessors = 0 ) const
3430  {
3431  double result = 0;
3432  if ( *this )
3433  SOLVE_TEMPLATE( __MEAN_OF_SQUARES )
3434  return result;
3435  }
3436 
3437 #undef __MEAN_OF_SQUARES
3438 
3439  // -------------------------------------------------------------------------
3440 
3441 #define __MEDIAN( I ) \
3442  result = static_cast<const pcl::I&>( **this ).Median( rect, firstChannel, lastChannel, maxProcessors )
3443 
3449  double Median( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
3450  int maxProcessors = 0 ) const
3451  {
3452  double result = 0;
3453  if ( *this )
3454  SOLVE_TEMPLATE( __MEDIAN )
3455  return result;
3456  }
3457 
3458 #undef __MEDIAN
3459 
3460  // -------------------------------------------------------------------------
3461 
3462 #define __ORDER_STATISTIC( I ) \
3463  result = static_cast<const pcl::I&>( **this ).OrderStatistic( k, rect, firstChannel, lastChannel, maxProcessors )
3464 
3470  double OrderStatistic( double k,
3471  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
3472  int maxProcessors = 0 ) const
3473  {
3474  double result = 0;
3475  if ( *this )
3476  SOLVE_TEMPLATE( __ORDER_STATISTIC )
3477  return result;
3478  }
3479 
3480 #undef __ORDER_STATISTIC
3481 
3482  // -------------------------------------------------------------------------
3483 
3484 #define __MINIMUM( I ) \
3485  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Minimum( scalar, rect, firstChannel, lastChannel ) ) ); \
3486  result.SetOwnership( true )
3487 
3495  template <typename T>
3497  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
3498  {
3499  ImageVariant result;
3500  if ( *this )
3501  SOLVE_TEMPLATE( __MINIMUM )
3502  return result;
3503  }
3504 
3505 #undef __MINIMUM
3506 
3507  // -------------------------------------------------------------------------
3508 
3509 #define __MINIMUM_SAMPLE_VALUE( I ) \
3510  pcl::I::pixel_traits::FromSample( result, static_cast<const pcl::I&>( **this ).MinimumSampleValue( rect, firstChannel, lastChannel, maxProcessors ) )
3511 
3518  double MinimumSampleValue( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
3519  int maxProcessors = 0 ) const
3520  {
3521  double result = 0;
3522  if ( *this )
3523  SOLVE_TEMPLATE( __MINIMUM_SAMPLE_VALUE )
3524  return result;
3525  }
3526 
3527 #undef __MINIMUM_SAMPLE_VALUE
3528 
3529  // -------------------------------------------------------------------------
3530 
3531 #define __MODULUS( I ) \
3532  result = static_cast<const pcl::I&>( **this ).Modulus( rect, firstChannel, lastChannel, maxProcessors )
3533 
3540  double Modulus( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
3541  int maxProcessors = 0 ) const
3542  {
3543  double result = 0;
3544  if ( *this )
3545  SOLVE_TEMPLATE( __MODULUS )
3546  return result;
3547  }
3548 
3549 #undef __MODULUS
3550 
3551  // -------------------------------------------------------------------------
3552 
3553 #define __MOVE( I ) \
3554  static_cast<pcl::I&>( **this ).Move( scalar, rect, firstChannel, lastChannel )
3555 
3562  template <typename T>
3563  ImageVariant& Move( T scalar,
3564  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
3565  {
3566  if ( *this )
3567  SOLVE_TEMPLATE( __MOVE )
3568  return *this;
3569  }
3570 
3571 #undef __MOVE
3572 
3576  template <typename T>
3577  ImageVariant& Mov( T scalar, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
3578  {
3579  return Move( scalar, rect, firstChannel, lastChannel );
3580  }
3581 
3582  // -------------------------------------------------------------------------
3583 
3584 #define __MOVE_1( I ) \
3585  ImageVariant::Move( static_cast<pcl::I&>( **this ), image, point, channel, rect, firstChannel, lastChannel )
3586 
3587 #define __MOVE_2( I ) \
3588  image1.Move( static_cast<const pcl::I&>( *image2 ), point, channel, rect, firstChannel, lastChannel )
3589 
3590 private:
3591 
3592  template <class P> static
3593  void Move( GenericImage<P>& image1, const ImageVariant& image2,
3594  const Point& point, int channel,
3595  const Rect& rect, int firstChannel, int lastChannel )
3596  {
3597  SOLVE_TEMPLATE_2( image2, __MOVE_2 )
3598  }
3599 
3600 public:
3601 
3609  const Point& point = Point( int_max ), int channel = -1,
3610  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
3611  {
3612  if ( *this )
3613  if ( image )
3614  SOLVE_TEMPLATE( __MOVE_1 )
3615  return *this;
3616  }
3617 
3618 #undef __MOVE_1
3619 #undef __MOVE_2
3620 
3621  ImageVariant& Mov( const ImageVariant& image,
3622  const Point& point = Point( int_max ), int channel = -1,
3623  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
3624  {
3625  return Move( image, point, channel, rect, firstChannel, lastChannel );
3626  }
3627 
3628  // -------------------------------------------------------------------------
3629 
3630 #define __MULTIPLY( I ) \
3631  static_cast<pcl::I&>( **this ).Multiply( scalar, rect, firstChannel, lastChannel )
3632 
3640  template <typename T>
3642  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
3643  {
3644  if ( *this )
3645  SOLVE_TEMPLATE( __MULTIPLY )
3646  return *this;
3647  }
3648 
3649 #undef __MULTIPLY
3650 
3654  template <typename T>
3655  ImageVariant& Mul( T scalar,
3656  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
3657  {
3658  return Multiply( scalar, rect, firstChannel, lastChannel );
3659  }
3660 
3661  // -------------------------------------------------------------------------
3662 
3663 #define __MULTIPLY_1( I ) \
3664  ImageVariant::Multiply( static_cast<pcl::I&>( **this ), image, point, channel, rect, firstChannel, lastChannel )
3665 
3666 #define __MULTIPLY_2( I ) \
3667  image1.Multiply( static_cast<const pcl::I&>( *image2 ), point, channel, rect, firstChannel, lastChannel )
3668 
3669 private:
3670 
3671  template <class P> static
3672  void Multiply( GenericImage<P>& image1, const ImageVariant& image2,
3673  const Point& point, int channel,
3674  const Rect& rect, int firstChannel, int lastChannel )
3675  {
3676  SOLVE_TEMPLATE_2( image2, __MULTIPLY_2 )
3677  }
3678 
3679 public:
3680 
3689  const Point& point = Point( int_max ), int channel = -1,
3690  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
3691  {
3692  if ( *this )
3693  if ( image )
3694  SOLVE_TEMPLATE( __MULTIPLY_1 )
3695  return *this;
3696  }
3697 
3698 #undef __MULTIPLY_1
3699 #undef __MULTIPLY_2
3700 
3705  const Point& point = Point( int_max ), int channel = -1,
3706  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
3707  {
3708  return Multiply( image, point, channel, rect, firstChannel, lastChannel );
3709  }
3710 
3711  // -------------------------------------------------------------------------
3712 
3713 #define __MULTIPLIED( I ) \
3714  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Multiplied( scalar, rect, firstChannel, lastChannel ) ) ); \
3715  result.SetOwnership( true )
3716 
3724  template <typename T>
3726  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
3727  {
3728  ImageVariant result;
3729  if ( *this )
3730  SOLVE_TEMPLATE( __MULTIPLIED )
3731  return result;
3732  }
3733 
3734 #undef __MULTIPLIED
3735 
3736  // -------------------------------------------------------------------------
3737 
3738 #define __NAND( I ) \
3739  static_cast<pcl::I&>( **this ).Nand( scalar, rect, firstChannel, lastChannel )
3740 
3748  template <typename T>
3749  ImageVariant& Nand( T scalar,
3750  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
3751  {
3752  if ( *this )
3753  SOLVE_TEMPLATE_REAL( __NAND )
3754  return *this;
3755  }
3756 
3757 #undef __NAND
3758 
3759  // -------------------------------------------------------------------------
3760 
3761 #define __NAND_1( I ) \
3762  ImageVariant::Nand( static_cast<pcl::I&>( **this ), image, point, channel, rect, firstChannel, lastChannel )
3763 
3764 #define __NAND_2( I ) \
3765  image1.Nand( static_cast<const pcl::I&>( *image2 ), point, channel, rect, firstChannel, lastChannel )
3766 
3767 private:
3768 
3769  template <class P> static
3770  void Nand( GenericImage<P>& image1, const ImageVariant& image2,
3771  const Point& point, int channel,
3772  const Rect& rect, int firstChannel, int lastChannel )
3773  {
3774  SOLVE_TEMPLATE_REAL_2( image2, __NAND_2 )
3775  }
3776 
3777 public:
3778 
3787  const Point& point = Point( int_max ), int channel = -1,
3788  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
3789  {
3790  if ( *this )
3791  if ( image )
3792  SOLVE_TEMPLATE_REAL( __NAND_1 )
3793  return *this;
3794  }
3795 
3796 #undef __NAND_1
3797 #undef __NAND_2
3798 
3799  // -------------------------------------------------------------------------
3800 
3801 #define __NOR( I ) \
3802  static_cast<pcl::I&>( **this ).Nor( scalar, rect, firstChannel, lastChannel )
3803 
3811  template <typename T>
3812  ImageVariant& Nor( T scalar,
3813  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
3814  {
3815  if ( *this )
3816  SOLVE_TEMPLATE_REAL( __NOR )
3817  return *this;
3818  }
3819 
3820 #undef __NOR
3821 
3822  // -------------------------------------------------------------------------
3823 
3824 #define __NOR_1( I ) \
3825  ImageVariant::Nor( static_cast<pcl::I&>( **this ), image, point, channel, rect, firstChannel, lastChannel )
3826 
3827 #define __NOR_2( I ) \
3828  image1.Nor( static_cast<const pcl::I&>( *image2 ), point, channel, rect, firstChannel, lastChannel )
3829 
3830 private:
3831 
3832  template <class P> static
3833  void Nor( GenericImage<P>& image1, const ImageVariant& image2,
3834  const Point& point, int channel,
3835  const Rect& rect, int firstChannel, int lastChannel )
3836  {
3837  SOLVE_TEMPLATE_REAL_2( image2, __NOR_2 )
3838  }
3839 
3840 public:
3841 
3850  const Point& point = Point( int_max ), int channel = -1,
3851  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
3852  {
3853  if ( *this )
3854  if ( image )
3855  SOLVE_TEMPLATE_REAL( __NOR_1 )
3856  return *this;
3857  }
3858 
3859 #undef __NOR_1
3860 #undef __NOR_2
3861 
3862  // -------------------------------------------------------------------------
3863 
3864 #define __NORM( I ) \
3865  result = static_cast<const pcl::I&>( **this ).Norm( rect, firstChannel, lastChannel, maxProcessors )
3866 
3873  double Norm( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
3874  int maxProcessors = 0 ) const
3875  {
3876  double result = 0;
3877  if ( *this )
3878  SOLVE_TEMPLATE( __NORM )
3879  return result;
3880  }
3881 
3882 #undef __NORM
3883 
3884  // -------------------------------------------------------------------------
3885 
3886 #define __NORMALIZE( I ) \
3887  static_cast<pcl::I&>( **this ).Normalize( lowerBound, upperBound, rect, firstChannel, lastChannel )
3888 
3896  template <typename T>
3897  ImageVariant& Normalize( T lowerBound, T upperBound,
3898  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
3899  {
3900  if ( *this )
3901  SOLVE_TEMPLATE_REAL( __NORMALIZE )
3902  return *this;
3903  }
3904 
3905 #undef __NORMALIZE
3906 
3907  // -------------------------------------------------------------------------
3908 
3909 #define __NORMALIZE( I ) \
3910  static_cast<pcl::I&>( **this ).Normalize( rect, firstChannel, lastChannel )
3911 
3919  ImageVariant& Normalize( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
3920  {
3921  if ( *this )
3922  SOLVE_TEMPLATE_REAL( __NORMALIZE )
3923  return *this;
3924  }
3925 
3926 #undef __NORMALIZE
3927 
3928  // -------------------------------------------------------------------------
3929 
3930 #define __NORMALIZED( I ) \
3931  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Normalized( lowerBound, upperBound, rect, firstChannel, lastChannel ) ) ); \
3932  result.SetOwnership( true )
3933 
3941  template <typename T>
3942  ImageVariant Normalized( T lowerBound, T upperBound,
3943  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
3944  {
3945  ImageVariant result;
3946  if ( *this )
3947  SOLVE_TEMPLATE_REAL( __NORMALIZED )
3948  return result;
3949  }
3950 
3951 #undef __NORMALIZED
3952 
3953  // -------------------------------------------------------------------------
3954 
3955 #define __NORMALIZED( I ) \
3956  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Normalized( rect, firstChannel, lastChannel ) ) ); \
3957  result.SetOwnership( true )
3958 
3966  ImageVariant Normalized( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
3967  {
3968  ImageVariant result;
3969  if ( *this )
3970  SOLVE_TEMPLATE_REAL( __NORMALIZED )
3971  return result;
3972  }
3973 
3974 #undef __NORMALIZED
3975 
3976  // -------------------------------------------------------------------------
3977 
3978 #define __NOT( I ) \
3979  static_cast<pcl::I&>( **this ).Not( rect, firstChannel, lastChannel )
3980 
3987  ImageVariant& Not( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
3988  {
3989  if ( *this )
3990  SOLVE_TEMPLATE_REAL( __NOT )
3991  return *this;
3992  }
3993 
3994 #undef __NOT
3995 
3996  // -------------------------------------------------------------------------
3997 
3998 #define __ONE( I ) \
3999  static_cast<pcl::I&>( **this ).One( rect, firstChannel, lastChannel )
4000 
4008  ImageVariant& One( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4009  {
4010  if ( *this )
4011  SOLVE_TEMPLATE_REAL( __ONE )
4012  return *this;
4013  }
4014 
4015 #undef __ONE
4016 
4017  // -------------------------------------------------------------------------
4018 
4019 #define __MULTIPLY( I ) \
4020  static_cast<pcl::I&>( **this ) *= scalar
4021 
4025  template <typename T>
4026  ImageVariant& operator *=( T scalar )
4027  {
4028  if ( *this )
4029  SOLVE_TEMPLATE( __MULTIPLY )
4030  return *this;
4031  }
4032 
4033 #undef __MULTIPLY
4034 
4035  // -------------------------------------------------------------------------
4036 
4037 #define __MULTIPLY_1( I ) \
4038  ImageVariant::Multiply( static_cast<pcl::I&>( **this ), image )
4039 
4040 #define __MULTIPLY_2( I ) \
4041  image1 *= static_cast<const pcl::I&>( *image2 )
4042 
4043 private:
4044 
4045  template <class P> static
4046  void Multiply( GenericImage<P>& image1, const ImageVariant& image2 )
4047  {
4048  SOLVE_TEMPLATE_2( image2, __MULTIPLY_2 )
4049  }
4050 
4051 public:
4052 
4056  ImageVariant& operator *=( const ImageVariant& image )
4057  {
4058  if ( *this )
4059  if ( image )
4060  SOLVE_TEMPLATE( __MULTIPLY_1 )
4061  return *this;
4062  }
4063 
4064 #undef __MULTIPLY_1
4065 #undef __MULTIPLY_2
4066 
4067  // -------------------------------------------------------------------------
4068 
4069 #define __ADD( I ) \
4070  static_cast<pcl::I&>( **this ) += scalar
4071 
4075  template <typename T>
4076  ImageVariant& operator +=( T scalar )
4077  {
4078  if ( *this )
4079  SOLVE_TEMPLATE( __ADD )
4080  return *this;
4081  }
4082 
4083 #undef __ADD
4084 
4085  // -------------------------------------------------------------------------
4086 
4087 #define __ADD_1( I ) \
4088  ImageVariant::Add( static_cast<pcl::I&>( **this ), image )
4089 
4090 #define __ADD_2( I ) \
4091  image1 += static_cast<const pcl::I&>( *image2 )
4092 
4093 private:
4094 
4095  template <class P> static
4096  void Add( GenericImage<P>& image1, const ImageVariant& image2 )
4097  {
4098  SOLVE_TEMPLATE_2( image2, __ADD_2 )
4099  }
4100 
4101 public:
4102 
4106  ImageVariant& operator +=( const ImageVariant& image )
4107  {
4108  if ( *this )
4109  if ( image )
4110  SOLVE_TEMPLATE( __ADD_1 )
4111  return *this;
4112  }
4113 
4114 #undef __ADD_1
4115 #undef __ADD_2
4116 
4117  // -------------------------------------------------------------------------
4118 
4119 #define __SUBTRACT( I ) \
4120  static_cast<pcl::I&>( **this ) -= scalar
4121 
4125  template <typename T>
4126  ImageVariant& operator -=( T scalar )
4127  {
4128  if ( *this )
4129  SOLVE_TEMPLATE( __SUBTRACT )
4130  return *this;
4131  }
4132 
4133 #undef __SUBTRACT
4134 
4135  // -------------------------------------------------------------------------
4136 
4137 #define __SUBTRACT_1( I ) \
4138  ImageVariant::Subtract( static_cast<pcl::I&>( **this ), image )
4139 
4140 #define __SUBTRACT_2( I ) \
4141  image1 -= static_cast<const pcl::I&>( *image2 )
4142 
4143 private:
4144 
4145  template <class P> static
4146  void Subtract( GenericImage<P>& image1, const ImageVariant& image2 )
4147  {
4148  SOLVE_TEMPLATE_2( image2, __SUBTRACT_2 )
4149  }
4150 
4151 public:
4152 
4156  ImageVariant& operator -=( const ImageVariant& image )
4157  {
4158  if ( *this )
4159  if ( image )
4160  SOLVE_TEMPLATE( __SUBTRACT_1 )
4161  return *this;
4162  }
4163 
4164 #undef __SUBTRACT_1
4165 #undef __SUBTRACT_2
4166 
4167  // -------------------------------------------------------------------------
4168 
4169 #define __DIVIDE( I ) \
4170  static_cast<pcl::I&>( **this ) /= scalar
4171 
4175  template <typename T>
4176  ImageVariant& operator /=( T scalar )
4177  {
4178  if ( *this )
4179  SOLVE_TEMPLATE( __DIVIDE )
4180  return *this;
4181  }
4182 
4183 #undef __DIVIDE
4184 
4185  // -------------------------------------------------------------------------
4186 
4187 #define __DIVIDE_1( I ) \
4188  ImageVariant::Divide( static_cast<pcl::I&>( **this ), image )
4189 
4190 #define __DIVIDE_2( I ) \
4191  image1 /= static_cast<const pcl::I&>( *image2 )
4192 
4193 private:
4194 
4195  template <class P> static
4196  void Divide( GenericImage<P>& image1, const ImageVariant& image2 )
4197  {
4198  SOLVE_TEMPLATE_2( image2, __DIVIDE_2 )
4199  }
4200 
4201 public:
4202 
4206  ImageVariant& operator /=( const ImageVariant& image )
4207  {
4208  if ( *this )
4209  if ( image )
4210  SOLVE_TEMPLATE( __DIVIDE_1 )
4211  return *this;
4212  }
4213 
4214 #undef __DIVIDE_1
4215 #undef __DIVIDE_2
4216 
4217  // -------------------------------------------------------------------------
4218 
4219 #define __RAISE( I ) \
4220  static_cast<pcl::I&>( **this ) ^= scalar
4221 
4225  template <typename T>
4226  ImageVariant& operator ^=( T scalar )
4227  {
4228  if ( *this )
4229  SOLVE_TEMPLATE( __RAISE )
4230  return *this;
4231  }
4232 
4233 #undef __RAISE
4234 
4235  // -------------------------------------------------------------------------
4236 
4237 #define __RAISE_1( I ) \
4238  ImageVariant::Raise( static_cast<pcl::I&>( **this ), image )
4239 
4240 #define __RAISE_2( I ) \
4241  image1 ^= static_cast<const pcl::I&>( *image2 )
4242 
4243 private:
4244 
4245  template <class P> static
4246  void Raise( GenericImage<P>& image1, const ImageVariant& image2 )
4247  {
4248  SOLVE_TEMPLATE_2( image2, __RAISE_2 )
4249  }
4250 
4251 public:
4252 
4256  ImageVariant& operator ^=( const ImageVariant& image )
4257  {
4258  if ( *this )
4259  if ( image )
4260  SOLVE_TEMPLATE( __RAISE_1 )
4261  return *this;
4262  }
4263 
4264 #undef __RAISE_1
4265 #undef __RAISE_2
4266 
4267  // -------------------------------------------------------------------------
4268 
4269 #define __INVERTED( I ) \
4270  result.SetImage( *new pcl::I( ~static_cast<const pcl::I&>( **this ) ) ); \
4271  result.SetOwnership( true )
4272 
4281  ImageVariant operator ~() const
4282  {
4283  ImageVariant result;
4284  if ( *this )
4285  SOLVE_TEMPLATE( __INVERTED )
4286  return result;
4287  }
4288 
4289 #undef __INVERTED
4290 
4291  // -------------------------------------------------------------------------
4292 
4293 #define __OR( I ) \
4294  static_cast<pcl::I&>( **this ).Or( scalar, rect, firstChannel, lastChannel )
4295 
4303  template <typename T>
4304  ImageVariant& Or( T scalar, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4305  {
4306  if ( *this )
4307  SOLVE_TEMPLATE_REAL( __OR )
4308  return *this;
4309  }
4310 
4311 #undef __OR
4312 
4313  // -------------------------------------------------------------------------
4314 
4315 #define __OR_1( I ) \
4316  ImageVariant::Or( static_cast<pcl::I&>( **this ), image, point, channel, rect, firstChannel, lastChannel )
4317 
4318 #define __OR_2( I ) \
4319  image1.Or( static_cast<const pcl::I&>( *image2 ), point, channel, rect, firstChannel, lastChannel )
4320 
4321 private:
4322 
4323  template <class P> static
4324  void Or( GenericImage<P>& image1, const ImageVariant& image2,
4325  const Point& point, int channel,
4326  const Rect& rect, int firstChannel, int lastChannel )
4327  {
4328  SOLVE_TEMPLATE_REAL_2( image2, __OR_2 )
4329  }
4330 
4331 public:
4332 
4340  ImageVariant& Or( const ImageVariant& image,
4341  const Point& point = Point( int_max ), int channel = -1,
4342  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4343  {
4344  if ( *this )
4345  if ( image )
4346  SOLVE_TEMPLATE_REAL( __OR_1 )
4347  return *this;
4348  }
4349 
4350 #undef __OR_1
4351 #undef __OR_2
4352 
4353  // -------------------------------------------------------------------------
4354 
4355 #define __RAISE( I ) \
4356  static_cast<pcl::I&>( **this ).Raise( scalar, rect, firstChannel, lastChannel )
4357 
4364  template <typename T>
4365  ImageVariant& Raise( T scalar,
4366  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4367  {
4368  if ( *this )
4369  SOLVE_TEMPLATE( __RAISE )
4370  return *this;
4371  }
4372 
4373 #undef __RAISE
4374 
4378  template <typename T>
4379  ImageVariant& Pow( T scalar,
4380  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4381  {
4382  return Raise( scalar, rect, firstChannel, lastChannel );
4383  }
4384 
4385  // -------------------------------------------------------------------------
4386 
4387 #define __Qn( I ) \
4388  result = static_cast<const pcl::I&>( **this ).Qn( rect, firstChannel, lastChannel, maxProcessors )
4389 
4396  double Qn( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
4397  int maxProcessors = 0 ) const
4398  {
4399  double result = false;
4400  if ( *this )
4401  SOLVE_TEMPLATE( __Qn )
4402  return result;
4403  }
4404 
4405 #undef __Qn
4406 
4407  // -------------------------------------------------------------------------
4408 
4409 #define __RAISE_1( I ) \
4410  ImageVariant::Raise( static_cast<pcl::I&>( **this ), image, point, channel, rect, firstChannel, lastChannel )
4411 
4412 #define __RAISE_2( I ) \
4413  image1.Raise( static_cast<const pcl::I&>( *image2 ), point, channel, rect, firstChannel, lastChannel )
4414 
4415 private:
4416 
4417  template <class P> static
4418  void Raise( GenericImage<P>& image1, const ImageVariant& image2,
4419  const Point& point, int channel,
4420  const Rect& rect, int firstChannel, int lastChannel )
4421  {
4422  SOLVE_TEMPLATE_2( image2, __RAISE_2 )
4423  }
4424 
4425 public:
4426 
4435  const Point& point = Point( int_max ), int channel = -1,
4436  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4437  {
4438  if ( *this )
4439  if ( image )
4440  SOLVE_TEMPLATE( __RAISE_1 )
4441  return *this;
4442  }
4443 
4444 #undef __RAISE_1
4445 #undef __RAISE_2
4446 
4451  const Point& point = Point( int_max ), int channel = -1,
4452  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4453  {
4454  return Raise( image, point, channel, rect, firstChannel, lastChannel );
4455  }
4456 
4457  // -------------------------------------------------------------------------
4458 
4459 #define __RAISED( I ) \
4460  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Raised( scalar, rect, firstChannel, lastChannel ) ) ); \
4461  result.SetOwnership( true )
4462 
4469  template <typename T>
4471  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
4472  {
4473  ImageVariant result;
4474  if ( *this )
4475  SOLVE_TEMPLATE( __RAISED )
4476  return result;
4477  }
4478 
4479 #undef __RAISED
4480 
4481  // -------------------------------------------------------------------------
4482 
4483 #define __READ( I ) \
4484  static_cast<pcl::I&>( **this ).Read( file )
4485 
4493  {
4494  if ( *this )
4495  SOLVE_TEMPLATE( __READ )
4496  return *this;
4497  }
4498 
4499 #undef __READ
4500 
4501  // -------------------------------------------------------------------------
4502 
4503 #define __READ( I ) \
4504  static_cast<pcl::I&>( **this ).Read( filePath )
4505 
4512  ImageVariant& Read( const String& filePath )
4513  {
4514  if ( *this )
4515  SOLVE_TEMPLATE( __READ )
4516  return *this;
4517  }
4518 
4519 #undef __READ
4520 
4521  // -------------------------------------------------------------------------
4522 
4523 #define __RESCALE( I ) \
4524  static_cast<pcl::I&>( **this ).Rescale( lowerBound, upperBound, rect, firstChannel, lastChannel )
4525 
4532  template <typename T>
4533  ImageVariant& Rescale( T lowerBound, T upperBound,
4534  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4535  {
4536  if ( *this )
4537  SOLVE_TEMPLATE_REAL( __RESCALE )
4538  return *this;
4539  }
4540 
4541 #undef __RESCALE
4542 
4543  // -------------------------------------------------------------------------
4544 
4545 #define __RESCALE( I ) \
4546  static_cast<pcl::I&>( **this ).Rescale( rect, firstChannel, lastChannel )
4547 
4554  ImageVariant& Rescale( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4555  {
4556  if ( *this )
4557  SOLVE_TEMPLATE_REAL( __RESCALE )
4558  return *this;
4559  }
4560 
4561 #undef __RESCALE
4562 
4563  // -------------------------------------------------------------------------
4564 
4565 #define __RESCALED( I ) \
4566  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Rescaled( lowerBound, upperBound, rect, firstChannel, lastChannel ) ) ); \
4567  result.SetOwnership( true )
4568 
4576  template <typename T>
4577  ImageVariant Rescaled( T lowerBound, T upperBound,
4578  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
4579  {
4580  ImageVariant result;
4581  if ( *this )
4582  SOLVE_TEMPLATE_REAL( __RESCALED )
4583  return result;
4584  }
4585 
4586 #undef __RESCALED
4587 
4588  // -------------------------------------------------------------------------
4589 
4590 #define __RESCALED( I ) \
4591  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Rescaled( rect, firstChannel, lastChannel ) ) ); \
4592  result.SetOwnership( true )
4593 
4601  ImageVariant Rescaled( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
4602  {
4603  ImageVariant result;
4604  if ( *this )
4605  SOLVE_TEMPLATE_REAL( __RESCALED )
4606  return result;
4607  }
4608 
4609 #undef __RESCALED
4610 
4611  // -------------------------------------------------------------------------
4612 
4613 #define __SET_ABSOLUTE_DIFFERENCE( I ) \
4614  static_cast<pcl::I&>( **this ).SetAbsoluteDifference( scalar, rect, firstChannel, lastChannel )
4615 
4624  template <typename T>
4626  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4627  {
4628  if ( *this )
4629  SOLVE_TEMPLATE( __SET_ABSOLUTE_DIFFERENCE )
4630  return *this;
4631  }
4632 
4633 #undef __SET_ABSOLUTE_DIFFERENCE
4634 
4638  template <typename T>
4639  ImageVariant& Dif( T scalar,
4640  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4641  {
4642  return SetAbsoluteDifference( scalar, rect, firstChannel, lastChannel );
4643  }
4644 
4645  // -------------------------------------------------------------------------
4646 
4647 #define __SET_ABSOLUTE_DIFFERENCE_1( I ) \
4648  ImageVariant::SetAbsoluteDifference( static_cast<pcl::I&>( **this ), image, point, channel, rect, firstChannel, lastChannel )
4649 
4650 #define __SET_ABSOLUTE_DIFFERENCE_2( I ) \
4651  image1.SetAbsoluteDifference( static_cast<const pcl::I&>( *image2 ), point, channel, rect, firstChannel, lastChannel )
4652 
4653 private:
4654 
4655  template <class P> static
4656  void SetAbsoluteDifference( GenericImage<P>& image1, const ImageVariant& image2,
4657  const Point& point, int channel,
4658  const Rect& rect, int firstChannel, int lastChannel )
4659  {
4660  SOLVE_TEMPLATE_2( image2, __SET_ABSOLUTE_DIFFERENCE_2 )
4661  }
4662 
4663 public:
4664 
4674  const Point& point = Point( int_max ), int channel = -1,
4675  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4676  {
4677  if ( *this )
4678  if ( image )
4679  SOLVE_TEMPLATE( __SET_ABSOLUTE_DIFFERENCE_1 )
4680  return *this;
4681  }
4682 
4683 #undef __SET_ABSOLUTE_DIFFERENCE_1
4684 #undef __SET_ABSOLUTE_DIFFERENCE_2
4685 
4686  ImageVariant& Dif( const ImageVariant& image,
4687  const Point& point = Point( int_max ), int channel = -1,
4688  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4689  {
4690  return SetAbsoluteDifference( image, point, channel, rect, firstChannel, lastChannel );
4691  }
4692 
4693  // -------------------------------------------------------------------------
4694 
4695 #define __SET_ABSOLUTE_VALUE( I ) \
4696  static_cast<pcl::I&>( **this ).SetAbsoluteValue( rect, firstChannel, lastChannel )
4697 
4705  ImageVariant& SetAbsoluteValue( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4706  {
4707  if ( *this )
4708  SOLVE_TEMPLATE( __SET_ABSOLUTE_VALUE )
4709  return *this;
4710  }
4711 
4712  ImageVariant& Abs( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4713  {
4714  return SetAbsoluteValue( rect, firstChannel, lastChannel );
4715  }
4716 
4717 #undef __SET_ABSOLUTE_VALUE
4718 
4719  // -------------------------------------------------------------------------
4720 
4721 #define __SET_COLOR_SPACE( I ) \
4722  static_cast<pcl::I&>( **this ).SetColorSpace( colorSpace, maxProcessors )
4723 
4731  ImageVariant& SetColorSpace( color_space colorSpace, int maxProcessors = 0 )
4732  {
4733  if ( *this )
4734  SOLVE_TEMPLATE( __SET_COLOR_SPACE )
4735  return *this;
4736  }
4737 
4738 #undef __SET_COLOR_SPACE
4739 
4740  // -------------------------------------------------------------------------
4741 
4742 #define __SET_COLUMN( I ) \
4743  static_cast<pcl::I&>( **this ).SetColumn( buffer, x, channel )
4744 
4752  template <typename T>
4753  ImageVariant& SetColumn( const T* buffer, int x, int channel = -1 )
4754  {
4755  PCL_PRECONDITION( buffer != 0 )
4756  if ( *this )
4757  SOLVE_TEMPLATE( __SET_COLUMN )
4758  return *this;
4759  }
4760 
4761 #undef __SET_COLUMN
4762 
4763  // -------------------------------------------------------------------------
4764 
4765 #define __SET_LIGHTNESS_1( I ) \
4766  ImageVariant::SetLightness( static_cast<pcl::I&>( **this ), L, point, rect, maxProcessors )
4767 
4768 #define __SET_LIGHTNESS_2( I ) \
4769  image.SetLightness( static_cast<const pcl::I&>( *L ), point, rect, maxProcessors )
4770 
4771 private:
4772 
4773  template <class P> static
4774  void SetLightness( GenericImage<P>& image, const ImageVariant& L,
4775  const Point& point, const Rect& rect, int maxProcessors )
4776  {
4777  if ( !L.IsComplexSample() )
4778  SOLVE_TEMPLATE_REAL_2( L, __SET_LIGHTNESS_2 )
4779  }
4780 
4781 public:
4782 
4791  const Point& point = Point( int_max ),
4792  const Rect& rect = Rect( 0 ), int maxProcessors = 0 )
4793  {
4794  if ( *this )
4795  if ( !IsComplexSample() )
4796  if ( L )
4797  SOLVE_TEMPLATE_REAL( __SET_LIGHTNESS_1 )
4798  return *this;
4799  }
4800 
4801 #undef __SET_LIGHTNESS_1
4802 #undef __SET_LIGHTNESS_2
4803 
4804  // -------------------------------------------------------------------------
4805 
4806 #define __SET_LUMINANCE_1( I ) \
4807  ImageVariant::SetLuminance( static_cast<pcl::I&>( **this ), Y, point, rect, maxProcessors )
4808 
4809 #define __SET_LUMINANCE_2( I ) \
4810  image.SetLuminance( static_cast<const pcl::I&>( *Y ), point, rect, maxProcessors )
4811 
4812 private:
4813 
4814  template <class P> static
4815  void SetLuminance( GenericImage<P>& image, const ImageVariant& Y,
4816  const Point& point, const Rect& rect, int maxProcessors )
4817  {
4818  if ( !Y.IsComplexSample() )
4819  SOLVE_TEMPLATE_REAL_2( Y, __SET_LUMINANCE_2 )
4820  }
4821 
4822 public:
4823 
4832  const Point& point = Point( int_max ),
4833  const Rect& rect = Rect( 0 ), int maxProcessors = 0 )
4834  {
4835  if ( *this )
4836  if ( !IsComplexSample() )
4837  if ( Y )
4838  SOLVE_TEMPLATE_REAL( __SET_LUMINANCE_1 )
4839  return *this;
4840  }
4841 
4842 #undef __SET_LUMINANCE_1
4843 #undef __SET_LUMINANCE_2
4844 
4845  // -------------------------------------------------------------------------
4846 
4847 #define __SET_MAXIMUM( I ) \
4848  static_cast<pcl::I&>( **this ).SetMaximum( scalar, rect, firstChannel, lastChannel )
4849 
4857  template <typename T>
4859  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4860  {
4861  if ( *this )
4862  SOLVE_TEMPLATE( __SET_MAXIMUM )
4863  return *this;
4864  }
4865 
4866 #undef __SET_MAXIMUM
4867 
4871  template <typename T>
4872  ImageVariant& Max( T scalar,
4873  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4874  {
4875  return SetMaximum( scalar, rect, firstChannel, lastChannel );
4876  }
4877 
4878  // -------------------------------------------------------------------------
4879 
4880 #define __SET_MAXIMUM_1( I ) \
4881  ImageVariant::SetMaximum( static_cast<pcl::I&>( **this ), image, point, channel, rect, firstChannel, lastChannel )
4882 
4883 #define __SET_MAXIMUM_2( I ) \
4884  image1.SetMaximum( static_cast<const pcl::I&>( *image2 ), point, channel, rect, firstChannel, lastChannel )
4885 
4886 private:
4887 
4888  template <class P> static
4889  void SetMaximum( GenericImage<P>& image1, const ImageVariant& image2,
4890  const Point& point, int channel,
4891  const Rect& rect, int firstChannel, int lastChannel )
4892  {
4893  SOLVE_TEMPLATE_2( image2, __SET_MAXIMUM_2 )
4894  }
4895 
4896 public:
4897 
4907  const Point& point = Point( int_max ), int channel = -1,
4908  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4909  {
4910  if ( *this )
4911  if ( image )
4912  SOLVE_TEMPLATE( __SET_MAXIMUM_1 )
4913  return *this;
4914  }
4915 
4916 #undef __SET_MAXIMUM_1
4917 #undef __SET_MAXIMUM_2
4918 
4923  const Point& point = Point( int_max ), int channel = -1,
4924  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4925  {
4926  return SetMaximum( image, point, channel, rect, firstChannel, lastChannel );
4927  }
4928 
4929  // -------------------------------------------------------------------------
4930 
4931 #define __SET_MINIMUM( I ) \
4932  static_cast<pcl::I&>( **this ).SetMinimum( scalar, rect, firstChannel, lastChannel )
4933 
4941  template <typename T>
4943  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4944  {
4945  if ( *this )
4946  SOLVE_TEMPLATE( __SET_MINIMUM )
4947  return *this;
4948  }
4949 
4950 #undef __SET_MINIMUM
4951 
4955  template <typename T>
4956  ImageVariant& Min( T scalar,
4957  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4958  {
4959  return SetMinimum( scalar, rect, firstChannel, lastChannel );
4960  }
4961 
4962  // -------------------------------------------------------------------------
4963 
4964 #define __SET_MINIMUM_1( I ) \
4965  ImageVariant::SetMinimum( static_cast<pcl::I&>( **this ), image, point, channel, rect, firstChannel, lastChannel )
4966 
4967 #define __SET_MINIMUM_2( I ) \
4968  image1.SetMinimum( static_cast<const pcl::I&>( *image2 ), point, channel, rect, firstChannel, lastChannel )
4969 
4970 private:
4971 
4972  template <class P> static
4973  void SetMinimum( GenericImage<P>& image1, const ImageVariant& image2,
4974  const Point& point, int channel,
4975  const Rect& rect, int firstChannel, int lastChannel )
4976  {
4977  SOLVE_TEMPLATE_2( image2, __SET_MINIMUM_2 )
4978  }
4979 
4980 public:
4981 
4991  const Point& point = Point( int_max ), int channel = -1,
4992  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4993  {
4994  if ( *this )
4995  if ( image )
4996  SOLVE_TEMPLATE( __SET_MINIMUM_1 )
4997  return *this;
4998  }
4999 
5000 #undef __SET_MINIMUM_1
5001 #undef __SET_MINIMUM_2
5002 
5007  const Point& point = Point( int_max ), int channel = -1,
5008  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
5009  {
5010  return SetMinimum( image, point, channel, rect, firstChannel, lastChannel );
5011  }
5012 
5013  // -------------------------------------------------------------------------
5014 
5015 #define __Sn( I ) \
5016  result = static_cast<const pcl::I&>( **this ).Sn( rect, firstChannel, lastChannel, maxProcessors )
5017 
5024  double Sn( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
5025  int maxProcessors = 0 ) const
5026  {
5027  double result = false;
5028  if ( *this )
5029  SOLVE_TEMPLATE( __Sn )
5030  return result;
5031  }
5032 
5033 #undef __Sn
5034 
5035  // -------------------------------------------------------------------------
5036 
5037 #define __SET_ROW( I ) \
5038  static_cast<pcl::I&>( **this ).SetRow( buffer, y, channel )
5039 
5047  template <typename T>
5048  ImageVariant& SetRow( const T* buffer, int y, int channel = -1 )
5049  {
5050  PCL_PRECONDITION( buffer != 0 )
5051  if ( *this )
5052  SOLVE_TEMPLATE( __SET_ROW )
5053  return *this;
5054  }
5055 
5056 #undef __SET_ROW
5057 
5058  // -------------------------------------------------------------------------
5059 
5060 #define __ENSURE_UNIQUE_IMAGE( I ) \
5061  static_cast<pcl::I&>( **this ).EnsureUnique()
5062 
5072  {
5073  if ( *this )
5074  SOLVE_TEMPLATE( __ENSURE_UNIQUE_IMAGE )
5075  return *this;
5076  }
5077 
5078 #undef __ENSURE_UNIQUE_IMAGE
5079 
5080  // -------------------------------------------------------------------------
5081 
5082 #define __ENSURE_LOCAL_IMAGE( I ) \
5083  static_cast<pcl::I&>( **this ).EnsureLocal()
5084 
5093  {
5094  if ( *this )
5095  SOLVE_TEMPLATE( __ENSURE_LOCAL_IMAGE )
5096  return *this;
5097  }
5098 
5099 #undef __ENSURE_LOCAL_IMAGE
5100 
5101  // -------------------------------------------------------------------------
5102 
5103 #define __SHIFT( I ) \
5104  static_cast<pcl::I&>( **this ).Shift( fillValues )
5105 
5112  template <typename T>
5113  ImageVariant& Shift( const GenericVector<T>& fillValues )
5114  {
5115  if ( *this )
5116  SOLVE_TEMPLATE( __SHIFT )
5117  return *this;
5118  }
5119 
5120 #undef __SHIFT
5121 
5122  // -------------------------------------------------------------------------
5123 
5124 #define __SHIFT( I ) \
5125  static_cast<pcl::I&>( **this ).Shift()
5126 
5135  {
5136  if ( *this )
5137  SOLVE_TEMPLATE( __SHIFT )
5138  return *this;
5139  }
5140 
5141 #undef __SHIFT
5142 
5143  // -------------------------------------------------------------------------
5144 
5145 #define __SHIFT_BY( I ) \
5146  static_cast<pcl::I&>( **this ).ShiftBy( dx, dy, fillValues )
5147 
5154  template <typename T>
5155  ImageVariant& ShiftBy( int dx, int dy, const GenericVector<T>& fillValues )
5156  {
5157  if ( *this )
5158  SOLVE_TEMPLATE( __SHIFT_BY )
5159  return *this;
5160  }
5161 
5162 #undef __SHIFT_BY
5163 
5164  // -------------------------------------------------------------------------
5165 
5166 #define __SHIFT_BY( I ) \
5167  static_cast<pcl::I&>( **this ).ShiftBy( dx, dy )
5168 
5176  ImageVariant& ShiftBy( int dx, int dy )
5177  {
5178  if ( *this )
5179  SOLVE_TEMPLATE( __SHIFT_BY )
5180  return *this;
5181  }
5182 
5183 #undef __SHIFT_BY
5184 
5185  // -------------------------------------------------------------------------
5186 
5187 #define __SHIFT_TO( I ) \
5188  static_cast<pcl::I&>( **this ).ShiftTo( x, y, fillValues )
5189 
5196  template <typename T>
5197  ImageVariant& ShiftTo( int x, int y, const GenericVector<T>& fillValues )
5198  {
5199  if ( *this )
5200  SOLVE_TEMPLATE( __SHIFT_TO )
5201  return *this;
5202  }
5203 
5204 #undef __SHIFT_TO
5205 
5206  // -------------------------------------------------------------------------
5207 
5208 #define __SHIFT_TO( I ) \
5209  static_cast<pcl::I&>( **this ).ShiftTo( x, y )
5210 
5218  ImageVariant& ShiftTo( int x, int y )
5219  {
5220  if ( *this )
5221  SOLVE_TEMPLATE( __SHIFT_TO )
5222  return *this;
5223  }
5224 
5225 #undef __SHIFT_TO
5226 
5227  // -------------------------------------------------------------------------
5228 
5229 #define __SHIFT_TO( I ) \
5230  static_cast<pcl::I&>( **this ).ShiftTo( p, fillValues )
5231 
5238  template <typename T>
5239  ImageVariant& ShiftTo( const Point& p, const GenericVector<T>& fillValues )
5240  {
5241  if ( *this )
5242  SOLVE_TEMPLATE( __SHIFT_TO )
5243  return *this;
5244  }
5245 
5246 #undef __SHIFT_TO
5247 
5248  // -------------------------------------------------------------------------
5249 
5250 #define __SHIFT_TO( I ) \
5251  static_cast<pcl::I&>( **this ).ShiftTo( p )
5252 
5261  {
5262  if ( *this )
5263  SOLVE_TEMPLATE( __SHIFT_TO )
5264  return *this;
5265  }
5266 
5267 #undef __SHIFT_TO
5268 
5269  // -------------------------------------------------------------------------
5270 
5271 #define __SHIFT_TO_BOTTOM_LEFT( I ) \
5272  static_cast<pcl::I&>( **this ).ShiftToBottomLeft( width, height, fillValues )
5273 
5281  template <typename T>
5282  ImageVariant& ShiftToBottomLeft( int width, int height, const GenericVector<T>& fillValues )
5283  {
5284  if ( *this )
5285  SOLVE_TEMPLATE( __SHIFT_TO_BOTTOM_LEFT )
5286  return *this;
5287  }
5288 
5289 #undef __SHIFT_TO_BOTTOM_LEFT
5290 
5291  // -------------------------------------------------------------------------
5292 
5293 #define __SHIFT_TO_BOTTOM_LEFT( I ) \
5294  static_cast<pcl::I&>( **this ).ShiftToBottomLeft( width, height )
5295 
5305  ImageVariant& ShiftToBottomLeft( int width, int height )
5306  {
5307  if ( *this )
5308  SOLVE_TEMPLATE( __SHIFT_TO_BOTTOM_LEFT )
5309  return *this;
5310  }
5311 
5312 #undef __SHIFT_TO_BOTTOM_LEFT
5313 
5314  // -------------------------------------------------------------------------
5315 
5316 #define __SHIFT_TO_BOTTOM_RIGHT( I ) \
5317  static_cast<pcl::I&>( **this ).ShiftToBottomRight( width, height, fillValues )
5318 
5326  template <typename T>
5327  ImageVariant& ShiftToBottomRight( int width, int height, const GenericVector<T>& fillValues )
5328  {
5329  if ( *this )
5330  SOLVE_TEMPLATE( __SHIFT_TO_BOTTOM_RIGHT )
5331  return *this;
5332  }
5333 
5334 #undef __SHIFT_TO_BOTTOM_RIGHT
5335 
5336  // -------------------------------------------------------------------------
5337 
5338 #define __SHIFT_TO_BOTTOM_RIGHT( I ) \
5339  static_cast<pcl::I&>( **this ).ShiftToBottomRight( width, height )
5340 
5350  ImageVariant& ShiftToBottomRight( int width, int height )
5351  {
5352  if ( *this )
5353  SOLVE_TEMPLATE( __SHIFT_TO_BOTTOM_RIGHT )
5354  return *this;
5355  }
5356 
5357 #undef __SHIFT_TO_BOTTOM_RIGHT
5358 
5359  // -------------------------------------------------------------------------
5360 
5361 #define __SHIFT_TO_BOTTOM_CENTER( I ) \
5362  static_cast<pcl::I&>( **this ).ShiftToCenter( width, height, fillValues )
5363 
5371  template <typename T>
5372  ImageVariant& ShiftToCenter( int width, int height, const GenericVector<T>& fillValues )
5373  {
5374  if ( *this )
5375  SOLVE_TEMPLATE( __SHIFT_TO_BOTTOM_CENTER )
5376  return *this;
5377  }
5378 
5379 #undef __SHIFT_TO_BOTTOM_CENTER
5380 
5381  // -------------------------------------------------------------------------
5382 
5383 #define __SHIFT_TO_BOTTOM_CENTER( I ) \
5384  static_cast<pcl::I&>( **this ).ShiftToCenter( width, height )
5385 
5395  ImageVariant& ShiftToCenter( int width, int height )
5396  {
5397  if ( *this )
5398  SOLVE_TEMPLATE( __SHIFT_TO_BOTTOM_CENTER )
5399  return *this;
5400  }
5401 
5402 #undef __SHIFT_TO_BOTTOM_CENTER
5403 
5404  // -------------------------------------------------------------------------
5405 
5406 #define __SHIFT_TO_TOP_LEFT( I ) \
5407  static_cast<pcl::I&>( **this ).ShiftToTopLeft( width, height, fillValues )
5408 
5416  template <typename T>
5417  ImageVariant& ShiftToTopLeft( int width, int height, const GenericVector<T>& fillValues )
5418  {
5419  if ( *this )
5420  SOLVE_TEMPLATE( __SHIFT_TO_TOP_LEFT )
5421  return *this;
5422  }
5423 
5424 #undef __SHIFT_TO_TOP_LEFT
5425 
5426  // -------------------------------------------------------------------------
5427 
5428 #define __SHIFT_TO_TOP_LEFT( I ) \
5429  static_cast<pcl::I&>( **this ).ShiftToTopLeft( width, height )
5430 
5440  ImageVariant& ShiftToTopLeft( int width, int height )
5441  {
5442  if ( *this )
5443  SOLVE_TEMPLATE( __SHIFT_TO_TOP_LEFT )
5444  return *this;
5445  }
5446 
5447 #undef __SHIFT_TO_TOP_LEFT
5448 
5449  // -------------------------------------------------------------------------
5450 
5451 #define __SHIFT_TO_TOP_RIGHT( I ) \
5452  static_cast<pcl::I&>( **this ).ShiftToTopRight( width, height, fillValues )
5453 
5461  template <typename T>
5462  ImageVariant& ShiftToTopRight( int width, int height, const GenericVector< T >& fillValues )
5463  {
5464  if ( *this )
5465  SOLVE_TEMPLATE( __SHIFT_TO_TOP_RIGHT )
5466  return *this;
5467  }
5468 
5469 #undef __SHIFT_TO_TOP_RIGHT
5470 
5471  // -------------------------------------------------------------------------
5472 
5473 #define __SHIFT_TO_TOP_RIGHT( I ) \
5474  static_cast<pcl::I&>( **this ).ShiftToTopRight( width, height )
5475 
5485  ImageVariant& ShiftToTopRight( int width, int height )
5486  {
5487  if ( *this )
5488  SOLVE_TEMPLATE( __SHIFT_TO_TOP_RIGHT )
5489  return *this;
5490  }
5491 
5492 #undef __SHIFT_TO_TOP_RIGHT
5493 
5494  // -------------------------------------------------------------------------
5495 
5496 #define __STD_DEV( I ) \
5497  result = static_cast<const pcl::I&>( **this ).StdDev( rect, firstChannel, lastChannel, maxProcessors )
5498 
5504  double StdDev( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
5505  int maxProcessors = 0 ) const
5506  {
5507  double result = 0;
5508  if ( *this )
5509  SOLVE_TEMPLATE( __STD_DEV )
5510  return result;
5511  }
5512 
5513 #undef __STD_DEV
5514 
5515  // -------------------------------------------------------------------------
5516 
5517 #define __SUBTRACT( I ) \
5518  static_cast<pcl::I&>( **this ).Subtract( scalar, rect, firstChannel, lastChannel )
5519 
5527  template <typename T>
5529  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
5530  {
5531  if ( *this )
5532  SOLVE_TEMPLATE( __SUBTRACT )
5533  return *this;
5534  }
5535 
5536 #undef __SUBTRACT
5537 
5541  template <typename T>
5542  ImageVariant& Sub( T scalar,
5543  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
5544  {
5545  return Subtract( scalar, rect, firstChannel, lastChannel );
5546  }
5547 
5548  // -------------------------------------------------------------------------
5549 
5550 #define __SUBTRACT_1( I ) \
5551  ImageVariant::Subtract( static_cast<pcl::I&>( **this ), image, point, channel, rect, firstChannel, lastChannel )
5552 
5553 #define __SUBTRACT_2( I ) \
5554  image1.Subtract( static_cast<const pcl::I&>( *image2 ), point, channel, rect, firstChannel, lastChannel )
5555 
5556 private:
5557 
5558  template <class P> static
5559  void Subtract( GenericImage<P>& image1, const ImageVariant& image2,
5560  const Point& point, int channel,
5561  const Rect& rect, int firstChannel, int lastChannel )
5562  {
5563  SOLVE_TEMPLATE_2( image2, __SUBTRACT_2 )
5564  }
5565 
5566 public:
5567 
5576  const Point& point = Point( int_max ), int channel = -1,
5577  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
5578  {
5579  if ( *this )
5580  if ( image )
5581  SOLVE_TEMPLATE( __SUBTRACT_1 )
5582  return *this;
5583  }
5584 
5585 #undef __SUBTRACT_1
5586 #undef __SUBTRACT_2
5587 
5592  const Point& point = Point( int_max ), int channel = -1,
5593  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
5594  {
5595  return Subtract( image, point, channel, rect, firstChannel, lastChannel );
5596  }
5597 
5598  // -------------------------------------------------------------------------
5599 
5600 #define __SUBTRACTED( I ) \
5601  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Subtracted( scalar, rect, firstChannel, lastChannel ) ) ); \
5602  result.SetOwnership( true )
5603 
5611  template <typename T>
5613  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
5614  {
5615  ImageVariant result;
5616  if ( *this )
5617  SOLVE_TEMPLATE( __SUBTRACTED )
5618  return result;
5619  }
5620 
5621 #undef __SUBTRACTED
5622 
5623  // -------------------------------------------------------------------------
5624 
5625 #define __SUM_OF_SQUARES( I ) \
5626  result = static_cast<const pcl::I&>( **this ).SumOfSquares( rect, firstChannel, lastChannel, maxProcessors )
5627 
5634  double SumOfSquares( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
5635  int maxProcessors = 0 ) const
5636  {
5637  double result = 0;
5638  if ( *this )
5639  SOLVE_TEMPLATE( __SUM_OF_SQUARES )
5640  return result;
5641  }
5642 
5643 #undef __SUM_OF_SQUARES
5644 
5645  // -------------------------------------------------------------------------
5646 
5647 #define __TRANSFER_IMAGE_1( I ) \
5648  ImageVariant::TransferImage( static_cast<pcl::I&>( **this ), image )
5649 
5650 #define __TRANSFER_IMAGE_2( I ) \
5651  image1.Transfer( static_cast<pcl::I&>( *image2 ) )
5652 
5653 private:
5654 
5655  template <class P> static
5656  void TransferImage( GenericImage<P>& image1, ImageVariant& image2 )
5657  {
5658  SOLVE_TEMPLATE_2( image2, __TRANSFER_IMAGE_2 )
5659  }
5660 
5661 public:
5662 
5672  {
5673  if ( *this )
5674  if ( image )
5675  SOLVE_TEMPLATE( __TRANSFER_IMAGE_1 )
5676  return *this;
5677  }
5678 
5679 #undef __TRANSFER_IMAGE_1
5680 #undef __TRANSFER_IMAGE_2
5681 
5682  // -------------------------------------------------------------------------
5683 
5684 #define __TRANSFORM( I ) \
5685  static_cast<const pcl::I&>( **this ).Transform( transform, rect, firstChannel, lastChannel )
5686 
5695  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
5696  {
5697  if ( *this )
5698  SOLVE_TEMPLATE( __TRANSFORM )
5699  }
5700 
5701 #undef __TRANSFORM
5702 
5703  // -------------------------------------------------------------------------
5704 
5705 #define __TRUNCATE( I ) \
5706  static_cast<pcl::I&>( **this ).Truncate( lowerBound, upperBound, rect, firstChannel, lastChannel )
5707 
5715  template <typename T>
5716  ImageVariant& Truncate( T lowerBound, T upperBound,
5717  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
5718  {
5719  if ( *this )
5720  SOLVE_TEMPLATE_REAL( __TRUNCATE )
5721  return *this;
5722  }
5723 
5724 #undef __TRUNCATE
5725 
5726  // -------------------------------------------------------------------------
5727 
5728 #define __TRUNCATE( I ) \
5729  static_cast<pcl::I&>( **this ).Truncate( rect, firstChannel, lastChannel )
5730 
5738  ImageVariant& Truncate( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
5739  {
5740  if ( *this )
5741  SOLVE_TEMPLATE_REAL( __TRUNCATE )
5742  return *this;
5743  }
5744 
5745 #undef __TRUNCATE
5746 
5747  // -------------------------------------------------------------------------
5748 
5749 #define __TRUNCATED( I ) \
5750  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Truncated( lowerBound, upperBound, rect, firstChannel, lastChannel ) ) ); \
5751  result.SetOwnership( true )
5752 
5760  template <typename T>
5761  ImageVariant Truncated( T lowerBound, T upperBound,
5762  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
5763  {
5764  ImageVariant result;
5765  if ( *this )
5766  SOLVE_TEMPLATE( __TRUNCATED )
5767  return result;
5768  }
5769 
5770 #undef __TRUNCATED
5771 
5772  // -------------------------------------------------------------------------
5773 
5774 #define __TRUNCATED( I ) \
5775  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Truncated( rect, firstChannel, lastChannel ) ) ); \
5776  result.SetOwnership( true )
5777 
5785  ImageVariant Truncated( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
5786  {
5787  ImageVariant result;
5788  if ( *this )
5789  SOLVE_TEMPLATE( __TRUNCATED )
5790  return result;
5791  }
5792 
5793 #undef __TRUNCATED
5794 
5795  // -------------------------------------------------------------------------
5796 
5797 #define __VARIANCE( I ) \
5798  result = static_cast<const pcl::I&>( **this ).Variance( rect, firstChannel, lastChannel, maxProcessors )
5799 
5805  double Variance( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1, int maxProcessors = 0 ) const
5806  {
5807  double result = 0;
5808  if ( *this )
5809  SOLVE_TEMPLATE( __VARIANCE )
5810  return result;
5811  }
5812 
5813 #undef __VARIANCE
5814 
5815  // -------------------------------------------------------------------------
5816 
5817 #define __WHITE( I ) \
5818  static_cast<pcl::I&>( **this ).White( rect, firstChannel, lastChannel )
5819 
5826  ImageVariant& White( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
5827  {
5828  if ( *this )
5829  SOLVE_TEMPLATE_REAL( __WHITE )
5830  return *this;
5831  }
5832 
5833 #undef __WHITE
5834 
5835  // -------------------------------------------------------------------------
5836 
5837 #define __WRITE( I ) \
5838  static_cast<const pcl::I&>( **this ).Write( file, rect, firstChannel, lastChannel )
5839 
5847  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
5848  {
5849  if ( *this )
5850  SOLVE_TEMPLATE( __WRITE )
5851  return const_cast<ImageVariant&>( *this );
5852  }
5853 
5854 #undef __WRITE
5855 
5856  // -------------------------------------------------------------------------
5857 
5858 #define __WRITE( I ) \
5859  static_cast<const pcl::I&>( **this ).Write( filePath, rect, firstChannel, lastChannel )
5860 
5867  ImageVariant& Write( const String& filePath,
5868  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
5869  {
5870  if ( *this )
5871  SOLVE_TEMPLATE( __WRITE )
5872  return const_cast<ImageVariant&>( *this );
5873  }
5874 
5875 #undef __WRITE
5876 
5877  // -------------------------------------------------------------------------
5878 
5879 #define __XNOR( I ) \
5880  static_cast<pcl::I&>( **this ).Xnor( scalar, rect, firstChannel, lastChannel )
5881 
5889  template <typename T>
5890  ImageVariant& Xnor( T scalar,
5891  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
5892  {
5893  if ( *this )
5894  SOLVE_TEMPLATE_REAL( __XNOR )
5895  return *this;
5896  }
5897 
5898 #undef __XNOR
5899 
5900  // -------------------------------------------------------------------------
5901 
5902 #define __XNOR_1( I ) \
5903  ImageVariant::Xnor( static_cast<pcl::I&>( **this ), image, point, channel, rect, firstChannel, lastChannel )
5904 
5905 #define __XNOR_2( I ) \
5906  image1.Xnor( static_cast<const pcl::I&>( *image2 ), point, channel, rect, firstChannel, lastChannel )
5907 
5908 private:
5909 
5910  template <class P> static
5911  void Xnor( GenericImage<P>& image1, const ImageVariant& image2,
5912  const Point& point, int channel,
5913  const Rect& rect, int firstChannel, int lastChannel )
5914  {
5915  SOLVE_TEMPLATE_REAL_2( image2, __XNOR_2 )
5916  }
5917 
5918 public:
5919 
5928  const Point& point = Point( int_max ), int channel = -1,
5929  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
5930  {
5931  if ( *this )
5932  if ( image )
5933  SOLVE_TEMPLATE_REAL( __XNOR_1 )
5934  return *this;
5935  }
5936 
5937 #undef __XNOR_1
5938 #undef __XNOR_2
5939 
5940  // -------------------------------------------------------------------------
5941 
5942 #define __XOR( I ) \
5943  static_cast<pcl::I&>( **this ).Xor( scalar, rect, firstChannel, lastChannel )
5944 
5952  template <typename T>
5953  ImageVariant& Xor( T scalar,
5954  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
5955  {
5956  if ( *this )
5957  SOLVE_TEMPLATE_REAL( __XOR )
5958  return *this;
5959  }
5960 
5961 #undef __XOR
5962 
5963  // -------------------------------------------------------------------------
5964 
5965 #define __XOR_1( I ) \
5966  ImageVariant::Xor( static_cast<pcl::I&>( **this ), image, point, channel, rect, firstChannel, lastChannel )
5967 
5968 #define __XOR_2( I ) \
5969  image1.Xor( static_cast<const pcl::I&>( *image2 ), point, channel, rect, firstChannel, lastChannel )
5970 
5971 private:
5972 
5973  template <class P> static
5974  void Xor( GenericImage<P>& image1, const ImageVariant& image2,
5975  const Point& point, int channel,
5976  const Rect& rect, int firstChannel, int lastChannel )
5977  {
5978  SOLVE_TEMPLATE_REAL_2( image2, __XOR_2 )
5979  }
5980 
5981 public:
5982 
5991  const Point& point = Point( int_max ), int channel = -1,
5992  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
5993  {
5994  if ( *this )
5995  if ( image )
5996  SOLVE_TEMPLATE_REAL( __XOR_1 )
5997  return *this;
5998  }
5999 
6000 #undef __XOR_1
6001 #undef __XOR_2
6002 
6003  // -------------------------------------------------------------------------
6004 
6005 #define __ZERO( I ) \
6006  static_cast<pcl::I&>( **this ).Zero( rect, firstChannel, lastChannel )
6007 
6015  ImageVariant& Zero( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
6016  {
6017  if ( *this )
6018  SOLVE_TEMPLATE_REAL( __ZERO )
6019  return *this;
6020  }
6021 
6022 #undef __ZERO
6023 
6024  // -------------------------------------------------------------------------
6025 
6026 #define __COMPRESS( I ) \
6027  return static_cast<const pcl::I&>( **this ).Compress( compressor, rect, channel, perf )
6028 
6040  const Rect& rect = Rect( 0 ), int channel = -1,
6041  Compression::Performance* perf = nullptr ) const
6042  {
6043  if ( *this )
6044  SOLVE_TEMPLATE( __COMPRESS )
6045  return Compression::subblock_list();
6046  }
6047 
6048 #undef __COMPRESS
6049 
6050  // -------------------------------------------------------------------------
6051 
6056  template <class P>
6057  bool IsAs( const pcl::GenericImage<P>& ) const
6058  {
6059  return m_data->image && m_data->isFloatSample == P::IsFloatSample() &&
6060  m_data->isComplexSample == P::IsComplexSample() &&
6061  m_data->bitsPerSample == P::BitsPerSample();
6062  }
6063 
6073  {
6074  image.m_data->Attach();
6075  DetachFromData();
6076  m_data = image.m_data;
6077  return *this;
6078  }
6079 
6085  ImageVariant& operator =( const ImageVariant& image )
6086  {
6087  return Assign( image );
6088  }
6089 
6090 #define TRANSFER_BODY() \
6091  if ( &image != this ) /* N.B.: Self-movement incompatible with server-side SharedImage */ \
6092  { \
6093  DetachFromData(); \
6094  m_data = image.m_data; \
6095  image.m_data = nullptr; \
6096  } \
6097  return *this
6098 
6111  {
6112  TRANSFER_BODY();
6113  }
6114 
6127  {
6128  TRANSFER_BODY();
6129  }
6130 
6131 #undef TRANSFER_BODY
6132 
6138  ImageVariant& operator =( ImageVariant&& image )
6139  {
6140  return Transfer( image );
6141  }
6142 
6151  void ReleaseTo( ImageVariant& image )
6152  {
6153  if ( &image != this ) // N.B.: Self-release incompatible with server-side SharedImage.
6154  {
6155  Data* newData = new Data;
6156  image.DetachFromData();
6157  image.m_data = m_data;
6158  m_data = newData;
6159  }
6160  }
6161 
6170  template <class P>
6172  {
6173  if ( &image != m_data->image )
6174  {
6175  Free();
6176  m_data->Update( &image );
6177  }
6178  return *this;
6179  }
6180 
6184  friend void Swap( ImageVariant& x1, ImageVariant& x2 ) noexcept
6185  {
6186  pcl::Swap( x1.m_data, x2.m_data );
6187  }
6188 
6213  ImageVariant& CreateImage( bool isFloat, bool isComplex, int bitSize )
6214  {
6215  if ( isFloat )
6216  {
6217  if ( isComplex )
6218  CreateComplexImage( bitSize );
6219  else
6220  CreateFloatImage( bitSize );
6221  }
6222  else
6223  {
6224  if ( !isComplex )
6225  CreateUIntImage( bitSize );
6226  /*
6227  else
6228  {
6229  ### Yeah this is true, but everybody already knows so we don't want
6230  to replicate this useless message everywhere!
6231  throw Error( "Integer-valued complex images not supported by this PCL version." );
6232  }
6233  */
6234  }
6235 
6236  return *this;
6237  }
6238 
6239 #define CREATE_IMAGE( I ) m_data->Update( new pcl::I )
6240 
6253  ImageVariant& CreateFloatImage( int bitSize = 32 )
6254  {
6255  PCL_PRECONDITION( bitSize == 32 || bitSize == 64 )
6256  Free();
6257  switch ( bitSize )
6258  {
6259  case 32: CREATE_IMAGE( Image ); break;
6260  case 64: CREATE_IMAGE( DImage ); break;
6261  }
6262  m_data->ownsImage = m_data->image != nullptr;
6263  return *this;
6264  }
6265 
6275  {
6276  return CreateFloatImage();
6277  }
6278 
6290  ImageVariant& CreateComplexImage( int bitSize = 32 )
6291  {
6292  PCL_PRECONDITION( bitSize == 32 || bitSize == 64 )
6293  Free();
6294  switch ( bitSize )
6295  {
6296  case 32: CREATE_IMAGE( ComplexImage ); break;
6297  case 64: CREATE_IMAGE( DComplexImage ); break;
6298  }
6299  m_data->ownsImage = m_data->image != nullptr;
6300  return *this;
6301  }
6302 
6314  ImageVariant& CreateUIntImage( int bitSize = 16 )
6315  {
6316  PCL_PRECONDITION( bitSize == 8 || bitSize == 16 || bitSize == 32 )
6317  Free();
6318  switch ( bitSize )
6319  {
6320  case 8: CREATE_IMAGE( UInt8Image ); break;
6321  case 16: CREATE_IMAGE( UInt16Image ); break;
6322  case 32: CREATE_IMAGE( UInt32Image ); break;
6323  }
6324  m_data->ownsImage = m_data->image != nullptr;
6325  return *this;
6326  }
6327 
6328 #undef CREATE_IMAGE
6329 
6343  template <class P>
6345  {
6346  return CreateImage( P::IsFloatSample(), P::IsComplexSample(), P::BitsPerSample() );
6347  }
6348 
6363  {
6364  return CreateImage( image.IsFloatSample(), image.IsComplexSample(), image.BitsPerSample() );
6365  }
6366 
6367 #ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
6368 
6402  ImageVariant& CreateSharedImage( bool isFloat, bool isComplex, int bitSize )
6403  {
6404  if ( isFloat )
6405  {
6406  if ( isComplex )
6407  CreateSharedComplexImage( bitSize );
6408  else
6409  CreateSharedFloatImage( bitSize );
6410  }
6411  else
6412  {
6413  if ( !isComplex )
6414  CreateSharedUIntImage( bitSize );
6415  }
6416 
6417  return *this;
6418  }
6419 
6420 #define CREATE_SHARED_IMAGE( I ) m_data->Update( new pcl::I( (void*)0, 0, 0 ) )
6421 
6437  {
6438  PCL_PRECONDITION( bitSize == 32 || bitSize == 64 )
6439  Free();
6440  switch ( bitSize )
6441  {
6442  case 32: CREATE_SHARED_IMAGE( Image ); break;
6443  case 64: CREATE_SHARED_IMAGE( DImage ); break;
6444  }
6445  m_data->ownsImage = m_data->image != nullptr;
6446  return *this;
6447  }
6448 
6461  {
6462  return CreateSharedFloatImage();
6463  }
6464 
6480  {
6481  PCL_PRECONDITION( bitSize == 32 || bitSize == 64 )
6482  Free();
6483  switch ( bitSize )
6484  {
6485  case 32: CREATE_SHARED_IMAGE( ComplexImage ); break;
6486  case 64: CREATE_SHARED_IMAGE( DComplexImage ); break;
6487  }
6488  m_data->ownsImage = m_data->image != nullptr;
6489  return *this;
6490  }
6491 
6507  {
6508  PCL_PRECONDITION( bitSize == 8 || bitSize == 16 || bitSize == 32 )
6509  Free();
6510  switch ( bitSize )
6511  {
6512  case 8: CREATE_SHARED_IMAGE( UInt8Image ); break;
6513  case 16: CREATE_SHARED_IMAGE( UInt16Image ); break;
6514  case 32: CREATE_SHARED_IMAGE( UInt32Image ); break;
6515  }
6516  m_data->ownsImage = m_data->image != nullptr;
6517  return *this;
6518  }
6519 
6520 #undef CREATE_SHARED_IMAGE
6521 
6538  template <class P>
6540  {
6541  return CreateSharedImage( P::IsFloatSample(), P::IsComplexSample(), P::BitsPerSample() );
6542  }
6543 
6561  {
6562  return CreateSharedImage( image.IsFloatSample(), image.IsComplexSample(), image.BitsPerSample() );
6563  }
6564 
6565 #endif // !__PCL_BUILDING_PIXINSIGHT_APPLICATION
6566 
6567 #define ALLOCATE_IMAGE( I ) \
6568  static_cast<pcl::I&>( **this ).AllocateData( width, height, numberOfChannels, colorSpace )
6569 
6594  ImageVariant& AllocateImage( int width, int height, int numberOfChannels, color_space colorSpace )
6595  {
6596  if ( !*this )
6597  CreateImage();
6598  SOLVE_TEMPLATE( ALLOCATE_IMAGE )
6599  return *this;
6600  }
6601 
6602 #undef ALLOCATE_IMAGE
6603 
6604 #define COPY_IMAGE( I ) static_cast<pcl::I&>( **this ).Assign( image )
6605 
6622  template <class P>
6624  {
6625  if ( !*this )
6626  CreateImageAs( image );
6627  SOLVE_TEMPLATE( COPY_IMAGE )
6628  return *this;
6629  }
6630 
6631 #undef COPY_IMAGE
6632 
6633 #define COPY_IMAGE( I ) CopyImage( static_cast<const pcl::I&>( *image ) )
6634 
6647  {
6648  if ( image )
6649  SOLVE_TEMPLATE_2( image, COPY_IMAGE )
6650  else
6651  FreeImage();
6652  return *this;
6653  }
6654 
6655 #undef COPY_IMAGE
6656 
6657 #define FREE_IMAGE( I ) static_cast<pcl::I&>( **this ).FreeData()
6658 
6675  {
6676  if ( *this )
6677  SOLVE_TEMPLATE( FREE_IMAGE )
6678  return *this;
6679  }
6680 
6687  static Compression* NewCompression( swap_compression algorithm, int itemSize = 1 );
6688 
6689 #undef FREE_IMAGE
6690 
6720  void WriteSwapFile( const String& filePath,
6721  swap_compression compression = SwapCompression::None,
6722  Compression::Performance* perf = nullptr,
6723  bool processEvents = false ) const;
6724 
6761  void WriteSwapFiles( const String& fileName, const StringList& directories,
6762  swap_compression compression = SwapCompression::None,
6763  Compression::Performance* perf = nullptr,
6764  bool processEvents = false ) const;
6794  void ReadSwapFile( const String& filePath,
6795  Compression::Performance* perf = nullptr,
6796  bool processEvents = false );
6797 
6833  void ReadSwapFiles( const String& fileName, const StringList& directories,
6834  Compression::Performance* perf = nullptr,
6835  bool processEvents = false );
6836 
6872  void MaskFromSwapFile( const String& filePath, const ImageVariant& mask, bool invert = false,
6873  bool processEvents = false );
6874 
6908  void MaskFromSwapFiles( const String& fileName, const StringList& directories,
6909  const ImageVariant& mask, bool invert = false,
6910  bool processEvents = false );
6911 
6916  static void DeleteSwapFile( const String& filePath );
6917 
6926  static void DeleteSwapFiles( const String& fileName, const StringList& directories );
6927 
6937  static uint64 SwapFileSize( const String& filePath );
6938 
6951  static uint64 SwapFilesSize( const String& fileName, const StringList& directories );
6952 
6981  void MaskImage( const ImageVariant& src, const ImageVariant& mask, bool invert = false );
6982 
6987  bool OwnsImage() const noexcept
6988  {
6989  return m_data->ownsImage;
6990  }
6991 
7002  ImageVariant& SetOwnership( bool owner = true ) noexcept
7003  {
7004  m_data->ownsImage = owner && m_data->image;
7005  return *this;
7006  }
7007 
7016  {
7017  if ( m_data->IsUnique() )
7018  m_data->Free();
7019  else
7020  {
7021  Data* newData = new Data;
7022  DetachFromData();
7023  m_data = newData;
7024  }
7025  return *this;
7026  }
7027 
7035  const AbstractImage* operator ->() const noexcept
7036  {
7037  PCL_PRECONDITION( m_data->image != nullptr )
7038  return m_data->image;
7039  }
7040 
7048  AbstractImage* operator ->() noexcept
7049  {
7050  PCL_PRECONDITION( m_data->image != nullptr )
7051  return m_data->image;
7052  }
7053 
7061  const AbstractImage& operator *() const noexcept
7062  {
7063  PCL_PRECONDITION( m_data->image != nullptr )
7064  return *m_data->image;
7065  }
7066 
7075  {
7076  PCL_PRECONDITION( m_data->image != nullptr )
7077  return *m_data->image;
7078  }
7079 
7083  operator bool() const noexcept
7084  {
7085  return m_data->image != nullptr;
7086  }
7087 
7088 #define __PIXEL_ACCESS_OPERATOR( I ) \
7089  pcl::I::pixel_traits::FromSample( result, *static_cast<const pcl::I&>( **this ).PixelAddress( x, y, channel ) )
7090 
7116  double operator ()( int x, int y, int channel = 0 ) const noexcept
7117  {
7118  double result = 0;
7119  if ( *this )
7120  SOLVE_TEMPLATE( __PIXEL_ACCESS_OPERATOR )
7121  return result;
7122  }
7123 
7124 #undef __PIXEL_ACCESS_OPERATOR
7125 
7126 #ifdef __PCL_BUILDING_PIXINSIGHT_APPLICATION
7127 
7128  bool IsShared() const noexcept
7129  {
7130  return m_shared != nullptr;
7131  }
7132 
7133  // Implemented in SharedImage.cpp
7134  pi::SharedImage* GetSharedImage( bool rdOnly = false ) const;
7135  pi::SharedImage* NewSharedImage( void* owner, bool rdOnly = false );
7136 
7137 #endif
7138 
7139 private:
7140 
7141  struct Data : public ReferenceCounter
7142  {
7143  AbstractImage* image = nullptr;
7144  bool isFloatSample = false;
7145  bool isComplexSample = false;
7146  uint8 bitsPerSample = 0;
7147  bool ownsImage = false;
7148 
7149  Data() = default;
7150 
7151  ~Data()
7152  {
7153  Free();
7154  }
7155 
7156  template <class P>
7157  void Update( GenericImage<P>* a_image ) noexcept
7158  {
7159  image = a_image;
7160  isFloatSample = P::IsFloatSample();
7161  isComplexSample = P::IsComplexSample();
7162  bitsPerSample = uint8( P::BitsPerSample() );
7163  }
7164 
7165  void Free()
7166  {
7167  if ( ownsImage )
7168  delete image;
7169  image = nullptr;
7170  isFloatSample = isComplexSample = false;
7171  bitsPerSample = 0;
7172  //ownsImage = ownsImage; ### N.B.: Ownership must *not* change here
7173  }
7174  };
7175 
7176  Data* m_data = nullptr;
7177 
7178 #ifdef __PCL_BUILDING_PIXINSIGHT_APPLICATION
7179  // This is the server-side part of the image sharing mechanism
7180  pi::SharedImage* m_shared = nullptr;
7181 #else
7182  const void* m_shared = nullptr;
7183 #endif
7184 
7185  void DetachFromData()
7186  {
7187  if ( !m_data->Detach() )
7188  delete m_data;
7189  }
7190 
7191 #ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
7192  // Server-side private ctor. used by View
7193  template <class P>
7194  ImageVariant( GenericImage<P>* image, int )
7195  {
7196  m_data = new Data;
7197  m_data->Update( image );
7198  m_data->ownsImage = true;
7199  }
7200 #endif
7201 
7202 #ifdef __PCL_BUILDING_PIXINSIGHT_APPLICATION
7203  friend class pi::SharedImage;
7204 #else
7205  friend class View;
7206  friend class ImageView;
7207 #endif
7208 };
7209 
7210 // ----------------------------------------------------------------------------
7211 
7212 /*
7213  * Implementation of member functions of GenericImage requiring a full
7214  * declaration of ImageVariant.
7215  */
7216 
7217 template <class P> inline
7218 void GenericImage<P>::GetLuminance( ImageVariant& Y, const Rect& rect, int maxProcessors ) const
7219 {
7220  ImageVariant( const_cast<GenericImage<P>*>( this ) ).GetLuminance( Y, rect, maxProcessors );
7221 }
7222 
7223 template <class P> inline
7224 void GenericImage<P>::GetLightness( ImageVariant& L, const Rect& rect, int maxProcessors ) const
7225 {
7226  ImageVariant( const_cast<GenericImage<P>*>( this ) ).GetLightness( L, rect, maxProcessors );
7227 }
7228 
7229 template <class P> inline
7230 void GenericImage<P>::GetIntensity( ImageVariant& I, const Rect& rect, int maxProcessors ) const
7231 {
7232  ImageVariant( const_cast<GenericImage<P>*>( this ) ).GetIntensity( I, rect, maxProcessors );
7233 }
7234 
7235 template <class P> inline
7236 GenericImage<P>& GenericImage<P>::SetLuminance( const ImageVariant& Y, const Point& point, const Rect& rect, int maxProcessors )
7237 {
7238  (void)ImageVariant( this ).SetLuminance( Y, point, rect, maxProcessors );
7239  return *this;
7240 }
7241 
7242 template <class P> inline
7243 GenericImage<P>& GenericImage<P>::SetLightness( const ImageVariant& L, const Point& point, const Rect& rect, int maxProcessors )
7244 {
7245  (void)ImageVariant( this ).SetLightness( L, point, rect, maxProcessors );
7246  return *this;
7247 }
7248 
7249 // ----------------------------------------------------------------------------
7250 
7251 } // pcl
7252 
7253 #endif // __PCL_ImageVariant_h
7254 
7255 // ----------------------------------------------------------------------------
7256 // EOF pcl/ImageVariant.h - Released 2021-04-09T19:40:59Z
ImageVariant & Div(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
ImageVariant Multiplied(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1) const
void SelectChannel(int c) const noexcept
Definition: ImageVariant.h:773
ImageVariant & ShiftToBottomRight(int width, int height, const GenericVector< T > &fillValues)
ImageVariant & CreateSharedComplexImage(int bitSize=32)
Client-side interface to a PixInsight Bitmap object.
Definition: Bitmap.h:203
ImageVariant & Xnor(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
ImageVariant & Multiply(T scalar, 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:931
int LastChannel() const noexcept
Definition: ImageVariant.h:513
ImageVariant & Rescale(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
int NumberOfAlphaChannels() const noexcept
Definition: ImageVariant.h:562
ImageVariant & ShiftTo(int x, int y)
ImageVariant & ShiftToTopRight(int width, int height, const GenericVector< T > &fillValues)
void ReleaseTo(ImageVariant &image)
void ResetRangeClipping() const noexcept
ImageVariant & CreateImage(bool isFloat, bool isComplex, int bitSize)
ImageVariant & Pow(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
ImageVariant & EnsureLocalImage()
ImageVariant(GenericImage< P > *image)
Definition: ImageVariant.h:359
int NumberOfSelectedChannels() const noexcept
Definition: ImageVariant.h:843
size_type NumberOfSelectedSamples() const noexcept
bool Intersects(T x0, T y0, T x1, T y1) const noexcept
Definition: ImageVariant.h:693
Root base class for bidirectional PCL image transformations.
int LastSelectedChannel() const noexcept
Definition: ImageVariant.h:861
ImageVariant & CreateComplexImage(int bitSize=32)
void SelectRectangle(const Point &p0, const Point &p1) const noexcept
Definition: ImageVariant.h:945
A generic point in the two-dimensional space.
Definition: Point.h:99
ImageVariant & SetImage(GenericImage< P > &image)
ImageVariant & CreateSharedFloatImage(int bitSize=32)
ImageVariant & Nand(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
ImageVariant & Normalize(T lowerBound, T upperBound, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
ImageVariant & CreateSharedImageAs(const ImageVariant &image)
ImageVariant & SetAbsoluteDifference(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
ImageVariant & Invert(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
size_type NominalSize() const noexcept
AbstractImage * ImagePtr() noexcept
Definition: ImageVariant.h:416
double MaximumSampleValue(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1, int maxProcessors=0) const
int Width() const noexcept
Definition: ImageVariant.h:472
ImageVariant & SetMaximum(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
void Transform(BidirectionalImageTransformation &transform, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1) const
bool IsEmptySelection() const noexcept
Definition: ImageVariant.h:975
void ResetChannelRange() const noexcept
Definition: ImageVariant.h:833
int FirstSelectedChannel() const noexcept
Definition: ImageVariant.h:852
unsigned char uint8
Definition: Defs.h:638
double RangeClipLow() const noexcept
ImageVariant & Xor(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
ImageVariant Normalized(T lowerBound, T upperBound, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1) const
Compression/decompression performance measurements.
Definition: Compression.h:102
ImageVariant & Truncate(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
Point SelectedPoint() const noexcept
Definition: ImageVariant.h:913
ImageVariant & Transfer(ImageVariant &&image)
ImageVariant & ShiftToBottomLeft(int width, int height)
ImageVariant Blended(const Bitmap &bitmap, const Point &point=Point(int_max), const Rect &rect=Rect(0)) const
void CreateAlphaChannels(int n)
ImageVariant AbsoluteDifference(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1) const
double LocateMinimumSampleValue(int &xmin, int &ymin, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1, int maxProcessors=0) const
ImageVariant & ShiftToBottomLeft(int width, int height, const GenericVector< T > &fillValues)
void GetExtremeSampleValues(T &min, T &max, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1, int maxProcessors=0) const
PCL root namespace.
Definition: AbstractImage.h:76
ImageVariant & Add(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
void ResetPoint() const noexcept
Definition: ImageVariant.h:903
double Norm(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1, int maxProcessors=0) const
double MAD(double center, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1, int maxProcessors=0) const
size_type NumberOfNominalSamples() const noexcept
Definition: ImageVariant.h:585
void EnableRangeClipping(bool enableLow=true, bool enableHigh=true) const noexcept
bool IsHighRangeClippingEnabled() const noexcept
ImageVariant & ShiftTo(const Point &p)
void GetLightness(ImageVariant &L, const Rect &rect=Rect(0), int maxProcessors=0) const
A colorimetrically defined RGB working color space.
int NumberOfChannels() const noexcept
Definition: ImageVariant.h:501
bool CanPopSelections() const noexcept
ImageVariant Truncated(T lowerBound, T upperBound, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1) const
ImageVariant Applied(T scalar, image_op op=ImageOp::Mov, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1) const
ImageVariant & FreeImage()
ImageVariant & CropTo(int x0, int y0, int x1, int y1)
void DeleteAlphaChannel(int channel)
int NumberOfNominalChannels() const noexcept
Definition: ImageVariant.h:536
size_type NumberOfPixels() const noexcept
Definition: ImageVariant.h:492
size_type LineSize() const noexcept
ImageVariant & SetMinimum(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
ImageVariant & CropTo(const Rect &rect)
void Swap(GenericPoint< T > &p1, GenericPoint< T > &p2) noexcept
Definition: Point.h:1404
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 & Or(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
double Variance(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1, int maxProcessors=0) const
void EnableParallelProcessing(bool enable=true, int maxProcessors=0) noexcept
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 & Crop()
ImageVariant & Zero(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
ImageVariant Rescaled(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1) const
Abstract base class of data compression algorithm implementations.
Definition: Compression.h:83
ImageVariant & Shift()
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 & 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 & ShiftToTopLeft(int width, int height, const GenericVector< T > &fillValues)
ImageVariant & ShiftTo(int x, int y, const GenericVector< T > &fillValues)
bool Clip(pcl::GenericPoint< T > &p) const noexcept
Definition: ImageVariant.h:706
int BitsPerSample() const noexcept
Definition: ImageVariant.h:454
ImageVariant & Mul(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
bool IsRangeClippingEnabled() const noexcept
virtual ~ImageVariant()
Definition: ImageVariant.h:395
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)
Implements a generic, two-dimensional, shared or local image.
Definition: Image.h:277
pcl::StatusCallback * StatusCallback() const noexcept
size_type ChannelSize() const noexcept
size_type ImageSize() const noexcept
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)
ImageVariant & Shift(const GenericVector< T > &fillValues)
Two-sided descriptive statistical estimate.
Definition: Math.h:3483
size_type NumberOfAlphaSamples() const noexcept
Definition: ImageVariant.h:597
ImageVariant & One(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)
double Qn(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1, int maxProcessors=0) const
double Mean(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1, int maxProcessors=0) const
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)
double LocateMinimumSampleValue(Point &pmin, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1, int maxProcessors=0) const
ImageVariant Inverted(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1) const
ImageVariant & Transfer(ImageVariant &image)
ImageVariant(ImageVariant &&image)
Definition: ImageVariant.h:383
ImageVariant & ShiftToCenter(int width, int height)
ImageVariant & Read(const String &filePath)
16-bit unsigned integer image.
bool Includes(T x, T y) const noexcept
Definition: ImageVariant.h:666
bool IsUniqueImage() const noexcept
ImageVariant & And(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
String ChannelId(int c) const noexcept
double AvgDev(double center, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1, int maxProcessors=0) 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 & Dif(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
void GetIntensity(ImageVariant &Y, const Rect &rect=Rect(0), int maxProcessors=0) const
Generic vector of arbitrary length.
Definition: Vector.h:106
ImageVariant Inverted(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1) const
A generic rectangle in the two-dimensional space.
Definition: Rectangle.h:313
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)
void DeleteAlphaChannels()
size_t size_type
Definition: Defs.h:605
void SetRGBWorkingSpace(const RGBColorSystem &rgbws)
bool Clip(T &x0, T &y0, T &x1, T &y1) const noexcept
Definition: ImageVariant.h:762
color_space ColorSpace() const noexcept
ImageVariant & CreateImageAs(const ImageVariant &image)
Compression::subblock_list Compress(const Compression &compressor, const Rect &rect=Rect(0), int channel=-1, Compression::Performance *perf=nullptr) const
Acts like a union for all types of images in PCL, with optional class-wide ownership of transported i...
Definition: ImageVariant.h:317
ImageVariant & ShiftTo(const Point &p, const GenericVector< T > &fillValues)
ImageVariant Subtracted(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1) const
ImageVariant Applied(const ImageTransformation &transformation, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1) const
TwoSidedEstimate TwoSidedMAD(double center, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1, int maxProcessors=0) const
32-bit floating point complex image.
void SetRangeClipping(double clipLow, double clipHigh) const noexcept
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 & 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 & 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 & ShiftToTopLeft(int width, int height)
bool IsSameImage(const ImageVariant &image) const noexcept
Definition: ImageVariant.h:428
Rect Bounds() const noexcept
Definition: ImageVariant.h:612
ImageVariant & Crop(const GenericVector< T > &fillValues)
ImageVariant & AssignImage(const ImageVariant &image, 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)
ImageVariant & CreateImage()
ImageVariant & Sub(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
Unicode (UTF-16) string.
Definition: String.h:7923
int BytesPerSample() const noexcept
Definition: ImageVariant.h:463
void SelectRectangle(const Rect &r) const noexcept
Definition: ImageVariant.h:955
unsigned long long uint64
Definition: Defs.h:678
bool Includes(T x0, T y0, T x1, T y1) const noexcept
Definition: ImageVariant.h:651
ImageVariant & AllocateImage(int width, int height, int numberOfChannels, color_space colorSpace)
ImageVariant & ShiftToCenter(int width, int height, const GenericVector< T > &fillValues)
double MeanOfSquares(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1, int maxProcessors=0) const
double SumOfSquares(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1, int maxProcessors=0) const
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 IsCompletelySelected() const noexcept
ImageVariant & CropBy(int left, int top, int right, int bottom)
ImageVariant & Black(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
ImageVariant & Write(File &file, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1) const
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)
bool IsFloatSample() const noexcept
Definition: ImageVariant.h:437
ImageVariant Divided(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1) const
ImageVariant & SetColorSpace(color_space colorSpace, int maxProcessors=0)
bool IsColor() const noexcept
ImageVariant & CreateUIntImage(int bitSize=16)
ImageVariant & Write(const String &filePath, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1) const
ImageVariant AbsoluteValue(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1) const
ImageVariant & Divide(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
double OrderStatistic(double k, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1, int maxProcessors=0) const
ImageVariant & Exchange(ImageVariant &image, const Point &point=Point(int_max), int channel=-1, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
ImageVariant & TransferImage(ImageVariant &image)
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)
int MaxProcessors() const noexcept
ImageVariant & ShiftBy(int dx, int dy)
void Apply(FI i, FI j, F f) noexcept(noexcept(f))
Definition: Utility.h:249
bool IsFullSelection() const noexcept
Definition: ImageVariant.h:985
void SetRangeClipLow(double clipLow) const noexcept
double LocateMaximumSampleValue(Point &pmax, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1, int maxProcessors=0) const
ImageVariant & CropTo(int x0, int y0, int x1, int y1, const GenericVector< T > &fillValues)
void * SharedImageHandle() const noexcept
Base class of all two-dimensional images in PCL.
bool IsSharedImage() const noexcept
Rect SelectedRectangle() const noexcept
Definition: ImageVariant.h:994
ImageVariant & AllocateData(int width, int height, int numberOfChannels=1, color_space colorSpace=ColorSpace::Gray)
ImageVariant & ShiftToTopRight(int width, int height)
void GetLuminance(ImageVariant &Y, const Rect &rect=Rect(0), int maxProcessors=0) const
bool Clip(pcl::GenericRectangle< T > &r) const noexcept
Definition: ImageVariant.h:740
size_type NumberOfSamples() const noexcept
Definition: ImageVariant.h:573
ImageVariant & Assign(const ImageVariant &image)
64-bit floating point real image.
bool Includes(const GenericRectangle< T > &r) const noexcept
Definition: ImageVariant.h:636
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
ImageVariant & Binarize(T threshold, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
Dynamic list of Unicode (UTF-16) strings.
32-bit unsigned integer image.
TwoSidedEstimate TwoSidedAvgDev(double center, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1, int maxProcessors=0) const
bool Clip(T &x, T &y) const noexcept
Definition: ImageVariant.h:724
void SelectPoint(const Point &p) const noexcept
Definition: ImageVariant.h:894
ImageVariant & Binarize(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
An asynchronous status monitoring system.
void GetRow(T *buffer, int y, int channel=-1) const
void SetMaxProcessors(int maxProcessors) noexcept
ImageVariant & Truncate(T lowerBound, T upperBound, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
8-bit unsigned integer image.
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)
A structure used to store rectangular image selections, channel ranges, anchor points, and clipping ranges.
double Sn(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1, int maxProcessors=0) const
ImageVariant & CreateImageAs(const pcl::GenericImage< P > &image)
ImageVariant & SetRow(const T *buffer, int y, int channel=-1)
ImageVariant & CreateFloatImage(int bitSize=32)
ImageVariant & CreateSharedUIntImage(int bitSize=16)
bool OwnsImage() const noexcept
ImageVariant & Free()
T Abs(const Complex< T > &c) noexcept
Definition: Complex.h:429
ImageVariant & Rescale(T lowerBound, T upperBound, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
void ForgetAlphaChannels()
Generic dynamic array.
Definition: Array.h:99
void SelectChannelRange(int c0, int c1) const noexcept
Definition: ImageVariant.h:800
Root base class of all PCL image transformations.
double BendMidvariance(double center, double beta=0.2, 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
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)
void SetStatusCallback(pcl::StatusCallback *callback) const noexcept
ImageVariant & Normalize(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
ImageVariant & Apply(const ImageTransformation &transformation, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
ImageVariant & CropTo(const Rect &rect, const GenericVector< T > &fillValues)
ImageVariant & SetColumn(const T *buffer, int x, int channel=-1)
ImageVariant & SetLuminance(const ImageVariant &Y, const Point &point=Point(int_max), const Rect &rect=Rect(0), int maxProcessors=0)
double RangeClipHigh() const noexcept
double Median(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1, int maxProcessors=0) const
ImageVariant Normalized(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1) const
ImageVariant & CreateSharedImage()
Provides status monitoring callback functions.
Definition: StatusMonitor.h:97
size_type AlphaSize() const noexcept
void ForgetAlphaChannel(int channel)
bool IsAs(const pcl::GenericImage< P > &) const
ImageVariant & SetLightness(const ImageVariant &L, const Point &point=Point(int_max), const Rect &rect=Rect(0), int maxProcessors=0)
void SelectNominalChannels() const noexcept
Definition: ImageVariant.h:810
ImageVariant & Fill(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
double MinimumSampleValue(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1, int maxProcessors=0) const
bool IsLowRangeClippingEnabled() const noexcept
Client-side interface to a PixInsight ImageView control.
Definition: ImageView.h:79
High-level interface to a PixInsight view object.
Definition: View.h:212
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 & Mov(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
ImageVariant & SetAbsoluteValue(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
const RGBColorSystem & RGBWorkingSpace() const noexcept
bool Intersects(const pcl::GenericRectangle< T > &r) const noexcept
Definition: ImageVariant.h:678
ImageVariant Added(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1) const
ImageVariant & Move(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
ImageVariant & SetOwnership(bool owner=true) noexcept
ImageVariant & EnsureUniqueImage()
ImageVariant & CopyImage(const GenericImage< P > &image)
double StdDev(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1, int maxProcessors=0) const
void DisableParallelProcessing(bool disable=true) noexcept
ImageVariant & Subtract(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
32-bit integer point on the plane.
void DisableRangeClipping(bool disableLow=true, bool disableHigh=true) const noexcept
StatusMonitor & Status() const noexcept
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)
64-bit floating point complex image.
ImageVariant Binarized(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1) const
void GetSelectedChannelRange(int &c0, int &c1) const noexcept
Definition: ImageVariant.h:873
ImageVariant Binarized(T threshold, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1) const
void GetColumn(T *buffer, int x, int channel=-1) const
const AbstractImage * ImagePtr() const noexcept
Definition: ImageVariant.h:408
ImageVariant & CropBy(int left, int top, int right, int bottom, const GenericVector< T > &fillValues)
double Modulus(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1, int maxProcessors=0) const
void SetRangeClipHigh(double clipHigh) const noexcept
ImageVariant & CreateSharedImage(bool isFloat, bool isComplex, int bitSize)
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)
ImageOp::value_type image_op
Definition: ImageVariant.h:333
ImageVariant & CreateSharedImageAs(const pcl::GenericImage< P > &image)
double LocateMaximumSampleValue(int &xmax, int &ymax, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1, int maxProcessors=0) const
ImageVariant & Apply(T scalar, image_op op=ImageOp::Mov, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
Complex< T1 > operator*(const Complex< T1 > &c1, const Complex< T2 > &c2) noexcept
Definition: Complex.h:548
void PushSelections() const
void PopSelections() const
ImageVariant & White(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
bool IsParallelProcessingEnabled() const noexcept
int NumberOfNominalChannels(int colorSpace)
Definition: ColorSpace.h:102
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 Raised(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1) const
ImageVariant & Max(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
ImageVariant & Invert(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
void SelectPoint(int x, int y) const noexcept
Definition: ImageVariant.h:885
bool IsValidChannelIndex(int c) const noexcept
Definition: ImageVariant.h:523
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
size_type NumberOfSelectedPixels() const noexcept
ImageVariant & Nor(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
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)
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)
ImageVariant & Not(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
ImageVariant & Read(File &file)
ImageVariant & Blend(const Bitmap &bitmap, const Point &point=Point(int_max), const Rect &rect=Rect(0))
uint64 Count(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1, int maxProcessors=0) const
ImageVariant & Fill(const GenericVector< T > &values, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
ImageVariant & Raise(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
ImageVariant(const ImageVariant &image)
Definition: ImageVariant.h:374
ImageVariant & CopyImage(const ImageVariant &image)
32-bit integer rectangle on the plane.
ImageVariant & Xchg(ImageVariant &image, const Point &point=Point(int_max), int channel=-1, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
ImageVariant Maximum(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1) const
ImageVariant & ShiftBy(int dx, int dy, const GenericVector< T > &fillValues)
ImageVariant & ShiftToBottomRight(int width, int height)
void ResetSelection() const noexcept
Definition: ImageVariant.h:964
ImageVariant Minimum(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1) const
AbstractImage::color_space color_space
Definition: ImageVariant.h:326
ImageVariant Rescaled(T lowerBound, T upperBound, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1) const
ImageVariant Truncated(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1) const
32-bit floating point real image.
friend void Swap(ImageVariant &x1, ImageVariant &x2) noexcept
bool Includes(const GenericPoint< T > &p) const noexcept
Definition: ImageVariant.h:624
void SelectAlphaChannels() const noexcept
Definition: ImageVariant.h:823
Thread-safe reference counter for copy-on-write data structures.
ImageVariant & AllocateData(const Rect &rect, int numberOfChannels=1, color_space colorSpace=ColorSpace::Gray)
int SelectedChannel() const noexcept
Definition: ImageVariant.h:788
bool IsComplexSample() const noexcept
Definition: ImageVariant.h:445
A platform-independent interface to the local file system.
Definition: File.h:496
void ResetSelections() const noexcept
int Height() const noexcept
Definition: ImageVariant.h:481
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)
ImageSelections & Selections() const noexcept
bool HasAlphaChannels() const noexcept
Definition: ImageVariant.h:549