PCL
ImageVariant.h
Go to the documentation of this file.
1 // ____ ______ __
2 // / __ \ / ____// /
3 // / /_/ // / / /
4 // / ____// /___ / /___ PixInsight Class Library
5 // /_/ \____//_____/ PCL 2.1.19
6 // ----------------------------------------------------------------------------
7 // pcl/ImageVariant.h - Released 2019-11-07T10:59:34Z
8 // ----------------------------------------------------------------------------
9 // This file is part of the PixInsight Class Library (PCL).
10 // PCL is a multiplatform C++ framework for development of PixInsight modules.
11 //
12 // Copyright (c) 2003-2019 Pleiades Astrophoto S.L. All Rights Reserved.
13 //
14 // Redistribution and use in both source and binary forms, with or without
15 // modification, is permitted provided that the following conditions are met:
16 //
17 // 1. All redistributions of source code must retain the above copyright
18 // notice, this list of conditions and the following disclaimer.
19 //
20 // 2. All redistributions in binary form must reproduce the above copyright
21 // notice, this list of conditions and the following disclaimer in the
22 // documentation and/or other materials provided with the distribution.
23 //
24 // 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
25 // of their contributors, may be used to endorse or promote products derived
26 // from this software without specific prior written permission. For written
27 // permission, please contact info@pixinsight.com.
28 //
29 // 4. All products derived from this software, in any form whatsoever, must
30 // reproduce the following acknowledgment in the end-user documentation
31 // and/or other materials provided with the product:
32 //
33 // "This product is based on software from the PixInsight project, developed
34 // by Pleiades Astrophoto and its contributors (http://pixinsight.com/)."
35 //
36 // Alternatively, if that is where third-party acknowledgments normally
37 // appear, this acknowledgment must be reproduced in the product itself.
38 //
39 // THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
40 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
41 // TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
43 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
44 // EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
45 // INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
46 // DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
47 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
49 // POSSIBILITY OF SUCH DAMAGE.
50 // ----------------------------------------------------------------------------
51 
52 #ifndef __PCL_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 ) : m_data( image.m_data )
375  {
376  m_data->Attach();
377  }
378 
382  ImageVariant( ImageVariant&& image ) : m_data( image.m_data )
383  {
384  image.m_data = nullptr;
385  }
386 
393  virtual ~ImageVariant()
394  {
395  if ( m_data != nullptr )
396  {
397  DetachFromData();
398  m_data = nullptr;
399  }
400  }
401 
406  const AbstractImage* ImagePtr() const
407  {
408  return m_data->image;
409  }
410 
415  {
416  return m_data->image;
417  }
418 
426  bool IsSameImage( const ImageVariant& image ) const
427  {
428  return m_data->image == image.m_data->image;
429  }
430 
435  bool IsFloatSample() const
436  {
437  return m_data->isFloatSample;
438  }
439 
443  bool IsComplexSample() const
444  {
445  return m_data->isComplexSample;
446  }
447 
452  int BitsPerSample() const
453  {
454  return m_data->bitsPerSample;
455  }
456 
461  int BytesPerSample() const
462  {
463  return m_data->bitsPerSample >> 3;
464  }
465 
470  int Width() const
471  {
472  return m_data->image ? m_data->image->Width() : 0;
473  }
474 
479  int Height() const
480  {
481  return m_data->image ? m_data->image->Height() : 0;
482  }
483 
491  {
492  return m_data->image ? m_data->image->NumberOfPixels() : 0;
493  }
494 
499  int NumberOfChannels() const
500  {
501  return m_data->image ? m_data->image->NumberOfChannels() : 0;
502  }
503 
511  int LastChannel() const
512  {
513  return m_data->image ? m_data->image->LastChannel() : -1;
514  }
515 
521  bool IsValidChannelIndex( int c ) const
522  {
523  return m_data->image && m_data->image->IsValidChannelIndex( c );
524  }
525 
535  {
536  return m_data->image ? m_data->image->NumberOfNominalChannels() : 0;
537  }
538 
547  bool HasAlphaChannels() const
548  {
549  return m_data->image && m_data->image->HasAlphaChannels();
550  }
551 
561  {
562  return m_data->image ? m_data->image->NumberOfAlphaChannels() : 0;
563  }
564 
572  {
573  return m_data->image ? m_data->image->NumberOfSamples() : 0;
574  }
575 
584  {
585  return m_data->image ? m_data->image->NumberOfNominalSamples() : 0;
586  }
587 
596  {
597  return m_data->image ? m_data->image->NumberOfAlphaSamples() : 0;
598  }
599 
610  Rect Bounds() const
611  {
612  return m_data->image ? m_data->image->Bounds() : Rect( 0 );
613  }
614 
621  template <typename T>
622  bool Includes( const GenericPoint<T>& p ) const
623  {
624  return m_data->image && m_data->image->Includes( p );
625  }
626 
633  template <typename T>
634  bool Includes( const GenericRectangle<T>& r ) const
635  {
636  return m_data->image && m_data->image->Includes( r );
637  }
638 
648  template <typename T>
649  bool Includes( T x0, T y0, T x1, T y1 ) const
650  {
651  return m_data->image && m_data->image->Includes( x0, y0, x1, y1 );
652  }
653 
663  template <typename T>
664  bool Includes( T x, T y ) const
665  {
666  return m_data->image && m_data->image->Includes( x, y );
667  }
668 
675  template <typename T>
676  bool Intersects( const pcl::GenericRectangle<T>& r ) const
677  {
678  return m_data->image && m_data->image->Intersects( r );
679  }
680 
690  template <typename T>
691  bool Intersects( T x0, T y0, T x1, T y1 ) const
692  {
693  return m_data->image && m_data->image->Intersects( x0, y0, x1, y1 );
694  }
695 
703  template <typename T>
704  bool Clip( pcl::GenericPoint<T>& p ) const
705  {
706  return m_data->image && m_data->image->Clip( p );
707  }
708 
721  template <typename T>
722  bool Clip( T& x, T& y ) const
723  {
724  return m_data->image && m_data->image->Clip( x, y );
725  }
726 
737  template <typename T>
739  {
740  return m_data->image && m_data->image->Clip( r );
741  }
742 
759  template <typename T>
760  bool Clip( T& x0, T& y0, T& x1, T& y1 ) const
761  {
762  return m_data->image && m_data->image->Clip( x0, y0, x1, y1 );
763  }
764 
771  void SelectChannel( int c ) const
772  {
773  if ( m_data->image )
774  m_data->image->SelectChannel( c );
775  }
776 
786  int SelectedChannel() const
787  {
788  return m_data->image ? m_data->image->SelectedChannel() : -1;
789  }
790 
798  void SelectChannelRange( int c0, int c1 ) const
799  {
800  if ( m_data->image )
801  m_data->image->SelectChannelRange( c0, c1 );
802  }
803 
809  {
810  if ( m_data->image )
811  m_data->image->SelectNominalChannels();
812  }
813 
821  void SelectAlphaChannels() const
822  {
823  if ( m_data->image )
824  m_data->image->SelectAlphaChannels();
825  }
826 
831  void ResetChannelRange() const
832  {
833  if ( m_data->image )
834  m_data->image->ResetChannelRange();
835  }
836 
842  {
843  return m_data->image ? m_data->image->NumberOfSelectedChannels() : 0;
844  }
845 
851  {
852  return m_data->image ? m_data->image->FirstSelectedChannel() : -1;
853  }
854 
860  {
861  return m_data->image ? m_data->image->LastSelectedChannel() : -1;
862  }
863 
871  void GetSelectedChannelRange( int& c0, int& c1 ) const
872  {
873  if ( m_data->image )
874  m_data->image->GetSelectedChannelRange( c0, c1 );
875  }
876 
883  void SelectPoint( int x, int y ) const
884  {
885  if ( m_data->image )
886  m_data->image->SelectPoint( x, y );
887  }
888 
892  void SelectPoint( const Point& p ) const
893  {
894  if ( m_data->image )
895  m_data->image->SelectPoint( p );
896  }
897 
901  void ResetPoint() const
902  {
903  if ( m_data->image )
904  m_data->image->ResetPoint();
905  }
906 
912  {
913  return m_data->image ? m_data->image->SelectedPoint() : Point( 0 );
914  }
915 
929  void SelectRectangle( int x0, int y0, int x1, int y1 ) const
930  {
931  if ( m_data->image )
932  m_data->image->SelectRectangle( x0, y0, x1, y1 );
933  }
934 
943  void SelectRectangle( const Point& p0, const Point& p1 ) const
944  {
945  if ( m_data->image )
946  m_data->image->SelectRectangle( p0, p1 );
947  }
948 
953  void SelectRectangle( const Rect& r ) const
954  {
955  if ( m_data->image )
956  m_data->image->SelectRectangle( r );
957  }
958 
962  void ResetSelection() const
963  {
964  if ( m_data->image )
965  m_data->image->ResetSelection();
966  }
967 
973  bool IsEmptySelection() const
974  {
975  return m_data->image ? m_data->image->IsEmptySelection() : false;
976  }
977 
983  bool IsFullSelection() const
984  {
985  return m_data->image ? m_data->image->IsFullSelection() : false;
986  }
987 
993  {
994  return m_data->image ? m_data->image->SelectedRectangle() : Rect( 0 );
995  }
996 
1006  {
1007  return m_data->image ? m_data->image->IsCompletelySelected() : false;
1008  }
1009 
1016  {
1017  return m_data->image ? m_data->image->NumberOfSelectedPixels() : 0;
1018  }
1019 
1026  {
1027  return m_data->image ? m_data->image->NumberOfSelectedSamples() : 0;
1028  }
1029 
1051  {
1052  return m_data->image ? m_data->image->IsRangeClippingEnabled() : false;
1053  }
1054 
1060  void EnableRangeClipping( bool enable = true ) const
1061  {
1062  if ( m_data->image )
1063  m_data->image->EnableRangeClipping( enable );
1064  }
1065 
1071  void DisableRangeClipping( bool disable = true ) const
1072  {
1073  if ( m_data->image )
1074  m_data->image->DisableRangeClipping( disable );
1075  }
1076 
1083  double RangeClipLow() const
1084  {
1085  return m_data->image ? m_data->image->RangeClipLow() : 0.0;
1086  }
1087 
1094  double RangeClipHigh() const
1095  {
1096  return m_data->image ? m_data->image->RangeClipHigh() : 0.0;
1097  }
1098 
1104  void SetRangeClipLow( double clipLow ) const
1105  {
1106  if ( m_data->image )
1107  m_data->image->SetRangeClipLow( clipLow );
1108  }
1109 
1115  void SetRangeClipHigh( double clipHigh ) const
1116  {
1117  if ( m_data->image )
1118  m_data->image->SetRangeClipHigh( clipHigh );
1119  }
1120 
1127  void SetRangeClipping( double clipLow, double clipHigh ) const
1128  {
1129  if ( m_data->image )
1130  m_data->image->SetRangeClipping( clipLow, clipHigh );
1131  }
1132 
1140  void ResetRangeClipping() const
1141  {
1142  if ( m_data->image )
1143  m_data->image->ResetRangeClipping();
1144  }
1145 
1164  void ResetSelections() const
1165  {
1166  if ( m_data->image )
1167  m_data->image->ResetSelections();
1168  }
1169 
1178  {
1179  return m_data->image->Selections();
1180  }
1181 
1186  void PushSelections() const
1187  {
1188  if ( m_data->image )
1189  m_data->image->PushSelections();
1190  }
1191 
1200  void PopSelections() const
1201  {
1202  if ( m_data->image )
1203  m_data->image->PopSelections();
1204  }
1205 
1212  bool CanPopSelections() const
1213  {
1214  return m_data->image ? m_data->image->CanPopSelections() : false;
1215  }
1216 
1225  {
1226  PCL_PRECONDITION( m_data->image != nullptr )
1227  return m_data->image->Status();
1228  }
1229 
1236  {
1237  return m_data->image ? m_data->image->StatusCallback() : nullptr;
1238  }
1239 
1247  void SetStatusCallback( pcl::StatusCallback* callback ) const
1248  {
1249  if ( m_data->image )
1250  m_data->image->SetStatusCallback( callback );
1251  }
1252 
1262  {
1263  return m_data->image != nullptr && m_data->image->IsParallelProcessingEnabled();
1264  }
1265 
1279  void EnableParallelProcessing( bool enable = true, int maxProcessors = 0 )
1280  {
1281  if ( m_data->image )
1282  m_data->image->EnableParallelProcessing( enable, maxProcessors );
1283  }
1284 
1294  void DisableParallelProcessing( bool disable = true )
1295  {
1296  if ( m_data->image )
1297  m_data->image->DisableParallelProcessing( disable );
1298  }
1299 
1313  int MaxProcessors() const
1314  {
1315  return m_data->image ? m_data->image->MaxProcessors() : 0;
1316  }
1317 
1338  void SetMaxProcessors( int maxProcessors )
1339  {
1340  if ( m_data->image )
1341  m_data->image->SetMaxProcessors( maxProcessors );
1342  }
1343 
1352  {
1353  return m_data->image ? BytesPerSample() * size_type( m_data->image->Width() ) : 0;
1354  }
1355 
1363  {
1364  return BytesPerSample() * NumberOfPixels();
1365  }
1366 
1375  {
1376  return ChannelSize() * size_type( NumberOfChannels() );
1377  }
1378 
1388  {
1389  return ChannelSize() * size_type( NumberOfNominalChannels() );
1390  }
1391 
1401  {
1402  return ChannelSize() * size_type( NumberOfAlphaChannels() );
1403  }
1404 
1410  bool IsColor() const
1411  {
1412  return m_data->image && m_data->image->IsColor();
1413  }
1414 
1423  color_space ColorSpace() const
1424  {
1425  return m_data->image ? m_data->image->ColorSpace() : ColorSpace::Unknown;
1426  }
1427 
1433  String ChannelId( int c ) const
1434  {
1435  return m_data->image ? m_data->image->ChannelId( c ) : String();
1436  }
1437 
1446  {
1447  PCL_PRECONDITION( m_data->image != nullptr )
1448  return m_data->image->RGBWorkingSpace();
1449  }
1450 
1462  void SetRGBWorkingSpace( const RGBColorSystem& rgbws )
1463  {
1464  if ( m_data->image )
1465  m_data->image->SetRGBWorkingSpace( rgbws );
1466  }
1467 
1468  // -------------------------------------------------------------------------
1469 
1470 #define __ABSOLUTE_DIFFERENCE( I ) \
1471  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).AbsoluteDifference( scalar, rect, firstChannel, lastChannel ) ) ); \
1472  result.SetOwnership( true )
1473 
1482  template <typename T>
1483  ImageVariant AbsoluteDifference( T scalar, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
1484  {
1485  ImageVariant result;
1486  if ( *this )
1487  SOLVE_TEMPLATE( __ABSOLUTE_DIFFERENCE )
1488  return result;
1489  }
1490 
1491 #undef __ABSOLUTE_DIFFERENCE
1492 
1493  // -------------------------------------------------------------------------
1494 
1495 #define __ABSOLUTE_VALUE( I ) \
1496  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).AbsoluteValue( rect, firstChannel, lastChannel ) ) ); \
1497  result.SetOwnership( true )
1498 
1506  ImageVariant AbsoluteValue( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
1507  {
1508  ImageVariant result;
1509  if ( *this )
1510  SOLVE_TEMPLATE( __ABSOLUTE_VALUE )
1511  return result;
1512  }
1513 
1514 #undef __ABSOLUTE_VALUE
1515 
1516  // -------------------------------------------------------------------------
1517 
1518 #define __ADD( I ) \
1519  static_cast<pcl::I&>( **this ).Add( scalar, rect, firstChannel, lastChannel )
1520 
1527  template <typename T>
1528  ImageVariant& Add( T scalar, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
1529  {
1530  if ( *this )
1531  SOLVE_TEMPLATE( __ADD )
1532  return *this;
1533  }
1534 
1535 #undef __ADD
1536 
1537  // -------------------------------------------------------------------------
1538 
1539 #define __ADD_1( I ) \
1540  ImageVariant::Add( static_cast<pcl::I&>( **this ), image, point, channel, rect, firstChannel, lastChannel )
1541 
1542 #define __ADD_2( I ) \
1543  image1.Add( static_cast<const pcl::I&>( *image2 ), point, channel, rect, firstChannel, lastChannel )
1544 
1545 private:
1546 
1547  template <class P> static
1548  void Add( GenericImage<P>& image1, const ImageVariant& image2,
1549  const Point& point, int channel, const Rect& rect, int firstChannel, int lastChannel )
1550  {
1551  SOLVE_TEMPLATE_2( image2, __ADD_2 )
1552  }
1553 
1554 public:
1555 
1563  const Point& point = Point( int_max ), int channel = -1,
1564  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
1565  {
1566  if ( *this )
1567  if ( image )
1568  SOLVE_TEMPLATE( __ADD_1 )
1569  return *this;
1570  }
1571 
1572 #undef __ADD_1
1573 #undef __ADD_2
1574 
1575  // -------------------------------------------------------------------------
1576 
1577 #define __ADDED( I ) \
1578  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Added( scalar, rect, firstChannel, lastChannel ) ) ); \
1579  result.SetOwnership( true )
1580 
1587  template <typename T>
1588  ImageVariant Added( T scalar, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
1589  {
1590  ImageVariant result;
1591  if ( *this )
1592  SOLVE_TEMPLATE( __ADDED )
1593  return result;
1594  }
1595 
1596 #undef __ADDED
1597 
1598  // -------------------------------------------------------------------------
1599 
1600 #define __ALLOCATE_DATA( I ) \
1601  static_cast<pcl::I&>( **this ).AllocateData( width, height, numberOfChannels, colorSpace )
1602 
1613  ImageVariant& AllocateData( int width, int height, int numberOfChannels = 1, color_space colorSpace = ColorSpace::Gray )
1614  {
1615  if ( !*this )
1616  CreateImage();
1617  SOLVE_TEMPLATE( __ALLOCATE_DATA )
1618  return *this;
1619  }
1620 
1621 #undef __ALLOCATE_DATA
1622 
1623  // -------------------------------------------------------------------------
1624 
1625 #define __ALLOCATE_DATA( I ) \
1626  static_cast<pcl::I&>( **this ).AllocateData( rect, numberOfChannels, colorSpace )
1627 
1638  ImageVariant& AllocateData( const Rect& rect, int numberOfChannels = 1, color_space colorSpace = ColorSpace::Gray )
1639  {
1640  if ( !*this )
1641  CreateImage();
1642  SOLVE_TEMPLATE( __ALLOCATE_DATA )
1643  return *this;
1644  }
1645 
1646 #undef __ALLOCATE_DATA
1647 
1648  // -------------------------------------------------------------------------
1649 
1650 #define __AND( I ) \
1651  static_cast<pcl::I&>( **this ).And( scalar, rect, firstChannel, lastChannel )
1652 
1660  template <typename T>
1661  ImageVariant& And( T scalar, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
1662  {
1663  if ( *this )
1664  SOLVE_TEMPLATE_REAL( __AND )
1665  return *this;
1666  }
1667 
1668 #undef __AND
1669 
1670  // -------------------------------------------------------------------------
1671 
1672 #define __AND_1( I ) \
1673  ImageVariant::And( static_cast<pcl::I&>( **this ), image, point, channel, rect, firstChannel, lastChannel )
1674 
1675 #define __AND_2( I ) \
1676  image1.And( static_cast<const pcl::I&>( *image2 ), point, channel, rect, firstChannel, lastChannel )
1677 
1678 private:
1679 
1680  template <class P> static
1681  void And( GenericImage<P>& image1, const ImageVariant& image2,
1682  const Point& point, int channel, const Rect& rect, int firstChannel, int lastChannel )
1683  {
1684  SOLVE_TEMPLATE_REAL_2( image2, __AND_2 )
1685  }
1686 
1687 public:
1688 
1697  const Point& point = Point( int_max ), int channel = -1,
1698  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
1699  {
1700  if ( *this )
1701  if ( image )
1702  SOLVE_TEMPLATE_REAL( __AND_1 )
1703  return *this;
1704  }
1705 
1706 #undef __AND_1
1707 #undef __AND_2
1708 
1709  // -------------------------------------------------------------------------
1710 
1711 #define __APPLIED( I ) \
1712  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Applied( scalar, op, rect, firstChannel, lastChannel ) ) ); \
1713  result.SetOwnership( true )
1714 
1723  template <typename T>
1724  ImageVariant Applied( T scalar, image_op op = ImageOp::Mov, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
1725  {
1726  ImageVariant result;
1727  if ( *this )
1728  SOLVE_TEMPLATE( __APPLIED )
1729  return result;
1730  }
1731 
1732 #undef __APPLIED
1733 
1734  // -------------------------------------------------------------------------
1735 
1736 #define __APPLIED_1( I ) \
1737  result = ImageVariant::Applied( static_cast<const pcl::I&>( **this ), image, op, point, channel, rect, firstChannel, lastChannel )
1738 
1739 #define __APPLIED_2( I ) \
1740  result.SetImage( *new pcl::I( image1.Applied( static_cast<const pcl::I&>( *image2 ), op, point, channel, rect, firstChannel, lastChannel ) ) ); \
1741  result.SetOwnership( true )
1742 
1743 private:
1744 
1745  template <class P> static
1746  ImageVariant Applied( const GenericImage<P>& image1, const ImageVariant& image2,
1747  image_op op, const Point& point, int channel, const Rect& rect, int firstChannel, int lastChannel )
1748  {
1749  ImageVariant result;
1750  SOLVE_TEMPLATE_2( image2, __APPLIED_2 )
1751  return result;
1752  }
1753 
1754 public:
1755 
1764  ImageVariant Applied( const ImageVariant& image, image_op op = ImageOp::Mov,
1765  const Point& point = Point( int_max ), int channel = -1,
1766  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
1767  {
1768  ImageVariant result;
1769  if ( *this )
1770  if ( image )
1771  SOLVE_TEMPLATE( __APPLIED_1 )
1772  return result;
1773  }
1774 
1775 #undef __APPLIED_1
1776 #undef __APPLIED_2
1777 
1778  // -------------------------------------------------------------------------
1779 
1780 #define __APPLIED( I ) \
1781  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Applied( transformation, rect, firstChannel, lastChannel ) ) ); \
1782  result.SetOwnership( true )
1783 
1791  ImageVariant Applied( const ImageTransformation& transformation,
1792  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
1793  {
1794  ImageVariant result;
1795  if ( *this )
1796  SOLVE_TEMPLATE( __APPLIED )
1797  return result;
1798  }
1799 
1800 #undef __APPLIED
1801 
1802  // -------------------------------------------------------------------------
1803 
1804 #define __APPLY( I ) \
1805  static_cast<pcl::I&>( **this ).Apply( scalar, op, rect, firstChannel, lastChannel )
1806 
1815  template <typename T>
1816  ImageVariant& Apply( T scalar, image_op op = ImageOp::Mov, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
1817  {
1818  if ( *this )
1819  SOLVE_TEMPLATE( __APPLY )
1820  return *this;
1821  }
1822 
1823 #undef __APPLY
1824 
1825  // -------------------------------------------------------------------------
1826 
1827 #define __APPLY_1( I ) \
1828  ImageVariant::Apply( static_cast<pcl::I&>( **this ), image, op, point, channel, rect, firstChannel, lastChannel )
1829 
1830 #define __APPLY_2( I ) \
1831  image1.Apply( static_cast<const pcl::I&>( *image2 ), op, point, channel, rect, firstChannel, lastChannel )
1832 
1833 private:
1834 
1835  template <class P> static
1836  void Apply( GenericImage<P>& image1, const ImageVariant& image2,
1837  image_op op, const Point& point, int channel, const Rect& rect, int firstChannel, int lastChannel )
1838  {
1839  SOLVE_TEMPLATE_2( image2, __APPLY_2 )
1840  }
1841 
1842 public:
1843 
1852  ImageVariant& Apply( const ImageVariant& image, image_op op = ImageOp::Mov,
1853  const Point& point = Point( int_max ), int channel = -1,
1854  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
1855  {
1856  if ( *this )
1857  if ( image )
1858  SOLVE_TEMPLATE( __APPLY_1 )
1859  return *this;
1860  }
1861 
1862 #undef __APPLY_1
1863 #undef __APPLY_2
1864 
1865  // -------------------------------------------------------------------------
1866 
1867 #define __APPLY( I ) \
1868  static_cast<pcl::I&>( **this ).Apply( transformation, rect, firstChannel, lastChannel )
1869 
1877  ImageVariant& Apply( const ImageTransformation& transformation,
1878  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
1879  {
1880  if ( *this )
1881  SOLVE_TEMPLATE( __APPLY )
1882  return *this;
1883  }
1884 
1885 #undef __APPLY
1886 
1887  // -------------------------------------------------------------------------
1888 
1889 #define __ASSIGN_IMAGE_1( I ) \
1890  ImageVariant::AssignImage( static_cast<pcl::I&>( **this ), image, rect, firstChannel, lastChannel )
1891 
1892 #define __ASSIGN_IMAGE_2( I ) \
1893  image1.Assign( static_cast<const pcl::I&>( *image2 ), rect, firstChannel, lastChannel )
1894 
1895 private:
1896 
1897  template <class P> static
1898  void AssignImage( GenericImage<P>& image1, const ImageVariant& image2, const Rect& rect, int firstChannel, int lastChannel )
1899  {
1900  SOLVE_TEMPLATE_2( image2, __ASSIGN_IMAGE_2 )
1901  }
1902 
1903 public:
1904 
1911  ImageVariant& AssignImage( const ImageVariant& image, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
1912  {
1913  if ( *this )
1914  if ( image )
1915  SOLVE_TEMPLATE( __ASSIGN_IMAGE_1 )
1916  return *this;
1917  }
1918 
1919 #undef __ASSIGN_IMAGE_1
1920 #undef __ASSIGN_IMAGE_2
1921 
1922  // -------------------------------------------------------------------------
1923 
1924 #define __AVG_DEV( I ) \
1925  result = static_cast<const pcl::I&>( **this ).AvgDev( center, rect, firstChannel, lastChannel, maxProcessors )
1926 
1933  double AvgDev( double center, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1, int maxProcessors = 0 ) const
1934  {
1935  double result = 0;
1936  if ( *this )
1937  SOLVE_TEMPLATE( __AVG_DEV )
1938  return result;
1939  }
1940 
1941 #undef __AVG_DEV
1942 
1943  // -------------------------------------------------------------------------
1944 
1945 #define __BINARIZE( I ) \
1946  static_cast<pcl::I&>( **this ).Binarize( threshold, rect, firstChannel, lastChannel )
1947 
1955  template <typename T>
1956  ImageVariant& Binarize( T threshold, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
1957  {
1958  if ( *this )
1959  SOLVE_TEMPLATE_REAL( __BINARIZE )
1960  return *this;
1961  }
1962 
1963 #undef __BINARIZE
1964 
1965  // -------------------------------------------------------------------------
1966 
1967 #define __BINARIZE( I ) \
1968  static_cast<pcl::I&>( **this ).Binarize( rect, firstChannel, lastChannel )
1969 
1977  ImageVariant& Binarize( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
1978  {
1979  if ( *this )
1980  SOLVE_TEMPLATE_REAL( __BINARIZE )
1981  return *this;
1982  }
1983 
1984 #undef __BINARIZE
1985 
1986  // -------------------------------------------------------------------------
1987 
1988 #define __BINARIZED( I ) \
1989  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Binarized( threshold, rect, firstChannel, lastChannel ) ) ); \
1990  result.SetOwnership( true )
1991 
1999  template <typename T>
2000  ImageVariant Binarized( T threshold, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
2001  {
2002  ImageVariant result;
2003  if ( *this )
2004  SOLVE_TEMPLATE_REAL( __BINARIZED )
2005  return result;
2006  }
2007 
2008 #undef __BINARIZED
2009 
2010  // -------------------------------------------------------------------------
2011 
2012 #define __BINARIZED( I ) \
2013  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Binarized( rect, firstChannel, lastChannel ) ) ); \
2014  result.SetOwnership( true )
2015 
2023  ImageVariant Binarized( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
2024  {
2025  ImageVariant result;
2026  if ( *this )
2027  SOLVE_TEMPLATE_REAL( __BINARIZED )
2028  return result;
2029  }
2030 
2031 #undef __BINARIZED
2032 
2033  // -------------------------------------------------------------------------
2034 
2035 #define __PBMV( I ) \
2036  result = static_cast<const pcl::I&>( **this ).BendMidvariance( center, beta, rect, firstChannel, lastChannel, maxProcessors )
2037 
2046  double BendMidvariance( double center, double beta = 0.2,
2047  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
2048  int maxProcessors = 0 ) const
2049  {
2050  double result = false;
2051  if ( *this )
2052  SOLVE_TEMPLATE( __PBMV )
2053  return result;
2054  }
2055 
2056 #undef __PBMV
2057 
2058  // -------------------------------------------------------------------------
2059 
2060 #define __BWMV( I ) \
2061  result = static_cast<const pcl::I&>( **this ).BiweightMidvariance( center, sigma, k, rect, firstChannel, lastChannel, maxProcessors )
2062 
2071  double BiweightMidvariance( double center, double sigma, int k = 9,
2072  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
2073  int maxProcessors = 0 ) const
2074  {
2075  double result = false;
2076  if ( *this )
2077  SOLVE_TEMPLATE( __BWMV )
2078  return result;
2079  }
2080 
2081 #undef __BWMV
2082 
2083  // -------------------------------------------------------------------------
2084 
2085 #define __BLACK( I ) \
2086  static_cast<pcl::I&>( **this ).Black( rect, firstChannel, lastChannel )
2087 
2094  ImageVariant& Black( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
2095  {
2096  if ( *this )
2097  SOLVE_TEMPLATE( __BLACK )
2098  return *this;
2099  }
2100 
2101 #undef __BLACK
2102 
2103  // -------------------------------------------------------------------------
2104 
2105 #define __BLEND( I ) \
2106  static_cast<pcl::I&>( **this ).Blend( bitmap, point, rect )
2107 
2114  ImageVariant& Blend( const Bitmap& bitmap, const Point& point = Point( int_max ), const Rect& rect = Rect( 0 ) )
2115  {
2116  if ( *this )
2117  SOLVE_TEMPLATE_REAL( __BLEND )
2118  return *this;
2119  }
2120 
2121 #undef __BLEND
2122 
2123  // -------------------------------------------------------------------------
2124 
2125 #define __BLENDED( I ) \
2126  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Blended( bitmap, point, rect ) ) ); \
2127  result.SetOwnership( true )
2128 
2135  ImageVariant Blended( const Bitmap& bitmap, const Point& point = Point( int_max ), const Rect& rect = Rect( 0 ) ) const
2136  {
2137  ImageVariant result;
2138  if ( *this )
2139  SOLVE_TEMPLATE_REAL( __BLENDED )
2140  return result;
2141  }
2142 
2143 #undef __BLENDED
2144 
2145  // -------------------------------------------------------------------------
2146 
2147 #define __COUNT( I ) \
2148  result = static_cast<const pcl::I&>( **this ).Count( rect, firstChannel, lastChannel, maxProcessors )
2149 
2156  uint64 Count( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1, int maxProcessors = 0 ) const
2157  {
2158  uint64 result = 0;
2159  if ( *this )
2160  SOLVE_TEMPLATE( __COUNT )
2161  return result;
2162  }
2163 
2164 #undef __COUNT
2165 
2166  // -------------------------------------------------------------------------
2167 
2168 #define __CREATE_ALPHA_CHANNELS( I ) \
2169  static_cast<pcl::I&>( **this ).CreateAlphaChannels( n )
2170 
2183  void CreateAlphaChannels( int n )
2184  {
2185  if ( *this )
2186  SOLVE_TEMPLATE( __CREATE_ALPHA_CHANNELS )
2187  }
2188 
2189 #undef __CREATE_ALPHA_CHANNELS
2190 
2191  // -------------------------------------------------------------------------
2192 
2193 #define __CROP( I ) \
2194  static_cast<pcl::I&>( **this ).Crop( fillValues )
2195 
2202  template <typename T>
2203  ImageVariant& Crop( const GenericVector<T>& fillValues )
2204  {
2205  if ( *this )
2206  SOLVE_TEMPLATE( __CROP )
2207  return *this;
2208  }
2209 
2210 #undef __CROP
2211 
2212  // -------------------------------------------------------------------------
2213 
2214 #define __CROP( I ) \
2215  static_cast<pcl::I&>( **this ).Crop()
2216 
2225  {
2226  if ( *this )
2227  SOLVE_TEMPLATE( __CROP )
2228  return *this;
2229  }
2230 
2231 #undef __CROP
2232 
2233  // -------------------------------------------------------------------------
2234 
2235 #define __CROP_BY( I ) \
2236  static_cast<pcl::I&>( **this ).CropBy( left, top, right, bottom, fillValues )
2237 
2244  template <typename T>
2245  ImageVariant& CropBy( int left, int top, int right, int bottom, const GenericVector<T>& fillValues )
2246  {
2247  if ( *this )
2248  SOLVE_TEMPLATE( __CROP_BY )
2249  return *this;
2250  }
2251 
2252 #undef __CROP_BY
2253 
2254  // -------------------------------------------------------------------------
2255 
2256 #define __CROP_BY( I ) \
2257  static_cast<pcl::I&>( **this ).CropBy( left, top, right, bottom )
2258 
2265  ImageVariant& CropBy( int left, int top, int right, int bottom )
2266  {
2267  if ( *this )
2268  SOLVE_TEMPLATE( __CROP_BY )
2269  return *this;
2270  }
2271 
2272 #undef __CROP_BY
2273 
2274  // -------------------------------------------------------------------------
2275 
2276 #define __CROP_TO( I ) \
2277  static_cast<pcl::I&>( **this ).CropTo( rect, fillValues )
2278 
2285  template <typename T>
2286  ImageVariant& CropTo( const Rect& rect, const GenericVector<T>& fillValues )
2287  {
2288  if ( *this )
2289  SOLVE_TEMPLATE( __CROP_TO )
2290  return *this;
2291  }
2292 
2293 #undef __CROP_TO
2294 
2295  // -------------------------------------------------------------------------
2296 
2297 #define __CROP_TO( I ) \
2298  static_cast<pcl::I&>( **this ).CropTo( rect )
2299 
2307  ImageVariant& CropTo( const Rect& rect )
2308  {
2309  if ( *this )
2310  SOLVE_TEMPLATE( __CROP_TO )
2311  return *this;
2312  }
2313 
2314 #undef __CROP_TO
2315 
2316  // -------------------------------------------------------------------------
2317 
2318 #define __CROP_TO( I ) \
2319  static_cast<pcl::I&>( **this ).CropTo( x0, y0, x1, y1, fillValues )
2320 
2327  template <typename T>
2328  ImageVariant& CropTo( int x0, int y0, int x1, int y1, const GenericVector<T>& fillValues )
2329  {
2330  if ( *this )
2331  SOLVE_TEMPLATE( __CROP_TO )
2332  return *this;
2333  }
2334 
2335 #undef __CROP_TO
2336 
2337  // -------------------------------------------------------------------------
2338 
2339 #define __CROP_TO( I ) \
2340  static_cast<pcl::I&>( **this ).CropTo( x0, y0, x1, y1 )
2341 
2349  ImageVariant& CropTo( int x0, int y0, int x1, int y1 )
2350  {
2351  if ( *this )
2352  SOLVE_TEMPLATE( __CROP_TO )
2353  return *this;
2354  }
2355 
2356 #undef __CROP_TO
2357 
2358  // -------------------------------------------------------------------------
2359 
2360 #define __DELETE_ALPHA_CHANNEL( I ) \
2361  static_cast<pcl::I&>( **this ).DeleteAlphaChannel( channel )
2362 
2369  void DeleteAlphaChannel( int channel )
2370  {
2371  if ( *this )
2372  SOLVE_TEMPLATE( __DELETE_ALPHA_CHANNEL )
2373  }
2374 
2375 #undef __DELETE_ALPHA_CHANNEL
2376 
2377  // -------------------------------------------------------------------------
2378 
2379 #define __DELETE_ALPHA_CHANNELS( I ) \
2380  static_cast<pcl::I&>( **this ).DeleteAlphaChannels()
2381 
2390  {
2391  if ( *this )
2392  SOLVE_TEMPLATE( __DELETE_ALPHA_CHANNELS )
2393  }
2394 
2395 #undef __DELETE_ALPHA_CHANNELS
2396 
2397  // -------------------------------------------------------------------------
2398 
2399 #define __DIVIDE( I ) \
2400  static_cast<pcl::I&>( **this ).Divide( scalar, rect, firstChannel, lastChannel )
2401 
2408  template <typename T>
2409  ImageVariant& Divide( T scalar, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
2410  {
2411  if ( *this )
2412  SOLVE_TEMPLATE( __DIVIDE )
2413  return *this;
2414  }
2415 
2416 #undef __DIVIDE
2417 
2421  template <typename T>
2422  ImageVariant& Div( T scalar, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
2423  {
2424  return Divide( scalar, rect, firstChannel, lastChannel );
2425  }
2426 
2427  // -------------------------------------------------------------------------
2428 
2429 #define __DIVIDE_1( I ) \
2430  ImageVariant::Divide( static_cast<pcl::I&>( **this ), image, point, channel, rect, firstChannel, lastChannel )
2431 
2432 #define __DIVIDE_2( I ) \
2433  image1.Divide( static_cast<const pcl::I&>( *image2 ), point, channel, rect, firstChannel, lastChannel )
2434 
2435 private:
2436 
2437  template <class P> static
2438  void Divide( GenericImage<P>& image1, const ImageVariant& image2,
2439  const Point& point, int channel, const Rect& rect, int firstChannel, int lastChannel )
2440  {
2441  SOLVE_TEMPLATE_2( image2, __DIVIDE_2 )
2442  }
2443 
2444 public:
2445 
2453  const Point& point = Point( int_max ), int channel = -1,
2454  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
2455  {
2456  if ( *this )
2457  if ( image )
2458  SOLVE_TEMPLATE( __DIVIDE_1 )
2459  return *this;
2460  }
2461 
2462 #undef __DIVIDE_1
2463 #undef __DIVIDE_2
2464 
2469  const Point& point = Point( int_max ), int channel = -1,
2470  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
2471  {
2472  return Divide( image, point, channel, rect, firstChannel, lastChannel );
2473  }
2474 
2475  // -------------------------------------------------------------------------
2476 
2477 #define __DIVIDED( I ) \
2478  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Divided( scalar, rect, firstChannel, lastChannel ) ) ); \
2479  result.SetOwnership( true )
2480 
2487  template <typename T>
2488  ImageVariant Divided( T scalar, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
2489  {
2490  ImageVariant result;
2491  if ( *this )
2492  SOLVE_TEMPLATE( __DIVIDED )
2493  return result;
2494  }
2495 
2496 #undef __DIVIDED
2497 
2498  // -------------------------------------------------------------------------
2499 
2500 #define __EXCHANGE_1( I ) \
2501  ImageVariant::Exchange( static_cast<pcl::I&>( **this ), image, point, channel, rect, firstChannel, lastChannel )
2502 
2503 #define __EXCHANGE_2( I ) \
2504  image1.Exchange( static_cast<pcl::I&>( *image2 ), point, channel, rect, firstChannel, lastChannel )
2505 
2506 private:
2507 
2508  template <class P> static
2509  void Exchange( GenericImage<P>& image1, ImageVariant& image2,
2510  const Point& point, int channel, const Rect& rect, int firstChannel, int lastChannel )
2511  {
2512  SOLVE_TEMPLATE_2( image2, __EXCHANGE_2 )
2513  }
2514 
2515 public:
2516 
2525  const Point& point = Point( int_max ), int channel = -1,
2526  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
2527  {
2528  if ( *this )
2529  if ( image )
2530  SOLVE_TEMPLATE( __EXCHANGE_1 )
2531  return *this;
2532  }
2533 
2534 #undef __EXCHANGE_1
2535 #undef __EXCHANGE_2
2536 
2541  const Point& point = Point( int_max ), int channel = -1,
2542  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
2543  {
2544  return Exchange( image, point, channel, rect, firstChannel, lastChannel );
2545  }
2546 
2547  // -------------------------------------------------------------------------
2548 
2549 #define __FILL( I ) \
2550  static_cast<pcl::I&>( **this ).Fill( scalar, rect, firstChannel, lastChannel )
2551 
2558  template <typename T>
2559  ImageVariant& Fill( T scalar, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
2560  {
2561  if ( *this )
2562  SOLVE_TEMPLATE( __FILL )
2563  return *this;
2564  }
2565 
2566 #undef __FILL
2567 
2568  // -------------------------------------------------------------------------
2569 
2570 #define __FILL( I ) \
2571  static_cast<pcl::I&>( **this ).Fill( values, rect, firstChannel, lastChannel )
2572 
2580  template <typename T>
2581  ImageVariant& Fill( const GenericVector<T>& values, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
2582  {
2583  if ( *this )
2584  SOLVE_TEMPLATE( __FILL )
2585  return *this;
2586  }
2587 
2588 #undef __FILL
2589 
2590  // -------------------------------------------------------------------------
2591 
2592 #define __FILLED( I ) \
2593  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Filled( scalar, rect, firstChannel, lastChannel ) ) ); \
2594  result.SetOwnership( true )
2595 
2602  template <typename T>
2603  ImageVariant Filled( T scalar, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
2604  {
2605  ImageVariant result;
2606  if ( *this )
2607  SOLVE_TEMPLATE( __FILLED )
2608  return result;
2609  }
2610 
2611 #undef __FILLED
2612 
2613  // -------------------------------------------------------------------------
2614 
2615 #define __FILLED( I ) \
2616  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Filled( values, rect, firstChannel, lastChannel ) ) ); \
2617  result.SetOwnership( true )
2618 
2626  template <typename T>
2627  ImageVariant Filled( const GenericVector<T>& values, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
2628  {
2629  ImageVariant result;
2630  if ( *this )
2631  SOLVE_TEMPLATE( __FILLED )
2632  return result;
2633  }
2634 
2635 #undef __FILLED
2636 
2637  // -------------------------------------------------------------------------
2638 
2639 #define __FORGET_ALPHA_CHANNEL( I ) \
2640  static_cast<pcl::I&>( **this ).ForgetAlphaChannel( channel )
2641 
2649  void ForgetAlphaChannel( int channel )
2650  {
2651  if ( *this )
2652  SOLVE_TEMPLATE( __FORGET_ALPHA_CHANNEL )
2653  }
2654 
2655 #undef __FORGET_ALPHA_CHANNEL
2656 
2657  // -------------------------------------------------------------------------
2658 
2659 #define __FORGET_ALPHA_CHANNELS( I ) \
2660  static_cast<pcl::I&>( **this ).ForgetAlphaChannels()
2661 
2670  {
2671  if ( *this )
2672  SOLVE_TEMPLATE( __FORGET_ALPHA_CHANNELS )
2673  }
2674 
2675 #undef __FORGET_ALPHA_CHANNELS
2676 
2677  // -------------------------------------------------------------------------
2678 
2679 #define __GET_COLUMN( I ) \
2680  static_cast<const pcl::I&>( **this ).GetColumn( buffer, x, channel )
2681 
2689  template <typename T>
2690  void GetColumn( T* buffer, int x, int channel = -1 ) const
2691  {
2692  PCL_PRECONDITION( buffer != 0 )
2693  if ( *this )
2694  SOLVE_TEMPLATE( __GET_COLUMN )
2695  }
2696 
2697 #undef __GET_COLUMN
2698 
2699  // -------------------------------------------------------------------------
2700 
2701 #define __GET_EXTREME_SAMPLE_VALUES( I ) \
2702  static_cast<const pcl::I&>( **this ).GetExtremeSampleValues( min, max, rect, firstChannel, lastChannel, maxProcessors )
2703 
2710  template <typename T>
2711  void GetExtremeSampleValues( T& min, T& max, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
2712  int maxProcessors = 0 ) const
2713  {
2714  PCL_PRECONDITION( buffer != 0 )
2715  if ( *this )
2716  SOLVE_TEMPLATE( __GET_EXTREME_SAMPLE_VALUES )
2717  }
2718 
2719 #undef __GET_EXTREME_SAMPLE_VALUES
2720 
2721  // -------------------------------------------------------------------------
2722 
2723 #define __GET_INTENSITY_1( I ) \
2724  ImageVariant::GetIntensity( Y, static_cast<const pcl::I&>( **this ), rect, maxProcessors )
2725 
2726 #define __GET_INTENSITY_2( I ) \
2727  image.GetIntensity( static_cast<pcl::I&>( *Y ), rect, maxProcessors )
2728 
2729 private:
2730 
2731  template <class P> static
2732  void GetIntensity( ImageVariant& Y, const GenericImage<P>& image, const Rect& rect, int maxProcessors )
2733  {
2734  if ( !Y.IsComplexSample() )
2735  SOLVE_TEMPLATE_REAL_2( Y, __GET_INTENSITY_2 )
2736  }
2737 
2738 public:
2739 
2752  void GetIntensity( ImageVariant& Y, const Rect& rect = Rect( 0 ), int maxProcessors = 0 ) const
2753  {
2754  if ( *this )
2755  if ( !IsComplexSample() )
2756  {
2757  if ( !Y )
2758  Y.CreateFloatImage( 32 );
2759 
2760  SOLVE_TEMPLATE_REAL( __GET_INTENSITY_1 )
2761  }
2762  }
2763 
2764 #undef __GET_INTENSITY_1
2765 #undef __GET_INTENSITY_2
2766 
2767  // -------------------------------------------------------------------------
2768 
2769 #define __GET_LIGHTNESS_1( I ) \
2770  ImageVariant::GetLightness( L, static_cast<const pcl::I&>( **this ), rect, maxProcessors )
2771 
2772 #define __GET_LIGHTNESS_2( I ) \
2773  image.GetLightness( static_cast<pcl::I&>( *L ), rect, maxProcessors )
2774 
2775 private:
2776 
2777  template <class P> static
2778  void GetLightness( ImageVariant& L, const GenericImage<P>& image, const Rect& rect, int maxProcessors )
2779  {
2780  if ( !L.IsComplexSample() )
2781  SOLVE_TEMPLATE_REAL_2( L, __GET_LIGHTNESS_2 )
2782  }
2783 
2784 public:
2785 
2800  void GetLightness( ImageVariant& L, const Rect& rect = Rect( 0 ), int maxProcessors = 0 ) const
2801  {
2802  if ( *this )
2803  if ( !IsComplexSample() )
2804  {
2805  if ( !L )
2806  L.CreateFloatImage( ( BitsPerSample() < 32 ) ? 32 : ( IsFloatSample() ? BitsPerSample() : 64 ) );
2807 
2808  SOLVE_TEMPLATE_REAL( __GET_LIGHTNESS_1 )
2809  }
2810  }
2811 
2812 #undef __GET_LIGHTNESS_1
2813 #undef __GET_LIGHTNESS_2
2814 
2815  // -------------------------------------------------------------------------
2816 
2817 #define __GET_LUMINANCE_1( I ) \
2818  ImageVariant::GetLuminance( Y, static_cast<const pcl::I&>( **this ), rect, maxProcessors )
2819 
2820 #define __GET_LUMINANCE_2( I ) \
2821  image.GetLuminance( static_cast<pcl::I&>( *Y ), rect, maxProcessors )
2822 
2823 private:
2824 
2825  template <class P> static
2826  void GetLuminance( ImageVariant& Y, const GenericImage<P>& image, const Rect& rect, int maxProcessors )
2827  {
2828  if ( !Y.IsComplexSample() )
2829  SOLVE_TEMPLATE_REAL_2( Y, __GET_LUMINANCE_2 )
2830  }
2831 
2832 public:
2833 
2848  void GetLuminance( ImageVariant& Y, const Rect& rect = Rect( 0 ), int maxProcessors = 0 ) const
2849  {
2850  if ( *this )
2851  if ( !IsComplexSample() )
2852  {
2853  if ( !Y )
2854  Y.CreateFloatImage( ( BitsPerSample() < 32 ) ? 32 : ( IsFloatSample() ? BitsPerSample() : 64 ) );
2855 
2856  SOLVE_TEMPLATE_REAL( __GET_LUMINANCE_1 )
2857  }
2858  }
2859 
2860 #undef __GET_LUMINANCE_1
2861 #undef __GET_LUMINANCE_2
2862 
2863  // -------------------------------------------------------------------------
2864 
2865 #define __GET_ROW( I ) \
2866  static_cast<const pcl::I&>( **this ).GetRow( buffer, y, channel )
2867 
2874  template <typename T>
2875  void GetRow( T* buffer, int y, int channel = -1 ) const
2876  {
2877  PCL_PRECONDITION( buffer != 0 )
2878  if ( *this )
2879  SOLVE_TEMPLATE( __GET_ROW )
2880  }
2881 
2882 #undef __GET_ROW
2883 
2884  // -------------------------------------------------------------------------
2885 
2886 #define __INVERT( I ) \
2887  static_cast<pcl::I&>( **this ).Invert( scalar, rect, firstChannel, lastChannel )
2888 
2895  template <typename T>
2896  ImageVariant& Invert( T scalar, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
2897  {
2898  if ( *this )
2899  SOLVE_TEMPLATE_REAL( __INVERT )
2900  return *this;
2901  }
2902 
2903 #undef __INVERT
2904 
2905  // -------------------------------------------------------------------------
2906 
2907 #define __INVERT( I ) \
2908  static_cast<pcl::I&>( **this ).Invert( rect, firstChannel, lastChannel )
2909 
2917  ImageVariant& Invert( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
2918  {
2919  if ( *this )
2920  SOLVE_TEMPLATE_REAL( __INVERT )
2921  return *this;
2922  }
2923 
2924 #undef __INVERT
2925 
2926  // -------------------------------------------------------------------------
2927 
2928 #define __INVERTED( I ) \
2929  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Inverted( scalar, rect, firstChannel, lastChannel ) ) ); \
2930  result.SetOwnership( true )
2931 
2939  template <typename T>
2940  ImageVariant Inverted( T scalar, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
2941  {
2942  ImageVariant result;
2943  if ( *this )
2944  SOLVE_TEMPLATE( __INVERTED )
2945  return result;
2946  }
2947 
2948 #undef __INVERTED
2949 
2950  // -------------------------------------------------------------------------
2951 
2952 #define __INVERTED( I ) \
2953  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Inverted( rect, firstChannel, lastChannel ) ) ); \
2954  result.SetOwnership( true )
2955 
2964  ImageVariant Inverted( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
2965  {
2966  ImageVariant result;
2967  if ( *this )
2968  SOLVE_TEMPLATE( __INVERTED )
2969  return result;
2970  }
2971 
2972 #undef __INVERTED
2973 
2974  // -------------------------------------------------------------------------
2975 
2976 #ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
2977 
2978 #define __IS_SHARED_IMAGE( I ) \
2979  result = static_cast<const pcl::I&>( **this ).IsShared()
2980 
2989  bool IsSharedImage() const
2990  {
2991  bool result = false;
2992  if ( *this )
2993  SOLVE_TEMPLATE( __IS_SHARED_IMAGE )
2994  return result;
2995  }
2996 
2997 #undef __IS_SHARED_IMAGE
2998 
2999 #endif // !__PCL_BUILDING_PIXINSIGHT_APPLICATION
3000 
3001  // -------------------------------------------------------------------------
3002 
3003 #ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
3004 
3005 #define __SHARED_IMAGE_HANDLE( I ) \
3006  handle = static_cast<const pcl::I&>( **this ).Allocator().Handle()
3007 
3013  void* SharedImageHandle() const
3014  {
3015  void* handle = 0;
3016  if ( *this )
3017  SOLVE_TEMPLATE( __SHARED_IMAGE_HANDLE )
3018  return handle;
3019  }
3020 
3021 #undef __SHARED_IMAGE_HANDLE
3022 
3023 #endif // !__PCL_BUILDING_PIXINSIGHT_APPLICATION
3024 
3025  // -------------------------------------------------------------------------
3026 
3027 #define __IS_UNIQUE_IMAGE( I ) \
3028  result = static_cast<const pcl::I&>( **this ).IsUnique()
3029 
3039  bool IsUniqueImage() const
3040  {
3041  bool result = false;
3042  if ( *this )
3043  SOLVE_TEMPLATE( __IS_UNIQUE_IMAGE )
3044  return result;
3045  }
3046 
3047 #undef __IS_UNIQUE_IMAGE
3048 
3049  // -------------------------------------------------------------------------
3050 
3051 #define __LOCATE_EXTREME_SAMPLE_VALUES( I ) \
3052  static_cast<const pcl::I&>( **this ).LocateExtremeSampleValues( xmin, ymin, min, xmax, ymax, max, rect, firstChannel, lastChannel, maxProcessors )
3053 
3061  template <typename T>
3062  void LocateExtremeSampleValues( int& xmin, int& ymin, T& min,
3063  int& xmax, int& ymax, T& max,
3064  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
3065  int maxProcessors = 0 ) const
3066  {
3067  if ( *this )
3068  SOLVE_TEMPLATE_REAL( __LOCATE_EXTREME_SAMPLE_VALUES )
3069  }
3070 
3071 #undef __LOCATE_EXTREME_SAMPLE_VALUES
3072 
3073  // -------------------------------------------------------------------------
3074 
3075 #define __LOCATE_EXTREME_SAMPLE_VALUES( I ) \
3076  static_cast<const pcl::I&>( **this ).LocateExtremeSampleValues( pmin, min, pmax, max, rect, firstChannel, lastChannel, maxProcessors )
3077 
3085  template <typename T>
3086  void LocateExtremeSampleValues( Point& pmin, T& min,
3087  Point& pmax, T& max,
3088  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
3089  int maxProcessors = 0 ) const
3090  {
3091  if ( *this )
3092  SOLVE_TEMPLATE_REAL( __LOCATE_EXTREME_SAMPLE_VALUES )
3093  }
3094 
3095 #undef __LOCATE_EXTREME_SAMPLE_VALUES
3096 
3097  // -------------------------------------------------------------------------
3098 
3099 #define __LOCATE_MAXIMUM_SAMPLE_VALUE( I ) \
3100  pcl::I::pixel_traits::FromSample( result, static_cast<const pcl::I&>( **this ).LocateMaximumSampleValue( xmax, ymax, rect, firstChannel, lastChannel, maxProcessors ) )
3101 
3109  double LocateMaximumSampleValue( int& xmax, int& ymax, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
3110  int maxProcessors = 0 ) const
3111  {
3112  double result = 0;
3113  if ( *this )
3114  SOLVE_TEMPLATE( __LOCATE_MAXIMUM_SAMPLE_VALUE )
3115  return result;
3116  }
3117 
3118 #undef __LOCATE_MAXIMUM_SAMPLE_VALUE
3119 
3120  // -------------------------------------------------------------------------
3121 
3122 #define __LOCATE_MAXIMUM_SAMPLE_VALUE( I ) \
3123  pcl::I::pixel_traits::FromSample( result, static_cast<const pcl::I&>( **this ).LocateMaximumSampleValue( pmax, rect, firstChannel, lastChannel, maxProcessors ) )
3124 
3132  double LocateMaximumSampleValue( Point& pmax, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
3133  int maxProcessors = 0 ) const
3134  {
3135  double result = 0;
3136  if ( *this )
3137  SOLVE_TEMPLATE( __LOCATE_MAXIMUM_SAMPLE_VALUE )
3138  return result;
3139  }
3140 
3141 #undef __LOCATE_MAXIMUM_SAMPLE_VALUE
3142 
3143  // -------------------------------------------------------------------------
3144 
3145 #define __LOCATE_MINIMUM_SAMPLE_VALUE( I ) \
3146  pcl::I::pixel_traits::FromSample( result, static_cast<const pcl::I&>( **this ).LocateMinimumSampleValue( xmin, ymin, rect, firstChannel, lastChannel, maxProcessors ) )
3147 
3155  double LocateMinimumSampleValue( int& xmin, int& ymin,
3156  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
3157  int maxProcessors = 0 ) const
3158  {
3159  double result = 0;
3160  if ( *this )
3161  SOLVE_TEMPLATE( __LOCATE_MINIMUM_SAMPLE_VALUE )
3162  return result;
3163  }
3164 
3165 #undef __LOCATE_MINIMUM_SAMPLE_VALUE
3166 
3167  // -------------------------------------------------------------------------
3168 
3169 #define __LOCATE_MINIMUM_SAMPLE_VALUE( I ) \
3170  pcl::I::pixel_traits::FromSample( result, static_cast<const pcl::I&>( **this ).LocateMinimumSampleValue( pmin, rect, firstChannel, lastChannel, maxProcessors ) )
3171 
3179  double LocateMinimumSampleValue( Point& pmin, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1,
3180  int maxProcessors = 0 ) const
3181  {
3182  double result = 0;
3183  if ( *this )
3184  SOLVE_TEMPLATE( __LOCATE_MINIMUM_SAMPLE_VALUE )
3185  return result;
3186  }
3187 
3188 #undef __LOCATE_MINIMUM_SAMPLE_VALUE
3189 
3190  // -------------------------------------------------------------------------
3191 
3192 #define __MAD( I ) \
3193  result = static_cast<const pcl::I&>( **this ).MAD( center, rect, firstChannel, lastChannel, maxProcessors )
3194 
3201  double MAD( double center, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1, int maxProcessors = 0 ) const
3202  {
3203  double result = false;
3204  if ( *this )
3205  SOLVE_TEMPLATE( __MAD )
3206  return result;
3207  }
3208 
3209 #undef __MAD
3210 
3211  // -------------------------------------------------------------------------
3212 
3213 #define __MAXIMUM( I ) \
3214  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Maximum( scalar, rect, firstChannel, lastChannel ) ) ); \
3215  result.SetOwnership( true )
3216 
3224  template <typename T>
3225  ImageVariant Maximum( T scalar, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
3226  {
3227  ImageVariant result;
3228  if ( *this )
3229  SOLVE_TEMPLATE( __MAXIMUM )
3230  return result;
3231  }
3232 
3233 #undef __MAXIMUM
3234 
3235  // -------------------------------------------------------------------------
3236 
3237 #define __MAXIMUM_SAMPLE_VALUE( I ) \
3238  pcl::I::pixel_traits::FromSample( result, static_cast<const pcl::I&>( **this ).MaximumSampleValue( rect, firstChannel, lastChannel, maxProcessors ) )
3239 
3246  double MaximumSampleValue( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1, int maxProcessors = 0 ) const
3247  {
3248  double result = 0;
3249  if ( *this )
3250  SOLVE_TEMPLATE( __MAXIMUM_SAMPLE_VALUE )
3251  return result;
3252  }
3253 
3254 #undef __MAXIMUM_SAMPLE_VALUE
3255 
3256  // -------------------------------------------------------------------------
3257 
3258 #define __MEAN( I ) \
3259  result = static_cast<const pcl::I&>( **this ).Mean( rect, firstChannel, lastChannel, maxProcessors )
3260 
3266  double Mean( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1, int maxProcessors = 0 ) const
3267  {
3268  double result = 0;
3269  if ( *this )
3270  SOLVE_TEMPLATE( __MEAN )
3271  return result;
3272  }
3273 
3274 #undef __MEAN
3275 
3276  // -------------------------------------------------------------------------
3277 
3278 #define __MEAN_OF_SQUARES( I ) \
3279  result = static_cast<const pcl::I&>( **this ).MeanOfSquares( rect, firstChannel, lastChannel, maxProcessors )
3280 
3287  double MeanOfSquares( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1, int maxProcessors = 0 ) const
3288  {
3289  double result = 0;
3290  if ( *this )
3291  SOLVE_TEMPLATE( __MEAN_OF_SQUARES )
3292  return result;
3293  }
3294 
3295 #undef __MEAN_OF_SQUARES
3296 
3297  // -------------------------------------------------------------------------
3298 
3299 #define __MEDIAN( I ) \
3300  result = static_cast<const pcl::I&>( **this ).Median( rect, firstChannel, lastChannel, maxProcessors )
3301 
3307  double Median( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1, int maxProcessors = 0 ) const
3308  {
3309  double result = 0;
3310  if ( *this )
3311  SOLVE_TEMPLATE( __MEDIAN )
3312  return result;
3313  }
3314 
3315 #undef __MEDIAN
3316 
3317  // -------------------------------------------------------------------------
3318 
3319 #define __MINIMUM( I ) \
3320  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Minimum( scalar, rect, firstChannel, lastChannel ) ) ); \
3321  result.SetOwnership( true )
3322 
3330  template <typename T>
3331  ImageVariant Minimum( T scalar, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
3332  {
3333  ImageVariant result;
3334  if ( *this )
3335  SOLVE_TEMPLATE( __MINIMUM )
3336  return result;
3337  }
3338 
3339 #undef __MINIMUM
3340 
3341  // -------------------------------------------------------------------------
3342 
3343 #define __MINIMUM_SAMPLE_VALUE( I ) \
3344  pcl::I::pixel_traits::FromSample( result, static_cast<const pcl::I&>( **this ).MinimumSampleValue( rect, firstChannel, lastChannel, maxProcessors ) )
3345 
3352  double MinimumSampleValue( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1, int maxProcessors = 0 ) const
3353  {
3354  double result = 0;
3355  if ( *this )
3356  SOLVE_TEMPLATE( __MINIMUM_SAMPLE_VALUE )
3357  return result;
3358  }
3359 
3360 #undef __MINIMUM_SAMPLE_VALUE
3361 
3362  // -------------------------------------------------------------------------
3363 
3364 #define __MODULUS( I ) \
3365  result = static_cast<const pcl::I&>( **this ).Modulus( rect, firstChannel, lastChannel, maxProcessors )
3366 
3373  double Modulus( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1, int maxProcessors = 0 ) const
3374  {
3375  double result = 0;
3376  if ( *this )
3377  SOLVE_TEMPLATE( __MODULUS )
3378  return result;
3379  }
3380 
3381 #undef __MODULUS
3382 
3383  // -------------------------------------------------------------------------
3384 
3385 #define __MOVE( I ) \
3386  static_cast<pcl::I&>( **this ).Move( scalar, rect, firstChannel, lastChannel )
3387 
3394  template <typename T>
3395  ImageVariant& Move( T scalar, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
3396  {
3397  if ( *this )
3398  SOLVE_TEMPLATE( __MOVE )
3399  return *this;
3400  }
3401 
3402 #undef __MOVE
3403 
3407  template <typename T>
3408  ImageVariant& Mov( T scalar, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
3409  {
3410  return Move( scalar, rect, firstChannel, lastChannel );
3411  }
3412 
3413  // -------------------------------------------------------------------------
3414 
3415 #define __MOVE_1( I ) \
3416  ImageVariant::Move( static_cast<pcl::I&>( **this ), image, point, channel, rect, firstChannel, lastChannel )
3417 
3418 #define __MOVE_2( I ) \
3419  image1.Move( static_cast<const pcl::I&>( *image2 ), point, channel, rect, firstChannel, lastChannel )
3420 
3421 private:
3422 
3423  template <class P> static
3424  void Move( GenericImage<P>& image1, const ImageVariant& image2,
3425  const Point& point, int channel, const Rect& rect, int firstChannel, int lastChannel )
3426  {
3427  SOLVE_TEMPLATE_2( image2, __MOVE_2 )
3428  }
3429 
3430 public:
3431 
3439  const Point& point = Point( int_max ), int channel = -1,
3440  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
3441  {
3442  if ( *this )
3443  if ( image )
3444  SOLVE_TEMPLATE( __MOVE_1 )
3445  return *this;
3446  }
3447 
3448 #undef __MOVE_1
3449 #undef __MOVE_2
3450 
3451  ImageVariant& Mov( const ImageVariant& image,
3452  const Point& point = Point( int_max ), int channel = -1,
3453  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
3454  {
3455  return Move( image, point, channel, rect, firstChannel, lastChannel );
3456  }
3457 
3458  // -------------------------------------------------------------------------
3459 
3460 #define __MULTIPLY( I ) \
3461  static_cast<pcl::I&>( **this ).Multiply( scalar, rect, firstChannel, lastChannel )
3462 
3470  template <typename T>
3471  ImageVariant& Multiply( T scalar, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
3472  {
3473  if ( *this )
3474  SOLVE_TEMPLATE( __MULTIPLY )
3475  return *this;
3476  }
3477 
3478 #undef __MULTIPLY
3479 
3483  template <typename T>
3484  ImageVariant& Mul( T scalar, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
3485  {
3486  return Multiply( scalar, rect, firstChannel, lastChannel );
3487  }
3488 
3489  // -------------------------------------------------------------------------
3490 
3491 #define __MULTIPLY_1( I ) \
3492  ImageVariant::Multiply( static_cast<pcl::I&>( **this ), image, point, channel, rect, firstChannel, lastChannel )
3493 
3494 #define __MULTIPLY_2( I ) \
3495  image1.Multiply( static_cast<const pcl::I&>( *image2 ), point, channel, rect, firstChannel, lastChannel )
3496 
3497 private:
3498 
3499  template <class P> static
3500  void Multiply( GenericImage<P>& image1, const ImageVariant& image2,
3501  const Point& point, int channel, const Rect& rect, int firstChannel, int lastChannel )
3502  {
3503  SOLVE_TEMPLATE_2( image2, __MULTIPLY_2 )
3504  }
3505 
3506 public:
3507 
3516  const Point& point = Point( int_max ), int channel = -1,
3517  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
3518  {
3519  if ( *this )
3520  if ( image )
3521  SOLVE_TEMPLATE( __MULTIPLY_1 )
3522  return *this;
3523  }
3524 
3525 #undef __MULTIPLY_1
3526 #undef __MULTIPLY_2
3527 
3532  const Point& point = Point( int_max ), int channel = -1,
3533  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
3534  {
3535  return Multiply( image, point, channel, rect, firstChannel, lastChannel );
3536  }
3537 
3538  // -------------------------------------------------------------------------
3539 
3540 #define __MULTIPLIED( I ) \
3541  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Multiplied( scalar, rect, firstChannel, lastChannel ) ) ); \
3542  result.SetOwnership( true )
3543 
3551  template <typename T>
3552  ImageVariant Multiplied( T scalar, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
3553  {
3554  ImageVariant result;
3555  if ( *this )
3556  SOLVE_TEMPLATE( __MULTIPLIED )
3557  return result;
3558  }
3559 
3560 #undef __MULTIPLIED
3561 
3562  // -------------------------------------------------------------------------
3563 
3564 #define __NAND( I ) \
3565  static_cast<pcl::I&>( **this ).Nand( scalar, rect, firstChannel, lastChannel )
3566 
3574  template <typename T>
3575  ImageVariant& Nand( T scalar, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
3576  {
3577  if ( *this )
3578  SOLVE_TEMPLATE_REAL( __NAND )
3579  return *this;
3580  }
3581 
3582 #undef __NAND
3583 
3584  // -------------------------------------------------------------------------
3585 
3586 #define __NAND_1( I ) \
3587  ImageVariant::Nand( static_cast<pcl::I&>( **this ), image, point, channel, rect, firstChannel, lastChannel )
3588 
3589 #define __NAND_2( I ) \
3590  image1.Nand( static_cast<const pcl::I&>( *image2 ), point, channel, rect, firstChannel, lastChannel )
3591 
3592 private:
3593 
3594  template <class P> static
3595  void Nand( GenericImage<P>& image1, const ImageVariant& image2,
3596  const Point& point, int channel, const Rect& rect, int firstChannel, int lastChannel )
3597  {
3598  SOLVE_TEMPLATE_REAL_2( image2, __NAND_2 )
3599  }
3600 
3601 public:
3602 
3611  const Point& point = Point( int_max ), int channel = -1,
3612  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
3613  {
3614  if ( *this )
3615  if ( image )
3616  SOLVE_TEMPLATE_REAL( __NAND_1 )
3617  return *this;
3618  }
3619 
3620 #undef __NAND_1
3621 #undef __NAND_2
3622 
3623  // -------------------------------------------------------------------------
3624 
3625 #define __NOR( I ) \
3626  static_cast<pcl::I&>( **this ).Nor( scalar, rect, firstChannel, lastChannel )
3627 
3635  template <typename T>
3636  ImageVariant& Nor( T scalar, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
3637  {
3638  if ( *this )
3639  SOLVE_TEMPLATE_REAL( __NOR )
3640  return *this;
3641  }
3642 
3643 #undef __NOR
3644 
3645  // -------------------------------------------------------------------------
3646 
3647 #define __NOR_1( I ) \
3648  ImageVariant::Nor( static_cast<pcl::I&>( **this ), image, point, channel, rect, firstChannel, lastChannel )
3649 
3650 #define __NOR_2( I ) \
3651  image1.Nor( static_cast<const pcl::I&>( *image2 ), point, channel, rect, firstChannel, lastChannel )
3652 
3653 private:
3654 
3655  template <class P> static
3656  void Nor( GenericImage<P>& image1, const ImageVariant& image2,
3657  const Point& point, int channel, const Rect& rect, int firstChannel, int lastChannel )
3658  {
3659  SOLVE_TEMPLATE_REAL_2( image2, __NOR_2 )
3660  }
3661 
3662 public:
3663 
3672  const Point& point = Point( int_max ), int channel = -1,
3673  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
3674  {
3675  if ( *this )
3676  if ( image )
3677  SOLVE_TEMPLATE_REAL( __NOR_1 )
3678  return *this;
3679  }
3680 
3681 #undef __NOR_1
3682 #undef __NOR_2
3683 
3684  // -------------------------------------------------------------------------
3685 
3686 #define __NORM( I ) \
3687  result = static_cast<const pcl::I&>( **this ).Norm( rect, firstChannel, lastChannel, maxProcessors )
3688 
3695  double Norm( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1, int maxProcessors = 0 ) const
3696  {
3697  double result = 0;
3698  if ( *this )
3699  SOLVE_TEMPLATE( __NORM )
3700  return result;
3701  }
3702 
3703 #undef __NORM
3704 
3705  // -------------------------------------------------------------------------
3706 
3707 #define __NORMALIZE( I ) \
3708  static_cast<pcl::I&>( **this ).Normalize( lowerBound, upperBound, rect, firstChannel, lastChannel )
3709 
3717  template <typename T>
3718  ImageVariant& Normalize( T lowerBound, T upperBound, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
3719  {
3720  if ( *this )
3721  SOLVE_TEMPLATE_REAL( __NORMALIZE )
3722  return *this;
3723  }
3724 
3725 #undef __NORMALIZE
3726 
3727  // -------------------------------------------------------------------------
3728 
3729 #define __NORMALIZE( I ) \
3730  static_cast<pcl::I&>( **this ).Normalize( rect, firstChannel, lastChannel )
3731 
3739  ImageVariant& Normalize( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
3740  {
3741  if ( *this )
3742  SOLVE_TEMPLATE_REAL( __NORMALIZE )
3743  return *this;
3744  }
3745 
3746 #undef __NORMALIZE
3747 
3748  // -------------------------------------------------------------------------
3749 
3750 #define __NORMALIZED( I ) \
3751  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Normalized( lowerBound, upperBound, rect, firstChannel, lastChannel ) ) ); \
3752  result.SetOwnership( true )
3753 
3761  template <typename T>
3762  ImageVariant Normalized( T lowerBound, T upperBound, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
3763  {
3764  ImageVariant result;
3765  if ( *this )
3766  SOLVE_TEMPLATE_REAL( __NORMALIZED )
3767  return result;
3768  }
3769 
3770 #undef __NORMALIZED
3771 
3772  // -------------------------------------------------------------------------
3773 
3774 #define __NORMALIZED( I ) \
3775  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Normalized( rect, firstChannel, lastChannel ) ) ); \
3776  result.SetOwnership( true )
3777 
3785  ImageVariant Normalized( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
3786  {
3787  ImageVariant result;
3788  if ( *this )
3789  SOLVE_TEMPLATE_REAL( __NORMALIZED )
3790  return result;
3791  }
3792 
3793 #undef __NORMALIZED
3794 
3795  // -------------------------------------------------------------------------
3796 
3797 #define __NOT( I ) \
3798  static_cast<pcl::I&>( **this ).Not( rect, firstChannel, lastChannel )
3799 
3806  ImageVariant& Not( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
3807  {
3808  if ( *this )
3809  SOLVE_TEMPLATE_REAL( __NOT )
3810  return *this;
3811  }
3812 
3813 #undef __NOT
3814 
3815  // -------------------------------------------------------------------------
3816 
3817 #define __ONE( I ) \
3818  static_cast<pcl::I&>( **this ).One( rect, firstChannel, lastChannel )
3819 
3827  ImageVariant& One( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
3828  {
3829  if ( *this )
3830  SOLVE_TEMPLATE_REAL( __ONE )
3831  return *this;
3832  }
3833 
3834 #undef __ONE
3835 
3836  // -------------------------------------------------------------------------
3837 
3838 #define __MULTIPLY( I ) \
3839  static_cast<pcl::I&>( **this ) *= scalar
3840 
3844  template <typename T>
3845  ImageVariant& operator *=( T scalar )
3846  {
3847  if ( *this )
3848  SOLVE_TEMPLATE( __MULTIPLY )
3849  return *this;
3850  }
3851 
3852 #undef __MULTIPLY
3853 
3854  // -------------------------------------------------------------------------
3855 
3856 #define __MULTIPLY_1( I ) \
3857  ImageVariant::Multiply( static_cast<pcl::I&>( **this ), image )
3858 
3859 #define __MULTIPLY_2( I ) \
3860  image1 *= static_cast<const pcl::I&>( *image2 )
3861 
3862 private:
3863 
3864  template <class P> static
3865  void Multiply( GenericImage<P>& image1, const ImageVariant& image2 )
3866  {
3867  SOLVE_TEMPLATE_2( image2, __MULTIPLY_2 )
3868  }
3869 
3870 public:
3871 
3875  ImageVariant& operator *=( const ImageVariant& image )
3876  {
3877  if ( *this )
3878  if ( image )
3879  SOLVE_TEMPLATE( __MULTIPLY_1 )
3880  return *this;
3881  }
3882 
3883 #undef __MULTIPLY_1
3884 #undef __MULTIPLY_2
3885 
3886  // -------------------------------------------------------------------------
3887 
3888 #define __ADD( I ) \
3889  static_cast<pcl::I&>( **this ) += scalar
3890 
3894  template <typename T>
3895  ImageVariant& operator +=( T scalar )
3896  {
3897  if ( *this )
3898  SOLVE_TEMPLATE( __ADD )
3899  return *this;
3900  }
3901 
3902 #undef __ADD
3903 
3904  // -------------------------------------------------------------------------
3905 
3906 #define __ADD_1( I ) \
3907  ImageVariant::Add( static_cast<pcl::I&>( **this ), image )
3908 
3909 #define __ADD_2( I ) \
3910  image1 += static_cast<const pcl::I&>( *image2 )
3911 
3912 private:
3913 
3914  template <class P> static
3915  void Add( GenericImage<P>& image1, const ImageVariant& image2 )
3916  {
3917  SOLVE_TEMPLATE_2( image2, __ADD_2 )
3918  }
3919 
3920 public:
3921 
3925  ImageVariant& operator +=( const ImageVariant& image )
3926  {
3927  if ( *this )
3928  if ( image )
3929  SOLVE_TEMPLATE( __ADD_1 )
3930  return *this;
3931  }
3932 
3933 #undef __ADD_1
3934 #undef __ADD_2
3935 
3936  // -------------------------------------------------------------------------
3937 
3938 #define __SUBTRACT( I ) \
3939  static_cast<pcl::I&>( **this ) -= scalar
3940 
3944  template <typename T>
3945  ImageVariant& operator -=( T scalar )
3946  {
3947  if ( *this )
3948  SOLVE_TEMPLATE( __SUBTRACT )
3949  return *this;
3950  }
3951 
3952 #undef __SUBTRACT
3953 
3954  // -------------------------------------------------------------------------
3955 
3956 #define __SUBTRACT_1( I ) \
3957  ImageVariant::Subtract( static_cast<pcl::I&>( **this ), image )
3958 
3959 #define __SUBTRACT_2( I ) \
3960  image1 -= static_cast<const pcl::I&>( *image2 )
3961 
3962 private:
3963 
3964  template <class P> static
3965  void Subtract( GenericImage<P>& image1, const ImageVariant& image2 )
3966  {
3967  SOLVE_TEMPLATE_2( image2, __SUBTRACT_2 )
3968  }
3969 
3970 public:
3971 
3975  ImageVariant& operator -=( const ImageVariant& image )
3976  {
3977  if ( *this )
3978  if ( image )
3979  SOLVE_TEMPLATE( __SUBTRACT_1 )
3980  return *this;
3981  }
3982 
3983 #undef __SUBTRACT_1
3984 #undef __SUBTRACT_2
3985 
3986  // -------------------------------------------------------------------------
3987 
3988 #define __DIVIDE( I ) \
3989  static_cast<pcl::I&>( **this ) /= scalar
3990 
3994  template <typename T>
3995  ImageVariant& operator /=( T scalar )
3996  {
3997  if ( *this )
3998  SOLVE_TEMPLATE( __DIVIDE )
3999  return *this;
4000  }
4001 
4002 #undef __DIVIDE
4003 
4004  // -------------------------------------------------------------------------
4005 
4006 #define __DIVIDE_1( I ) \
4007  ImageVariant::Divide( static_cast<pcl::I&>( **this ), image )
4008 
4009 #define __DIVIDE_2( I ) \
4010  image1 /= static_cast<const pcl::I&>( *image2 )
4011 
4012 private:
4013 
4014  template <class P> static
4015  void Divide( GenericImage<P>& image1, const ImageVariant& image2 )
4016  {
4017  SOLVE_TEMPLATE_2( image2, __DIVIDE_2 )
4018  }
4019 
4020 public:
4021 
4025  ImageVariant& operator /=( const ImageVariant& image )
4026  {
4027  if ( *this )
4028  if ( image )
4029  SOLVE_TEMPLATE( __DIVIDE_1 )
4030  return *this;
4031  }
4032 
4033 #undef __DIVIDE_1
4034 #undef __DIVIDE_2
4035 
4036  // -------------------------------------------------------------------------
4037 
4038 #define __RAISE( I ) \
4039  static_cast<pcl::I&>( **this ) ^= scalar
4040 
4044  template <typename T>
4045  ImageVariant& operator ^=( T scalar )
4046  {
4047  if ( *this )
4048  SOLVE_TEMPLATE( __RAISE )
4049  return *this;
4050  }
4051 
4052 #undef __RAISE
4053 
4054  // -------------------------------------------------------------------------
4055 
4056 #define __RAISE_1( I ) \
4057  ImageVariant::Raise( static_cast<pcl::I&>( **this ), image )
4058 
4059 #define __RAISE_2( I ) \
4060  image1 ^= static_cast<const pcl::I&>( *image2 )
4061 
4062 private:
4063 
4064  template <class P> static
4065  void Raise( GenericImage<P>& image1, const ImageVariant& image2 )
4066  {
4067  SOLVE_TEMPLATE_2( image2, __RAISE_2 )
4068  }
4069 
4070 public:
4071 
4075  ImageVariant& operator ^=( const ImageVariant& image )
4076  {
4077  if ( *this )
4078  if ( image )
4079  SOLVE_TEMPLATE( __RAISE_1 )
4080  return *this;
4081  }
4082 
4083 #undef __RAISE_1
4084 #undef __RAISE_2
4085 
4086  // -------------------------------------------------------------------------
4087 
4088 #define __INVERTED( I ) \
4089  result.SetImage( *new pcl::I( ~static_cast<const pcl::I&>( **this ) ) ); \
4090  result.SetOwnership( true )
4091 
4100  ImageVariant operator ~() const
4101  {
4102  ImageVariant result;
4103  if ( *this )
4104  SOLVE_TEMPLATE( __INVERTED )
4105  return result;
4106  }
4107 
4108 #undef __INVERTED
4109 
4110  // -------------------------------------------------------------------------
4111 
4112 #define __OR( I ) \
4113  static_cast<pcl::I&>( **this ).Or( scalar, rect, firstChannel, lastChannel )
4114 
4122  template <typename T>
4123  ImageVariant& Or( T scalar, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4124  {
4125  if ( *this )
4126  SOLVE_TEMPLATE_REAL( __OR )
4127  return *this;
4128  }
4129 
4130 #undef __OR
4131 
4132  // -------------------------------------------------------------------------
4133 
4134 #define __OR_1( I ) \
4135  ImageVariant::Or( static_cast<pcl::I&>( **this ), image, point, channel, rect, firstChannel, lastChannel )
4136 
4137 #define __OR_2( I ) \
4138  image1.Or( static_cast<const pcl::I&>( *image2 ), point, channel, rect, firstChannel, lastChannel )
4139 
4140 private:
4141 
4142  template <class P> static
4143  void Or( GenericImage<P>& image1, const ImageVariant& image2,
4144  const Point& point, int channel, const Rect& rect, int firstChannel, int lastChannel )
4145  {
4146  SOLVE_TEMPLATE_REAL_2( image2, __OR_2 )
4147  }
4148 
4149 public:
4150 
4158  ImageVariant& Or( const ImageVariant& image,
4159  const Point& point = Point( int_max ), int channel = -1,
4160  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4161  {
4162  if ( *this )
4163  if ( image )
4164  SOLVE_TEMPLATE_REAL( __OR_1 )
4165  return *this;
4166  }
4167 
4168 #undef __OR_1
4169 #undef __OR_2
4170 
4171  // -------------------------------------------------------------------------
4172 
4173 #define __RAISE( I ) \
4174  static_cast<pcl::I&>( **this ).Raise( scalar, rect, firstChannel, lastChannel )
4175 
4182  template <typename T>
4183  ImageVariant& Raise( T scalar, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4184  {
4185  if ( *this )
4186  SOLVE_TEMPLATE( __RAISE )
4187  return *this;
4188  }
4189 
4190 #undef __RAISE
4191 
4195  template <typename T>
4196  ImageVariant& Pow( T scalar, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4197  {
4198  return Raise( scalar, rect, firstChannel, lastChannel );
4199  }
4200 
4201  // -------------------------------------------------------------------------
4202 
4203 #define __Qn( I ) \
4204  result = static_cast<const pcl::I&>( **this ).Qn( rect, firstChannel, lastChannel, maxProcessors )
4205 
4212  double Qn( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1, int maxProcessors = 0 ) const
4213  {
4214  double result = false;
4215  if ( *this )
4216  SOLVE_TEMPLATE( __Qn )
4217  return result;
4218  }
4219 
4220 #undef __Qn
4221 
4222  // -------------------------------------------------------------------------
4223 
4224 #define __RAISE_1( I ) \
4225  ImageVariant::Raise( static_cast<pcl::I&>( **this ), image, point, channel, rect, firstChannel, lastChannel )
4226 
4227 #define __RAISE_2( I ) \
4228  image1.Raise( static_cast<const pcl::I&>( *image2 ), point, channel, rect, firstChannel, lastChannel )
4229 
4230 private:
4231 
4232  template <class P> static
4233  void Raise( GenericImage<P>& image1, const ImageVariant& image2,
4234  const Point& point, int channel, const Rect& rect, int firstChannel, int lastChannel )
4235  {
4236  SOLVE_TEMPLATE_2( image2, __RAISE_2 )
4237  }
4238 
4239 public:
4240 
4249  const Point& point = Point( int_max ), int channel = -1,
4250  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4251  {
4252  if ( *this )
4253  if ( image )
4254  SOLVE_TEMPLATE( __RAISE_1 )
4255  return *this;
4256  }
4257 
4258 #undef __RAISE_1
4259 #undef __RAISE_2
4260 
4265  const Point& point = Point( int_max ), int channel = -1,
4266  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4267  {
4268  return Raise( image, point, channel, rect, firstChannel, lastChannel );
4269  }
4270 
4271  // -------------------------------------------------------------------------
4272 
4273 #define __RAISED( I ) \
4274  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Raised( scalar, rect, firstChannel, lastChannel ) ) ); \
4275  result.SetOwnership( true )
4276 
4283  template <typename T>
4284  ImageVariant Raised( T scalar, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
4285  {
4286  ImageVariant result;
4287  if ( *this )
4288  SOLVE_TEMPLATE( __RAISED )
4289  return result;
4290  }
4291 
4292 #undef __RAISED
4293 
4294  // -------------------------------------------------------------------------
4295 
4296 #define __READ( I ) \
4297  static_cast<pcl::I&>( **this ).Read( file )
4298 
4306  {
4307  if ( *this )
4308  SOLVE_TEMPLATE( __READ )
4309  return *this;
4310  }
4311 
4312 #undef __READ
4313 
4314  // -------------------------------------------------------------------------
4315 
4316 #define __READ( I ) \
4317  static_cast<pcl::I&>( **this ).Read( filePath )
4318 
4325  ImageVariant& Read( const String& filePath )
4326  {
4327  if ( *this )
4328  SOLVE_TEMPLATE( __READ )
4329  return *this;
4330  }
4331 
4332 #undef __READ
4333 
4334  // -------------------------------------------------------------------------
4335 
4336 #define __RESCALE( I ) \
4337  static_cast<pcl::I&>( **this ).Rescale( lowerBound, upperBound, rect, firstChannel, lastChannel )
4338 
4345  template <typename T>
4346  ImageVariant& Rescale( T lowerBound, T upperBound, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4347  {
4348  if ( *this )
4349  SOLVE_TEMPLATE_REAL( __RESCALE )
4350  return *this;
4351  }
4352 
4353 #undef __RESCALE
4354 
4355  // -------------------------------------------------------------------------
4356 
4357 #define __RESCALE( I ) \
4358  static_cast<pcl::I&>( **this ).Rescale( rect, firstChannel, lastChannel )
4359 
4366  ImageVariant& Rescale( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4367  {
4368  if ( *this )
4369  SOLVE_TEMPLATE_REAL( __RESCALE )
4370  return *this;
4371  }
4372 
4373 #undef __RESCALE
4374 
4375  // -------------------------------------------------------------------------
4376 
4377 #define __RESCALED( I ) \
4378  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Rescaled( lowerBound, upperBound, rect, firstChannel, lastChannel ) ) ); \
4379  result.SetOwnership( true )
4380 
4388  template <typename T>
4389  ImageVariant Rescaled( T lowerBound, T upperBound, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
4390  {
4391  ImageVariant result;
4392  if ( *this )
4393  SOLVE_TEMPLATE_REAL( __RESCALED )
4394  return result;
4395  }
4396 
4397 #undef __RESCALED
4398 
4399  // -------------------------------------------------------------------------
4400 
4401 #define __RESCALED( I ) \
4402  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Rescaled( rect, firstChannel, lastChannel ) ) ); \
4403  result.SetOwnership( true )
4404 
4412  ImageVariant Rescaled( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
4413  {
4414  ImageVariant result;
4415  if ( *this )
4416  SOLVE_TEMPLATE_REAL( __RESCALED )
4417  return result;
4418  }
4419 
4420 #undef __RESCALED
4421 
4422  // -------------------------------------------------------------------------
4423 
4424 #define __SET_ABSOLUTE_DIFFERENCE( I ) \
4425  static_cast<pcl::I&>( **this ).SetAbsoluteDifference( scalar, rect, firstChannel, lastChannel )
4426 
4435  template <typename T>
4436  ImageVariant& SetAbsoluteDifference( T scalar, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4437  {
4438  if ( *this )
4439  SOLVE_TEMPLATE( __SET_ABSOLUTE_DIFFERENCE )
4440  return *this;
4441  }
4442 
4443 #undef __SET_ABSOLUTE_DIFFERENCE
4444 
4448  template <typename T>
4449  ImageVariant& Dif( T scalar, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4450  {
4451  return SetAbsoluteDifference( scalar, rect, firstChannel, lastChannel );
4452  }
4453 
4454  // -------------------------------------------------------------------------
4455 
4456 #define __SET_ABSOLUTE_DIFFERENCE_1( I ) \
4457  ImageVariant::SetAbsoluteDifference( static_cast<pcl::I&>( **this ), image, point, channel, rect, firstChannel, lastChannel )
4458 
4459 #define __SET_ABSOLUTE_DIFFERENCE_2( I ) \
4460  image1.SetAbsoluteDifference( static_cast<const pcl::I&>( *image2 ), point, channel, rect, firstChannel, lastChannel )
4461 
4462 private:
4463 
4464  template <class P> static
4465  void SetAbsoluteDifference( GenericImage<P>& image1, const ImageVariant& image2,
4466  const Point& point, int channel, const Rect& rect, int firstChannel, int lastChannel )
4467  {
4468  SOLVE_TEMPLATE_2( image2, __SET_ABSOLUTE_DIFFERENCE_2 )
4469  }
4470 
4471 public:
4472 
4482  const Point& point = Point( int_max ), int channel = -1,
4483  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4484  {
4485  if ( *this )
4486  if ( image )
4487  SOLVE_TEMPLATE( __SET_ABSOLUTE_DIFFERENCE_1 )
4488  return *this;
4489  }
4490 
4491 #undef __SET_ABSOLUTE_DIFFERENCE_1
4492 #undef __SET_ABSOLUTE_DIFFERENCE_2
4493 
4494  ImageVariant& Dif( const ImageVariant& image,
4495  const Point& point = Point( int_max ), int channel = -1,
4496  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4497  {
4498  return SetAbsoluteDifference( image, point, channel, rect, firstChannel, lastChannel );
4499  }
4500 
4501  // -------------------------------------------------------------------------
4502 
4503 #define __SET_ABSOLUTE_VALUE( I ) \
4504  static_cast<pcl::I&>( **this ).SetAbsoluteValue( rect, firstChannel, lastChannel )
4505 
4513  ImageVariant& SetAbsoluteValue( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4514  {
4515  if ( *this )
4516  SOLVE_TEMPLATE( __SET_ABSOLUTE_VALUE )
4517  return *this;
4518  }
4519 
4520  ImageVariant& Abs( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4521  {
4522  return SetAbsoluteValue( rect, firstChannel, lastChannel );
4523  }
4524 
4525 #undef __SET_ABSOLUTE_VALUE
4526 
4527  // -------------------------------------------------------------------------
4528 
4529 #define __SET_COLOR_SPACE( I ) \
4530  static_cast<pcl::I&>( **this ).SetColorSpace( colorSpace, maxProcessors )
4531 
4539  ImageVariant& SetColorSpace( color_space colorSpace, int maxProcessors = 0 )
4540  {
4541  if ( *this )
4542  SOLVE_TEMPLATE( __SET_COLOR_SPACE )
4543  return *this;
4544  }
4545 
4546 #undef __SET_COLOR_SPACE
4547 
4548  // -------------------------------------------------------------------------
4549 
4550 #define __SET_COLUMN( I ) \
4551  static_cast<pcl::I&>( **this ).SetColumn( buffer, x, channel )
4552 
4560  template <typename T>
4561  ImageVariant& SetColumn( const T* buffer, int x, int channel = -1 )
4562  {
4563  PCL_PRECONDITION( buffer != 0 )
4564  if ( *this )
4565  SOLVE_TEMPLATE( __SET_COLUMN )
4566  return *this;
4567  }
4568 
4569 #undef __SET_COLUMN
4570 
4571  // -------------------------------------------------------------------------
4572 
4573 #define __SET_LIGHTNESS_1( I ) \
4574  ImageVariant::SetLightness( static_cast<pcl::I&>( **this ), L, point, rect, maxProcessors )
4575 
4576 #define __SET_LIGHTNESS_2( I ) \
4577  image.SetLightness( static_cast<const pcl::I&>( *L ), point, rect, maxProcessors )
4578 
4579 private:
4580 
4581  template <class P> static
4582  void SetLightness( GenericImage<P>& image, const ImageVariant& L,
4583  const Point& point, const Rect& rect, int maxProcessors )
4584  {
4585  if ( !L.IsComplexSample() )
4586  SOLVE_TEMPLATE_REAL_2( L, __SET_LIGHTNESS_2 )
4587  }
4588 
4589 public:
4590 
4599  const Point& point = Point( int_max ),
4600  const Rect& rect = Rect( 0 ), int maxProcessors = 0 )
4601  {
4602  if ( *this )
4603  if ( !IsComplexSample() )
4604  if ( L )
4605  SOLVE_TEMPLATE_REAL( __SET_LIGHTNESS_1 )
4606  return *this;
4607  }
4608 
4609 #undef __SET_LIGHTNESS_1
4610 #undef __SET_LIGHTNESS_2
4611 
4612  // -------------------------------------------------------------------------
4613 
4614 #define __SET_LUMINANCE_1( I ) \
4615  ImageVariant::SetLuminance( static_cast<pcl::I&>( **this ), Y, point, rect, maxProcessors )
4616 
4617 #define __SET_LUMINANCE_2( I ) \
4618  image.SetLuminance( static_cast<const pcl::I&>( *Y ), point, rect, maxProcessors )
4619 
4620 private:
4621 
4622  template <class P> static
4623  void SetLuminance( GenericImage<P>& image, const ImageVariant& Y,
4624  const Point& point, const Rect& rect, int maxProcessors )
4625  {
4626  if ( !Y.IsComplexSample() )
4627  SOLVE_TEMPLATE_REAL_2( Y, __SET_LUMINANCE_2 )
4628  }
4629 
4630 public:
4631 
4640  const Point& point = Point( int_max ),
4641  const Rect& rect = Rect( 0 ), int maxProcessors = 0 )
4642  {
4643  if ( *this )
4644  if ( !IsComplexSample() )
4645  if ( Y )
4646  SOLVE_TEMPLATE_REAL( __SET_LUMINANCE_1 )
4647  return *this;
4648  }
4649 
4650 #undef __SET_LUMINANCE_1
4651 #undef __SET_LUMINANCE_2
4652 
4653  // -------------------------------------------------------------------------
4654 
4655 #define __SET_MAXIMUM( I ) \
4656  static_cast<pcl::I&>( **this ).SetMaximum( scalar, rect, firstChannel, lastChannel )
4657 
4665  template <typename T>
4666  ImageVariant& SetMaximum( T scalar, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4667  {
4668  if ( *this )
4669  SOLVE_TEMPLATE( __SET_MAXIMUM )
4670  return *this;
4671  }
4672 
4673 #undef __SET_MAXIMUM
4674 
4678  template <typename T>
4679  ImageVariant& Max( T scalar, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4680  {
4681  return SetMaximum( scalar, rect, firstChannel, lastChannel );
4682  }
4683 
4684  // -------------------------------------------------------------------------
4685 
4686 #define __SET_MAXIMUM_1( I ) \
4687  ImageVariant::SetMaximum( static_cast<pcl::I&>( **this ), image, point, channel, rect, firstChannel, lastChannel )
4688 
4689 #define __SET_MAXIMUM_2( I ) \
4690  image1.SetMaximum( static_cast<const pcl::I&>( *image2 ), point, channel, rect, firstChannel, lastChannel )
4691 
4692 private:
4693 
4694  template <class P> static
4695  void SetMaximum( GenericImage<P>& image1, const ImageVariant& image2,
4696  const Point& point, int channel, const Rect& rect, int firstChannel, int lastChannel )
4697  {
4698  SOLVE_TEMPLATE_2( image2, __SET_MAXIMUM_2 )
4699  }
4700 
4701 public:
4702 
4712  const Point& point = Point( int_max ), int channel = -1,
4713  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4714  {
4715  if ( *this )
4716  if ( image )
4717  SOLVE_TEMPLATE( __SET_MAXIMUM_1 )
4718  return *this;
4719  }
4720 
4721 #undef __SET_MAXIMUM_1
4722 #undef __SET_MAXIMUM_2
4723 
4728  const Point& point = Point( int_max ), int channel = -1,
4729  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4730  {
4731  return SetMaximum( image, point, channel, rect, firstChannel, lastChannel );
4732  }
4733 
4734  // -------------------------------------------------------------------------
4735 
4736 #define __SET_MINIMUM( I ) \
4737  static_cast<pcl::I&>( **this ).SetMinimum( scalar, rect, firstChannel, lastChannel )
4738 
4746  template <typename T>
4747  ImageVariant& SetMinimum( T scalar, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4748  {
4749  if ( *this )
4750  SOLVE_TEMPLATE( __SET_MINIMUM )
4751  return *this;
4752  }
4753 
4754 #undef __SET_MINIMUM
4755 
4759  template <typename T>
4760  ImageVariant& Min( T scalar, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4761  {
4762  return SetMinimum( scalar, rect, firstChannel, lastChannel );
4763  }
4764 
4765  // -------------------------------------------------------------------------
4766 
4767 #define __SET_MINIMUM_1( I ) \
4768  ImageVariant::SetMinimum( static_cast<pcl::I&>( **this ), image, point, channel, rect, firstChannel, lastChannel )
4769 
4770 #define __SET_MINIMUM_2( I ) \
4771  image1.SetMinimum( static_cast<const pcl::I&>( *image2 ), point, channel, rect, firstChannel, lastChannel )
4772 
4773 private:
4774 
4775  template <class P> static
4776  void SetMinimum( GenericImage<P>& image1, const ImageVariant& image2,
4777  const Point& point, int channel, const Rect& rect, int firstChannel, int lastChannel )
4778  {
4779  SOLVE_TEMPLATE_2( image2, __SET_MINIMUM_2 )
4780  }
4781 
4782 public:
4783 
4793  const Point& point = Point( int_max ), int channel = -1,
4794  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4795  {
4796  if ( *this )
4797  if ( image )
4798  SOLVE_TEMPLATE( __SET_MINIMUM_1 )
4799  return *this;
4800  }
4801 
4802 #undef __SET_MINIMUM_1
4803 #undef __SET_MINIMUM_2
4804 
4809  const Point& point = Point( int_max ), int channel = -1,
4810  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
4811  {
4812  return SetMinimum( image, point, channel, rect, firstChannel, lastChannel );
4813  }
4814 
4815  // -------------------------------------------------------------------------
4816 
4817 #define __Sn( I ) \
4818  result = static_cast<const pcl::I&>( **this ).Sn( rect, firstChannel, lastChannel, maxProcessors )
4819 
4826  double Sn( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1, int maxProcessors = 0 ) const
4827  {
4828  double result = false;
4829  if ( *this )
4830  SOLVE_TEMPLATE( __Sn )
4831  return result;
4832  }
4833 
4834 #undef __Sn
4835 
4836  // -------------------------------------------------------------------------
4837 
4838 #define __SET_ROW( I ) \
4839  static_cast<pcl::I&>( **this ).SetRow( buffer, y, channel )
4840 
4848  template <typename T>
4849  ImageVariant& SetRow( const T* buffer, int y, int channel = -1 )
4850  {
4851  PCL_PRECONDITION( buffer != 0 )
4852  if ( *this )
4853  SOLVE_TEMPLATE( __SET_ROW )
4854  return *this;
4855  }
4856 
4857 #undef __SET_ROW
4858 
4859  // -------------------------------------------------------------------------
4860 
4861 #define __ENSURE_UNIQUE_IMAGE( I ) \
4862  static_cast<pcl::I&>( **this ).EnsureUnique()
4863 
4873  {
4874  if ( *this )
4875  SOLVE_TEMPLATE( __ENSURE_UNIQUE_IMAGE )
4876  return *this;
4877  }
4878 
4879 #undef __ENSURE_UNIQUE_IMAGE
4880 
4881  // -------------------------------------------------------------------------
4882 
4883 #define __ENSURE_LOCAL_IMAGE( I ) \
4884  static_cast<pcl::I&>( **this ).EnsureLocal()
4885 
4894  {
4895  if ( *this )
4896  SOLVE_TEMPLATE( __ENSURE_LOCAL_IMAGE )
4897  return *this;
4898  }
4899 
4900 #undef __ENSURE_LOCAL_IMAGE
4901 
4902  // -------------------------------------------------------------------------
4903 
4904 #define __SHIFT( I ) \
4905  static_cast<pcl::I&>( **this ).Shift( fillValues )
4906 
4913  template <typename T>
4914  ImageVariant& Shift( const GenericVector<T>& fillValues )
4915  {
4916  if ( *this )
4917  SOLVE_TEMPLATE( __SHIFT )
4918  return *this;
4919  }
4920 
4921 #undef __SHIFT
4922 
4923  // -------------------------------------------------------------------------
4924 
4925 #define __SHIFT( I ) \
4926  static_cast<pcl::I&>( **this ).Shift()
4927 
4936  {
4937  if ( *this )
4938  SOLVE_TEMPLATE( __SHIFT )
4939  return *this;
4940  }
4941 
4942 #undef __SHIFT
4943 
4944  // -------------------------------------------------------------------------
4945 
4946 #define __SHIFT_BY( I ) \
4947  static_cast<pcl::I&>( **this ).ShiftBy( dx, dy, fillValues )
4948 
4955  template <typename T>
4956  ImageVariant& ShiftBy( int dx, int dy, const GenericVector<T>& fillValues )
4957  {
4958  if ( *this )
4959  SOLVE_TEMPLATE( __SHIFT_BY )
4960  return *this;
4961  }
4962 
4963 #undef __SHIFT_BY
4964 
4965  // -------------------------------------------------------------------------
4966 
4967 #define __SHIFT_BY( I ) \
4968  static_cast<pcl::I&>( **this ).ShiftBy( dx, dy )
4969 
4977  ImageVariant& ShiftBy( int dx, int dy )
4978  {
4979  if ( *this )
4980  SOLVE_TEMPLATE( __SHIFT_BY )
4981  return *this;
4982  }
4983 
4984 #undef __SHIFT_BY
4985 
4986  // -------------------------------------------------------------------------
4987 
4988 #define __SHIFT_TO( I ) \
4989  static_cast<pcl::I&>( **this ).ShiftTo( x, y, fillValues )
4990 
4997  template <typename T>
4998  ImageVariant& ShiftTo( int x, int y, const GenericVector<T>& fillValues )
4999  {
5000  if ( *this )
5001  SOLVE_TEMPLATE( __SHIFT_TO )
5002  return *this;
5003  }
5004 
5005 #undef __SHIFT_TO
5006 
5007  // -------------------------------------------------------------------------
5008 
5009 #define __SHIFT_TO( I ) \
5010  static_cast<pcl::I&>( **this ).ShiftTo( x, y )
5011 
5019  ImageVariant& ShiftTo( int x, int y )
5020  {
5021  if ( *this )
5022  SOLVE_TEMPLATE( __SHIFT_TO )
5023  return *this;
5024  }
5025 
5026 #undef __SHIFT_TO
5027 
5028  // -------------------------------------------------------------------------
5029 
5030 #define __SHIFT_TO( I ) \
5031  static_cast<pcl::I&>( **this ).ShiftTo( p, fillValues )
5032 
5039  template <typename T>
5040  ImageVariant& ShiftTo( const Point& p, const GenericVector<T>& fillValues )
5041  {
5042  if ( *this )
5043  SOLVE_TEMPLATE( __SHIFT_TO )
5044  return *this;
5045  }
5046 
5047 #undef __SHIFT_TO
5048 
5049  // -------------------------------------------------------------------------
5050 
5051 #define __SHIFT_TO( I ) \
5052  static_cast<pcl::I&>( **this ).ShiftTo( p )
5053 
5062  {
5063  if ( *this )
5064  SOLVE_TEMPLATE( __SHIFT_TO )
5065  return *this;
5066  }
5067 
5068 #undef __SHIFT_TO
5069 
5070  // -------------------------------------------------------------------------
5071 
5072 #define __SHIFT_TO_BOTTOM_LEFT( I ) \
5073  static_cast<pcl::I&>( **this ).ShiftToBottomLeft( width, height, fillValues )
5074 
5082  template <typename T>
5083  ImageVariant& ShiftToBottomLeft( int width, int height, const GenericVector<T>& fillValues )
5084  {
5085  if ( *this )
5086  SOLVE_TEMPLATE( __SHIFT_TO_BOTTOM_LEFT )
5087  return *this;
5088  }
5089 
5090 #undef __SHIFT_TO_BOTTOM_LEFT
5091 
5092  // -------------------------------------------------------------------------
5093 
5094 #define __SHIFT_TO_BOTTOM_LEFT( I ) \
5095  static_cast<pcl::I&>( **this ).ShiftToBottomLeft( width, height )
5096 
5106  ImageVariant& ShiftToBottomLeft( int width, int height )
5107  {
5108  if ( *this )
5109  SOLVE_TEMPLATE( __SHIFT_TO_BOTTOM_LEFT )
5110  return *this;
5111  }
5112 
5113 #undef __SHIFT_TO_BOTTOM_LEFT
5114 
5115  // -------------------------------------------------------------------------
5116 
5117 #define __SHIFT_TO_BOTTOM_RIGHT( I ) \
5118  static_cast<pcl::I&>( **this ).ShiftToBottomRight( width, height, fillValues )
5119 
5127  template <typename T>
5128  ImageVariant& ShiftToBottomRight( int width, int height, const GenericVector<T>& fillValues )
5129  {
5130  if ( *this )
5131  SOLVE_TEMPLATE( __SHIFT_TO_BOTTOM_RIGHT )
5132  return *this;
5133  }
5134 
5135 #undef __SHIFT_TO_BOTTOM_RIGHT
5136 
5137  // -------------------------------------------------------------------------
5138 
5139 #define __SHIFT_TO_BOTTOM_RIGHT( I ) \
5140  static_cast<pcl::I&>( **this ).ShiftToBottomRight( width, height )
5141 
5151  ImageVariant& ShiftToBottomRight( int width, int height )
5152  {
5153  if ( *this )
5154  SOLVE_TEMPLATE( __SHIFT_TO_BOTTOM_RIGHT )
5155  return *this;
5156  }
5157 
5158 #undef __SHIFT_TO_BOTTOM_RIGHT
5159 
5160  // -------------------------------------------------------------------------
5161 
5162 #define __SHIFT_TO_BOTTOM_CENTER( I ) \
5163  static_cast<pcl::I&>( **this ).ShiftToCenter( width, height, fillValues )
5164 
5172  template <typename T>
5173  ImageVariant& ShiftToCenter( int width, int height, const GenericVector<T>& fillValues )
5174  {
5175  if ( *this )
5176  SOLVE_TEMPLATE( __SHIFT_TO_BOTTOM_CENTER )
5177  return *this;
5178  }
5179 
5180 #undef __SHIFT_TO_BOTTOM_CENTER
5181 
5182  // -------------------------------------------------------------------------
5183 
5184 #define __SHIFT_TO_BOTTOM_CENTER( I ) \
5185  static_cast<pcl::I&>( **this ).ShiftToCenter( width, height )
5186 
5196  ImageVariant& ShiftToCenter( int width, int height )
5197  {
5198  if ( *this )
5199  SOLVE_TEMPLATE( __SHIFT_TO_BOTTOM_CENTER )
5200  return *this;
5201  }
5202 
5203 #undef __SHIFT_TO_BOTTOM_CENTER
5204 
5205  // -------------------------------------------------------------------------
5206 
5207 #define __SHIFT_TO_TOP_LEFT( I ) \
5208  static_cast<pcl::I&>( **this ).ShiftToTopLeft( width, height, fillValues )
5209 
5217  template <typename T>
5218  ImageVariant& ShiftToTopLeft( int width, int height, const GenericVector<T>& fillValues )
5219  {
5220  if ( *this )
5221  SOLVE_TEMPLATE( __SHIFT_TO_TOP_LEFT )
5222  return *this;
5223  }
5224 
5225 #undef __SHIFT_TO_TOP_LEFT
5226 
5227  // -------------------------------------------------------------------------
5228 
5229 #define __SHIFT_TO_TOP_LEFT( I ) \
5230  static_cast<pcl::I&>( **this ).ShiftToTopLeft( width, height )
5231 
5241  ImageVariant& ShiftToTopLeft( int width, int height )
5242  {
5243  if ( *this )
5244  SOLVE_TEMPLATE( __SHIFT_TO_TOP_LEFT )
5245  return *this;
5246  }
5247 
5248 #undef __SHIFT_TO_TOP_LEFT
5249 
5250  // -------------------------------------------------------------------------
5251 
5252 #define __SHIFT_TO_TOP_RIGHT( I ) \
5253  static_cast<pcl::I&>( **this ).ShiftToTopRight( width, height, fillValues )
5254 
5262  template <typename T>
5263  ImageVariant& ShiftToTopRight( int width, int height, const GenericVector< T >& fillValues )
5264  {
5265  if ( *this )
5266  SOLVE_TEMPLATE( __SHIFT_TO_TOP_RIGHT )
5267  return *this;
5268  }
5269 
5270 #undef __SHIFT_TO_TOP_RIGHT
5271 
5272  // -------------------------------------------------------------------------
5273 
5274 #define __SHIFT_TO_TOP_RIGHT( I ) \
5275  static_cast<pcl::I&>( **this ).ShiftToTopRight( width, height )
5276 
5286  ImageVariant& ShiftToTopRight( int width, int height )
5287  {
5288  if ( *this )
5289  SOLVE_TEMPLATE( __SHIFT_TO_TOP_RIGHT )
5290  return *this;
5291  }
5292 
5293 #undef __SHIFT_TO_TOP_RIGHT
5294 
5295  // -------------------------------------------------------------------------
5296 
5297 #define __STD_DEV( I ) \
5298  result = static_cast<const pcl::I&>( **this ).StdDev( rect, firstChannel, lastChannel, maxProcessors )
5299 
5305  double StdDev( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1, int maxProcessors = 0 ) const
5306  {
5307  double result = 0;
5308  if ( *this )
5309  SOLVE_TEMPLATE( __STD_DEV )
5310  return result;
5311  }
5312 
5313 #undef __STD_DEV
5314 
5315  // -------------------------------------------------------------------------
5316 
5317 #define __SUBTRACT( I ) \
5318  static_cast<pcl::I&>( **this ).Subtract( scalar, rect, firstChannel, lastChannel )
5319 
5327  template <typename T>
5328  ImageVariant& Subtract( T scalar, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
5329  {
5330  if ( *this )
5331  SOLVE_TEMPLATE( __SUBTRACT )
5332  return *this;
5333  }
5334 
5335 #undef __SUBTRACT
5336 
5340  template <typename T>
5341  ImageVariant& Sub( T scalar, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
5342  {
5343  return Subtract( scalar, rect, firstChannel, lastChannel );
5344  }
5345 
5346  // -------------------------------------------------------------------------
5347 
5348 #define __SUBTRACT_1( I ) \
5349  ImageVariant::Subtract( static_cast<pcl::I&>( **this ), image, point, channel, rect, firstChannel, lastChannel )
5350 
5351 #define __SUBTRACT_2( I ) \
5352  image1.Subtract( static_cast<const pcl::I&>( *image2 ), point, channel, rect, firstChannel, lastChannel )
5353 
5354 private:
5355 
5356  template <class P> static
5357  void Subtract( GenericImage<P>& image1, const ImageVariant& image2,
5358  const Point& point, int channel, const Rect& rect, int firstChannel, int lastChannel )
5359  {
5360  SOLVE_TEMPLATE_2( image2, __SUBTRACT_2 )
5361  }
5362 
5363 public:
5364 
5373  const Point& point = Point( int_max ), int channel = -1,
5374  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
5375  {
5376  if ( *this )
5377  if ( image )
5378  SOLVE_TEMPLATE( __SUBTRACT_1 )
5379  return *this;
5380  }
5381 
5382 #undef __SUBTRACT_1
5383 #undef __SUBTRACT_2
5384 
5389  const Point& point = Point( int_max ), int channel = -1,
5390  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
5391  {
5392  return Subtract( image, point, channel, rect, firstChannel, lastChannel );
5393  }
5394 
5395  // -------------------------------------------------------------------------
5396 
5397 #define __SUBTRACTED( I ) \
5398  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Subtracted( scalar, rect, firstChannel, lastChannel ) ) ); \
5399  result.SetOwnership( true )
5400 
5408  template <typename T>
5409  ImageVariant Subtracted( T scalar, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
5410  {
5411  ImageVariant result;
5412  if ( *this )
5413  SOLVE_TEMPLATE( __SUBTRACTED )
5414  return result;
5415  }
5416 
5417 #undef __SUBTRACTED
5418 
5419  // -------------------------------------------------------------------------
5420 
5421 #define __SUM_OF_SQUARES( I ) \
5422  result = static_cast<const pcl::I&>( **this ).SumOfSquares( rect, firstChannel, lastChannel, maxProcessors )
5423 
5430  double SumOfSquares( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1, int maxProcessors = 0 ) const
5431  {
5432  double result = 0;
5433  if ( *this )
5434  SOLVE_TEMPLATE( __SUM_OF_SQUARES )
5435  return result;
5436  }
5437 
5438 #undef __SUM_OF_SQUARES
5439 
5440  // -------------------------------------------------------------------------
5441 
5442 #define __TRANSFER_IMAGE_1( I ) \
5443  ImageVariant::TransferImage( static_cast<pcl::I&>( **this ), image )
5444 
5445 #define __TRANSFER_IMAGE_2( I ) \
5446  image1.Transfer( static_cast<pcl::I&>( *image2 ) )
5447 
5448 private:
5449 
5450  template <class P> static
5451  void TransferImage( GenericImage<P>& image1, ImageVariant& image2 )
5452  {
5453  SOLVE_TEMPLATE_2( image2, __TRANSFER_IMAGE_2 )
5454  }
5455 
5456 public:
5457 
5467  {
5468  if ( *this )
5469  if ( image )
5470  SOLVE_TEMPLATE( __TRANSFER_IMAGE_1 )
5471  return *this;
5472  }
5473 
5474 #undef __TRANSFER_IMAGE_1
5475 #undef __TRANSFER_IMAGE_2
5476 
5477  // -------------------------------------------------------------------------
5478 
5479 #define __TRANSFORM( I ) \
5480  static_cast<const pcl::I&>( **this ).Transform( transform, rect, firstChannel, lastChannel )
5481 
5490  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
5491  {
5492  if ( *this )
5493  SOLVE_TEMPLATE( __TRANSFORM )
5494  }
5495 
5496 #undef __TRANSFORM
5497 
5498  // -------------------------------------------------------------------------
5499 
5500 #define __TRUNCATE( I ) \
5501  static_cast<pcl::I&>( **this ).Truncate( lowerBound, upperBound, rect, firstChannel, lastChannel )
5502 
5510  template <typename T>
5511  ImageVariant& Truncate( T lowerBound, T upperBound, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
5512  {
5513  if ( *this )
5514  SOLVE_TEMPLATE_REAL( __TRUNCATE )
5515  return *this;
5516  }
5517 
5518 #undef __TRUNCATE
5519 
5520  // -------------------------------------------------------------------------
5521 
5522 #define __TRUNCATE( I ) \
5523  static_cast<pcl::I&>( **this ).Truncate( rect, firstChannel, lastChannel )
5524 
5532  ImageVariant& Truncate( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
5533  {
5534  if ( *this )
5535  SOLVE_TEMPLATE_REAL( __TRUNCATE )
5536  return *this;
5537  }
5538 
5539 #undef __TRUNCATE
5540 
5541  // -------------------------------------------------------------------------
5542 
5543 #define __TRUNCATED( I ) \
5544  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Truncated( lowerBound, upperBound, rect, firstChannel, lastChannel ) ) ); \
5545  result.SetOwnership( true )
5546 
5554  template <typename T>
5555  ImageVariant Truncated( T lowerBound, T upperBound, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
5556  {
5557  ImageVariant result;
5558  if ( *this )
5559  SOLVE_TEMPLATE( __TRUNCATED )
5560  return result;
5561  }
5562 
5563 #undef __TRUNCATED
5564 
5565  // -------------------------------------------------------------------------
5566 
5567 #define __TRUNCATED( I ) \
5568  result.SetImage( *new pcl::I( static_cast<const pcl::I&>( **this ).Truncated( rect, firstChannel, lastChannel ) ) ); \
5569  result.SetOwnership( true )
5570 
5578  ImageVariant Truncated( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
5579  {
5580  ImageVariant result;
5581  if ( *this )
5582  SOLVE_TEMPLATE( __TRUNCATED )
5583  return result;
5584  }
5585 
5586 #undef __TRUNCATED
5587 
5588  // -------------------------------------------------------------------------
5589 
5590 #define __VARIANCE( I ) \
5591  result = static_cast<const pcl::I&>( **this ).Variance( rect, firstChannel, lastChannel, maxProcessors )
5592 
5598  double Variance( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1, int maxProcessors = 0 ) const
5599  {
5600  double result = 0;
5601  if ( *this )
5602  SOLVE_TEMPLATE( __VARIANCE )
5603  return result;
5604  }
5605 
5606 #undef __VARIANCE
5607 
5608  // -------------------------------------------------------------------------
5609 
5610 #define __WHITE( I ) \
5611  static_cast<pcl::I&>( **this ).White( rect, firstChannel, lastChannel )
5612 
5619  ImageVariant& White( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
5620  {
5621  if ( *this )
5622  SOLVE_TEMPLATE_REAL( __WHITE )
5623  return *this;
5624  }
5625 
5626 #undef __WHITE
5627 
5628  // -------------------------------------------------------------------------
5629 
5630 #define __WRITE( I ) \
5631  static_cast<const pcl::I&>( **this ).Write( file, rect, firstChannel, lastChannel )
5632 
5638  void Write( File& file, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
5639  {
5640  if ( *this )
5641  SOLVE_TEMPLATE( __WRITE )
5642  }
5643 
5644 #undef __WRITE
5645 
5646  // -------------------------------------------------------------------------
5647 
5648 #define __WRITE( I ) \
5649  static_cast<const pcl::I&>( **this ).Write( filePath, rect, firstChannel, lastChannel )
5650 
5656  void Write( const String& filePath, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 ) const
5657  {
5658  if ( *this )
5659  SOLVE_TEMPLATE( __WRITE )
5660  }
5661 
5662 #undef __WRITE
5663 
5664  // -------------------------------------------------------------------------
5665 
5666 #define __XNOR( I ) \
5667  static_cast<pcl::I&>( **this ).Xnor( scalar, rect, firstChannel, lastChannel )
5668 
5676  template <typename T>
5677  ImageVariant& Xnor( T scalar, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
5678  {
5679  if ( *this )
5680  SOLVE_TEMPLATE_REAL( __XNOR )
5681  return *this;
5682  }
5683 
5684 #undef __XNOR
5685 
5686  // -------------------------------------------------------------------------
5687 
5688 #define __XNOR_1( I ) \
5689  ImageVariant::Xnor( static_cast<pcl::I&>( **this ), image, point, channel, rect, firstChannel, lastChannel )
5690 
5691 #define __XNOR_2( I ) \
5692  image1.Xnor( static_cast<const pcl::I&>( *image2 ), point, channel, rect, firstChannel, lastChannel )
5693 
5694 private:
5695 
5696  template <class P> static
5697  void Xnor( GenericImage<P>& image1, const ImageVariant& image2,
5698  const Point& point, int channel, const Rect& rect, int firstChannel, int lastChannel )
5699  {
5700  SOLVE_TEMPLATE_REAL_2( image2, __XNOR_2 )
5701  }
5702 
5703 public:
5704 
5713  const Point& point = Point( int_max ), int channel = -1,
5714  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
5715  {
5716  if ( *this )
5717  if ( image )
5718  SOLVE_TEMPLATE_REAL( __XNOR_1 )
5719  return *this;
5720  }
5721 
5722 #undef __XNOR_1
5723 #undef __XNOR_2
5724 
5725  // -------------------------------------------------------------------------
5726 
5727 #define __XOR( I ) \
5728  static_cast<pcl::I&>( **this ).Xor( scalar, rect, firstChannel, lastChannel )
5729 
5737  template <typename T>
5738  ImageVariant& Xor( T scalar, const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
5739  {
5740  if ( *this )
5741  SOLVE_TEMPLATE_REAL( __XOR )
5742  return *this;
5743  }
5744 
5745 #undef __XOR
5746 
5747  // -------------------------------------------------------------------------
5748 
5749 #define __XOR_1( I ) \
5750  ImageVariant::Xor( static_cast<pcl::I&>( **this ), image, point, channel, rect, firstChannel, lastChannel )
5751 
5752 #define __XOR_2( I ) \
5753  image1.Xor( static_cast<const pcl::I&>( *image2 ), point, channel, rect, firstChannel, lastChannel )
5754 
5755 private:
5756 
5757  template <class P> static
5758  void Xor( GenericImage<P>& image1, const ImageVariant& image2,
5759  const Point& point, int channel, const Rect& rect, int firstChannel, int lastChannel )
5760  {
5761  SOLVE_TEMPLATE_REAL_2( image2, __XOR_2 )
5762  }
5763 
5764 public:
5765 
5774  const Point& point = Point( int_max ), int channel = -1,
5775  const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
5776  {
5777  if ( *this )
5778  if ( image )
5779  SOLVE_TEMPLATE_REAL( __XOR_1 )
5780  return *this;
5781  }
5782 
5783 #undef __XOR_1
5784 #undef __XOR_2
5785 
5786  // -------------------------------------------------------------------------
5787 
5788 #define __ZERO( I ) \
5789  static_cast<pcl::I&>( **this ).Zero( rect, firstChannel, lastChannel )
5790 
5798  ImageVariant& Zero( const Rect& rect = Rect( 0 ), int firstChannel = -1, int lastChannel = -1 )
5799  {
5800  if ( *this )
5801  SOLVE_TEMPLATE_REAL( __ZERO )
5802  return *this;
5803  }
5804 
5805 #undef __ZERO
5806 
5807  // -------------------------------------------------------------------------
5808 
5809 #define __COMPRESS( I ) \
5810  return static_cast<const pcl::I&>( **this ).Compress( compressor, rect, channel, perf )
5811 
5823  const Rect& rect = Rect( 0 ), int channel = -1,
5824  Compression::Performance* perf = nullptr ) const
5825  {
5826  if ( *this )
5827  SOLVE_TEMPLATE( __COMPRESS )
5828  return Compression::subblock_list();
5829  }
5830 
5831 #undef __COMPRESS
5832 
5833  // -------------------------------------------------------------------------
5834 
5839  template <class P>
5840  bool IsAs( const pcl::GenericImage<P>& ) const
5841  {
5842  return m_data->image && m_data->isFloatSample == P::IsFloatSample() &&
5843  m_data->isComplexSample == P::IsComplexSample() &&
5844  m_data->bitsPerSample == P::BitsPerSample();
5845  }
5846 
5856  {
5857  image.m_data->Attach();
5858  DetachFromData();
5859  m_data = image.m_data;
5860  return *this;
5861  }
5862 
5868  ImageVariant& operator =( const ImageVariant& image )
5869  {
5870  return Assign( image );
5871  }
5872 
5873 #define TRANSFER_BODY() \
5874  if ( &image != this ) /* N.B.: Self-movement incompatible with server-side SharedImage */ \
5875  { \
5876  DetachFromData(); \
5877  m_data = image.m_data; \
5878  image.m_data = nullptr; \
5879  } \
5880  return *this
5881 
5894  {
5895  TRANSFER_BODY();
5896  }
5897 
5910  {
5911  TRANSFER_BODY();
5912  }
5913 
5914 #undef TRANSFER_BODY
5915 
5921  ImageVariant& operator =( ImageVariant&& image )
5922  {
5923  return Transfer( image );
5924  }
5925 
5934  void ReleaseTo( ImageVariant& image )
5935  {
5936  if ( &image != this ) // N.B.: Self-release incompatible with server-side SharedImage.
5937  {
5938  Data* newData = new Data;
5939  image.DetachFromData();
5940  image.m_data = m_data;
5941  m_data = newData;
5942  }
5943  }
5944 
5953  template <class P>
5955  {
5956  if ( &image != m_data->image )
5957  {
5958  Free();
5959  m_data->Update( &image );
5960  }
5961  return *this;
5962  }
5963 
5967  friend void Swap( ImageVariant& x1, ImageVariant& x2 )
5968  {
5969  pcl::Swap( x1.m_data, x2.m_data );
5970  }
5971 
5996  ImageVariant& CreateImage( bool isFloat, bool isComplex, int bitSize )
5997  {
5998  if ( isFloat )
5999  {
6000  if ( isComplex )
6001  CreateComplexImage( bitSize );
6002  else
6003  CreateFloatImage( bitSize );
6004  }
6005  else
6006  {
6007  if ( !isComplex )
6008  CreateUIntImage( bitSize );
6009  /*
6010  else
6011  {
6012  ### Yeah this is true, but everybody already knows so we don't want
6013  to replicate this useless message everywhere!
6014  throw Error( "Integer-valued complex images not supported by this PCL version." );
6015  }
6016  */
6017  }
6018 
6019  return *this;
6020  }
6021 
6022 #define CREATE_IMAGE( I ) m_data->Update( new pcl::I )
6023 
6036  ImageVariant& CreateFloatImage( int bitSize = 32 )
6037  {
6038  PCL_PRECONDITION( bitSize == 32 || bitSize == 64 )
6039  Free();
6040  switch ( bitSize )
6041  {
6042  case 32 : CREATE_IMAGE( Image ); break;
6043  case 64 : CREATE_IMAGE( DImage ); break;
6044  }
6045  m_data->ownsImage = m_data->image != nullptr;
6046  return *this;
6047  }
6048 
6058  {
6059  return CreateFloatImage();
6060  }
6061 
6073  ImageVariant& CreateComplexImage( int bitSize = 32 )
6074  {
6075  PCL_PRECONDITION( bitSize == 32 || bitSize == 64 )
6076  Free();
6077  switch ( bitSize )
6078  {
6079  case 32 : CREATE_IMAGE( ComplexImage ); break;
6080  case 64 : CREATE_IMAGE( DComplexImage ); break;
6081  }
6082  m_data->ownsImage = m_data->image != nullptr;
6083  return *this;
6084  }
6085 
6097  ImageVariant& CreateUIntImage( int bitSize = 16 )
6098  {
6099  PCL_PRECONDITION( bitSize == 8 || bitSize == 16 || bitSize == 32 )
6100  Free();
6101  switch ( bitSize )
6102  {
6103  case 8 : CREATE_IMAGE( UInt8Image ); break;
6104  case 16 : CREATE_IMAGE( UInt16Image ); break;
6105  case 32 : CREATE_IMAGE( UInt32Image ); break;
6106  }
6107  m_data->ownsImage = m_data->image != nullptr;
6108  return *this;
6109  }
6110 
6111 #undef CREATE_IMAGE
6112 
6126  template <class P>
6128  {
6129  return CreateImage( P::IsFloatSample(), P::IsComplexSample(), P::BitsPerSample() );
6130  }
6131 
6146  {
6147  return CreateImage( image.IsFloatSample(), image.IsComplexSample(), image.BitsPerSample() );
6148  }
6149 
6150 #ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
6151 
6185  ImageVariant& CreateSharedImage( bool isFloat, bool isComplex, int bitSize )
6186  {
6187  if ( isFloat )
6188  {
6189  if ( isComplex )
6190  CreateSharedComplexImage( bitSize );
6191  else
6192  CreateSharedFloatImage( bitSize );
6193  }
6194  else
6195  {
6196  if ( !isComplex )
6197  CreateSharedUIntImage( bitSize );
6198  }
6199 
6200  return *this;
6201  }
6202 
6203 #define CREATE_SHARED_IMAGE( I ) m_data->Update( new pcl::I( (void*)0, 0, 0 ) )
6204 
6220  {
6221  PCL_PRECONDITION( bitSize == 32 || bitSize == 64 )
6222  Free();
6223  switch ( bitSize )
6224  {
6225  case 32 : CREATE_SHARED_IMAGE( Image ); break;
6226  case 64 : CREATE_SHARED_IMAGE( DImage ); break;
6227  }
6228  m_data->ownsImage = m_data->image != nullptr;
6229  return *this;
6230  }
6231 
6244  {
6245  return CreateSharedFloatImage();
6246  }
6247 
6263  {
6264  PCL_PRECONDITION( bitSize == 32 || bitSize == 64 )
6265  Free();
6266  switch ( bitSize )
6267  {
6268  case 32 : CREATE_SHARED_IMAGE( ComplexImage ); break;
6269  case 64 : CREATE_SHARED_IMAGE( DComplexImage ); break;
6270  }
6271  m_data->ownsImage = m_data->image != nullptr;
6272  return *this;
6273  }
6274 
6290  {
6291  PCL_PRECONDITION( bitSize == 8 || bitSize == 16 || bitSize == 32 )
6292  Free();
6293  switch ( bitSize )
6294  {
6295  case 8 : CREATE_SHARED_IMAGE( UInt8Image ); break;
6296  case 16 : CREATE_SHARED_IMAGE( UInt16Image ); break;
6297  case 32 : CREATE_SHARED_IMAGE( UInt32Image ); break;
6298  }
6299  m_data->ownsImage = m_data->image != nullptr;
6300  return *this;
6301  }
6302 
6303 #undef CREATE_SHARED_IMAGE
6304 
6321  template <class P>
6323  {
6324  return CreateSharedImage( P::IsFloatSample(), P::IsComplexSample(), P::BitsPerSample() );
6325  }
6326 
6344  {
6345  return CreateSharedImage( image.IsFloatSample(), image.IsComplexSample(), image.BitsPerSample() );
6346  }
6347 
6348 #endif // !__PCL_BUILDING_PIXINSIGHT_APPLICATION
6349 
6350 #define ALLOCATE_IMAGE( I ) \
6351  static_cast<pcl::I&>( **this ).AllocateData( width, height, numberOfChannels, colorSpace )
6352 
6377  ImageVariant& AllocateImage( int width, int height, int numberOfChannels, color_space colorSpace )
6378  {
6379  if ( !*this )
6380  CreateImage();
6381  SOLVE_TEMPLATE( ALLOCATE_IMAGE )
6382  return *this;
6383  }
6384 
6385 #undef ALLOCATE_IMAGE
6386 
6387 #define COPY_IMAGE( I ) static_cast<pcl::I&>( **this ).Assign( image )
6388 
6405  template <class P>
6407  {
6408  if ( !*this )
6409  CreateImageAs( image );
6410  SOLVE_TEMPLATE( COPY_IMAGE )
6411  return *this;
6412  }
6413 
6414 #undef COPY_IMAGE
6415 
6416 #define COPY_IMAGE( I ) CopyImage( static_cast<const pcl::I&>( *image ) )
6417 
6430  {
6431  if ( image )
6432  SOLVE_TEMPLATE_2( image, COPY_IMAGE )
6433  else
6434  FreeImage();
6435  return *this;
6436  }
6437 
6438 #undef COPY_IMAGE
6439 
6440 #define FREE_IMAGE( I ) static_cast<pcl::I&>( **this ).FreeData()
6441 
6458  {
6459  if ( *this )
6460  SOLVE_TEMPLATE( FREE_IMAGE )
6461  return *this;
6462  }
6463 
6470  static Compression* NewCompression( swap_compression algorithm, int itemSize = 1 );
6471 
6472 #undef FREE_IMAGE
6473 
6503  void WriteSwapFile( const String& filePath,
6504  swap_compression compression = SwapCompression::None,
6505  Compression::Performance* perf = nullptr,
6506  bool processEvents = false ) const;
6507 
6544  void WriteSwapFiles( const String& fileName, const StringList& directories,
6545  swap_compression compression = SwapCompression::None,
6546  Compression::Performance* perf = nullptr,
6547  bool processEvents = false ) const;
6577  void ReadSwapFile( const String& filePath,
6578  Compression::Performance* perf = nullptr,
6579  bool processEvents = false );
6580 
6616  void ReadSwapFiles( const String& fileName, const StringList& directories,
6617  Compression::Performance* perf = nullptr,
6618  bool processEvents = false );
6619 
6655  void MaskFromSwapFile( const String& filePath, const ImageVariant& mask, bool invert = false,
6656  bool processEvents = false );
6657 
6691  void MaskFromSwapFiles( const String& fileName, const StringList& directories,
6692  const ImageVariant& mask, bool invert = false,
6693  bool processEvents = false );
6694 
6699  static void DeleteSwapFile( const String& filePath );
6700 
6709  static void DeleteSwapFiles( const String& fileName, const StringList& directories );
6710 
6720  static uint64 SwapFileSize( const String& filePath );
6721 
6734  static uint64 SwapFilesSize( const String& fileName, const StringList& directories );
6735 
6764  void MaskImage( const ImageVariant& src, const ImageVariant& mask, bool invert = false );
6765 
6770  bool OwnsImage() const
6771  {
6772  return m_data->ownsImage;
6773  }
6774 
6785  ImageVariant& SetOwnership( bool owner = true )
6786  {
6787  m_data->ownsImage = owner && m_data->image;
6788  return *this;
6789  }
6790 
6799  {
6800  if ( m_data->IsUnique() )
6801  m_data->Free();
6802  else
6803  {
6804  Data* newData = new Data;
6805  DetachFromData();
6806  m_data = newData;
6807  }
6808  return *this;
6809  }
6810 
6818  const AbstractImage* operator ->() const
6819  {
6820  PCL_PRECONDITION( m_data->image != nullptr )
6821  return m_data->image;
6822  }
6823 
6831  AbstractImage* operator ->()
6832  {
6833  PCL_PRECONDITION( m_data->image != nullptr )
6834  return m_data->image;
6835  }
6836 
6844  const AbstractImage& operator *() const
6845  {
6846  PCL_PRECONDITION( m_data->image != nullptr )
6847  return *m_data->image;
6848  }
6849 
6858  {
6859  PCL_PRECONDITION( m_data->image != nullptr )
6860  return *m_data->image;
6861  }
6862 
6866  operator bool() const
6867  {
6868  return m_data->image != nullptr;
6869  }
6870 
6871 #define __PIXEL_ACCESS_OPERATOR( I ) \
6872  pcl::I::pixel_traits::FromSample( result, *static_cast<const pcl::I&>( **this ).PixelAddress( x, y, channel ) )
6873 
6899  double operator ()( int x, int y, int channel = 0 ) const
6900  {
6901  double result = 0;
6902  if ( *this )
6903  SOLVE_TEMPLATE( __PIXEL_ACCESS_OPERATOR )
6904  return result;
6905  }
6906 
6907 #undef __PIXEL_ACCESS_OPERATOR
6908 
6909 #ifdef __PCL_BUILDING_PIXINSIGHT_APPLICATION
6910 
6911  pi::SharedImage* GetSharedImage() const
6912  {
6913  return m_shared;
6914  }
6915 
6916  bool IsShared() const
6917  {
6918  return m_shared != nullptr;
6919  }
6920 
6921  // Implemented in SharedImage.cpp
6922  pi::SharedImage* NewSharedImage( void* owner, bool rdOnly = false );
6923 
6924 #endif
6925 
6926 private:
6927 
6928  struct Data : public ReferenceCounter
6929  {
6930  AbstractImage* image = nullptr;
6931  bool isFloatSample = false;
6932  bool isComplexSample = false;
6933  uint8 bitsPerSample = 0;
6934  bool ownsImage = false;
6935 
6936  Data() = default;
6937 
6938  ~Data()
6939  {
6940  Free();
6941  }
6942 
6943  template <class P>
6944  void Update( GenericImage<P>* a_image )
6945  {
6946  image = a_image;
6947  isFloatSample = P::IsFloatSample();
6948  isComplexSample = P::IsComplexSample();
6949  bitsPerSample = uint8( P::BitsPerSample() );
6950  }
6951 
6952  void Free()
6953  {
6954  if ( ownsImage )
6955  delete image;
6956  image = nullptr;
6957  isFloatSample = isComplexSample = false;
6958  bitsPerSample = 0;
6959  //ownsImage = ownsImage; ### N.B.: Ownership must *not* change here
6960  }
6961  };
6962 
6963  Data* m_data = nullptr;
6964 
6965 #ifdef __PCL_BUILDING_PIXINSIGHT_APPLICATION
6966  // This is the server-side part of the image sharing mechanism
6967  pi::SharedImage* m_shared = nullptr;
6968 #else
6969  const void* m_shared = nullptr;
6970 #endif
6971 
6972  void DetachFromData()
6973  {
6974  if ( !m_data->Detach() )
6975  delete m_data;
6976  }
6977 
6978 #ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
6979  // Server-side private ctor. used by View
6980  template <class P>
6981  ImageVariant( GenericImage<P>* image, int )
6982  {
6983  m_data = new Data;
6984  m_data->Update( image );
6985  m_data->ownsImage = true;
6986  }
6987 #endif
6988 
6989 #ifdef __PCL_BUILDING_PIXINSIGHT_APPLICATION
6990  friend class pi::SharedImage;
6991 #else
6992  friend class View;
6993  friend class ImageView;
6994 #endif
6995 };
6996 
6997 // ----------------------------------------------------------------------------
6998 
6999 /*
7000  * Implementation of member functions of GenericImage requiring a full
7001  * declaration of ImageVariant.
7002  */
7003 
7004 template <class P> inline
7005 void GenericImage<P>::GetLuminance( ImageVariant& Y, const Rect& rect, int maxProcessors ) const
7006 {
7007  ImageVariant( const_cast<GenericImage<P>*>( this ) ).GetLuminance( Y, rect, maxProcessors );
7008 }
7009 
7010 template <class P> inline
7011 void GenericImage<P>::GetLightness( ImageVariant& L, const Rect& rect, int maxProcessors ) const
7012 {
7013  ImageVariant( const_cast<GenericImage<P>*>( this ) ).GetLightness( L, rect, maxProcessors );
7014 }
7015 
7016 template <class P> inline
7017 void GenericImage<P>::GetIntensity( ImageVariant& I, const Rect& rect, int maxProcessors ) const
7018 {
7019  ImageVariant( const_cast<GenericImage<P>*>( this ) ).GetIntensity( I, rect, maxProcessors );
7020 }
7021 
7022 template <class P> inline
7023 GenericImage<P>& GenericImage<P>::SetLuminance( const ImageVariant& Y, const Point& point, const Rect& rect, int maxProcessors )
7024 {
7025  (void)ImageVariant( this ).SetLuminance( Y, point, rect, maxProcessors );
7026  return *this;
7027 }
7028 
7029 template <class P> inline
7030 GenericImage<P>& GenericImage<P>::SetLightness( const ImageVariant& L, const Point& point, const Rect& rect, int maxProcessors )
7031 {
7032  (void)ImageVariant( this ).SetLightness( L, point, rect, maxProcessors );
7033  return *this;
7034 }
7035 
7036 // ----------------------------------------------------------------------------
7037 
7038 } // pcl
7039 
7040 #endif // __PCL_ImageVariant_h
7041 
7042 // ----------------------------------------------------------------------------
7043 // EOF pcl/ImageVariant.h - Released 2019-11-07T10:59:34Z
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
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:163
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
void EnableRangeClipping(bool enable=true) const
ImageVariant & Multiply(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
bool Intersects(T x0, T y0, T x1, T y1) const
Definition: ImageVariant.h:691
ImageVariant & Rescale(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
ImageVariant & ShiftTo(int x, int y)
int SelectedChannel() const
Definition: ImageVariant.h:786
ImageVariant & ShiftToTopRight(int width, int height, const GenericVector< T > &fillValues)
void ReleaseTo(ImageVariant &image)
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
const RGBColorSystem & RGBWorkingSpace() const
int NumberOfAlphaChannels() const
Definition: ImageVariant.h:560
Root base class for bidirectional PCL image transformations.
ImageVariant & CreateComplexImage(int bitSize=32)
Complex< T1 > operator*(const Complex< T1 > &c1, const Complex< T2 > &c2)
Definition: Complex.h:539
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)
size_type NumberOfSelectedPixels() const
void Write(const String &filePath, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1) const
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)
double MaximumSampleValue(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1, int maxProcessors=0) const
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 HasAlphaChannels() const
Definition: ImageVariant.h:547
ImageSelections & Selections() const
bool IsFloatSample() const
Definition: ImageVariant.h:435
unsigned char uint8
Definition: Defs.h:576
void Swap(GenericPoint< T > &p1, GenericPoint< T > &p2)
Definition: Point.h:1402
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)
int Width() const
Definition: ImageVariant.h:470
void SelectPoint(const Point &p) const
Definition: ImageVariant.h:892
ImageVariant & Transfer(ImageVariant &&image)
ImageVariant & ShiftToBottomLeft(int width, int height)
int FirstSelectedChannel() const
Definition: ImageVariant.h:850
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
int NumberOfSelectedChannels() const
Definition: ImageVariant.h:841
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
int BitsPerSample() const
Definition: ImageVariant.h:452
ImageVariant & SetOwnership(bool owner=true)
bool IsEmptySelection() const
Definition: ImageVariant.h:973
PCL root namespace.
Definition: AbstractImage.h:76
ImageVariant & Add(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
double Norm(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1, int maxProcessors=0) const
size_type NumberOfPixels() const
Definition: ImageVariant.h:490
bool OwnsImage() const
double MAD(double center, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1, int maxProcessors=0) const
AbstractImage * ImagePtr()
Definition: ImageVariant.h:414
ImageVariant & ShiftTo(const Point &p)
bool IsSharedImage() const
friend void Swap(ImageVariant &x1, ImageVariant &x2)
bool IsValidChannelIndex(int c) const
Definition: ImageVariant.h:521
void GetLightness(ImageVariant &L, const Rect &rect=Rect(0), int maxProcessors=0) const
A colorimetrically defined RGB working color space.
ImageVariant Truncated(T lowerBound, T upperBound, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1) const
bool Clip(pcl::GenericPoint< T > &p) const
Definition: ImageVariant.h:704
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)
bool Includes(const GenericRectangle< T > &r) const
Definition: ImageVariant.h:634
ImageVariant & SetMinimum(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
ImageVariant & CropTo(const Rect &rect)
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)
int LastSelectedChannel() const
Definition: ImageVariant.h:859
double Variance(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1, int maxProcessors=0) const
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()
bool IsSameImage(const ImageVariant &image) const
Definition: ImageVariant.h:426
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()
void SelectRectangle(const Point &p0, const Point &p1) const
Definition: ImageVariant.h:943
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
void ResetSelections() 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)
ImageVariant & Mul(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
virtual ~ImageVariant()
Definition: ImageVariant.h:393
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)
void SetRangeClipping(double clipLow, double clipHigh) const
void SetRangeClipHigh(double clipHigh) const
String ChannelId(int c) const
Implements a generic, two-dimensional, shared or local image.
Definition: Image.h:275
bool IsRangeClippingEnabled() const
size_type NumberOfAlphaSamples() const
Definition: ImageVariant.h:595
bool Intersects(const pcl::GenericRectangle< T > &r) const
Definition: ImageVariant.h:676
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)
Point SelectedPoint() const
Definition: ImageVariant.h:911
ImageVariant & Shift(const GenericVector< T > &fillValues)
void DisableRangeClipping(bool disable=true) const
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:382
ImageVariant & ShiftToCenter(int width, int height)
ImageVariant & Read(const String &filePath)
16-bit unsigned integer image.
size_type AlphaSize() const
size_type NominalSize() const
ImageVariant & And(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
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
Rect Bounds() const
Definition: ImageVariant.h:610
Generic vector of arbitrary length.
Definition: Vector.h:106
void SelectNominalChannels() const
Definition: ImageVariant.h:808
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:543
void SetRGBWorkingSpace(const RGBColorSystem &rgbws)
void SelectAlphaChannels() const
Definition: ImageVariant.h:821
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
size_type LineSize() const
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
void SelectRectangle(const Rect &r) const
Definition: ImageVariant.h:953
ImageVariant Applied(const ImageTransformation &transformation, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1) const
T Abs(const Complex< T > &c)
Definition: Complex.h:420
32-bit floating point complex image.
size_type NumberOfSelectedSamples() const
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)
void ResetPoint() const
Definition: ImageVariant.h:901
ImageVariant & Crop(const GenericVector< T > &fillValues)
ImageVariant & AssignImage(const ImageVariant &image, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
void Apply(FI i, FI j, F f)
Definition: Utility.h:249
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:7911
unsigned long long uint64
Definition: Defs.h:616
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
ImageVariant & CropBy(int left, int top, int right, int bottom)
ImageVariant & Black(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
double BiweightMidvariance(double center, double sigma, int k=9, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1, int maxProcessors=0) 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)
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 IsComplexSample() const
Definition: ImageVariant.h:443
ImageVariant & CreateUIntImage(int bitSize=16)
ImageVariant AbsoluteValue(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1) const
bool CanPopSelections() const
ImageVariant & Divide(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
void SetMaxProcessors(int maxProcessors)
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)
ImageVariant & ShiftBy(int dx, int dy)
size_type ChannelSize() const
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)
double RangeClipLow() const
void ResetSelection() const
Definition: ImageVariant.h:962
Base class of all two-dimensional images in PCL.
void ResetRangeClipping() const
void DisableParallelProcessing(bool disable=true)
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
ImageVariant & Assign(const ImageVariant &image)
64-bit floating point real image.
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.
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 SelectChannelRange(int c0, int c1) const
Definition: ImageVariant.h:798
int NumberOfNominalChannels() const
Definition: ImageVariant.h:534
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)
void GetSelectedChannelRange(int &c0, int &c1) const
Definition: ImageVariant.h:871
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
Rect SelectedRectangle() const
Definition: ImageVariant.h:992
ImageVariant & CreateImageAs(const pcl::GenericImage< P > &image)
ImageVariant & SetRow(const T *buffer, int y, int channel=-1)
int LastChannel() const
Definition: ImageVariant.h:511
StatusMonitor & Status() const
bool IsParallelProcessingEnabled() const
ImageVariant & CreateFloatImage(int bitSize=32)
ImageVariant & CreateSharedUIntImage(int bitSize=16)
ImageVariant & Free()
bool Clip(pcl::GenericRectangle< T > &r) const
Definition: ImageVariant.h:738
void SetStatusCallback(pcl::StatusCallback *callback) const
bool Includes(const GenericPoint< T > &p) const
Definition: ImageVariant.h:622
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
double RangeClipHigh() const
void EnableParallelProcessing(bool enable=true, int maxProcessors=0)
void * SharedImageHandle() const
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
void SelectRectangle(int x0, int y0, int x1, int y1) const
Definition: ImageVariant.h:929
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 SelectChannel(int c) const
Definition: ImageVariant.h:771
bool IsColor() const
ImageVariant & Normalize(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
size_type ImageSize() const
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 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
bool IsCompletelySelected() const
ImageVariant & CreateSharedImage()
Provides status monitoring callback functions.
Definition: StatusMonitor.h:97
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)
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
Client-side interface to a PixInsight ImageView control.
Definition: ImageView.h:79
High-level interface to a PixInsight view object.
Definition: View.h:167
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
int Height() const
Definition: ImageVariant.h:479
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)
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)
int BytesPerSample() const
Definition: ImageVariant.h:461
ImageVariant & EnsureUniqueImage()
const AbstractImage * ImagePtr() const
Definition: ImageVariant.h:406
ImageVariant & CopyImage(const GenericImage< P > &image)
bool Includes(T x, T y) const
Definition: ImageVariant.h:664
double StdDev(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1, int maxProcessors=0) const
bool Includes(T x0, T y0, T x1, T y1) const
Definition: ImageVariant.h:649
bool IsUniqueImage() const
ImageVariant & Subtract(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
32-bit integer point on the plane.
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)
bool IsFullSelection() const
Definition: ImageVariant.h:983
64-bit floating point complex image.
ImageVariant Binarized(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1) const
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
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
bool Clip(T &x, T &y) const
Definition: ImageVariant.h:722
void Write(File &file, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1) const
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)
void PushSelections() const
int MaxProcessors() const
void PopSelections() const
ImageVariant & White(const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1)
void SetRangeClipLow(double clipLow) const
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)
int NumberOfChannels() const
Definition: ImageVariant.h:499
void LocateExtremeSampleValues(int &xmin, int &ymin, T &min, int &xmax, int &ymax, T &max, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1, int maxProcessors=0) const
ImageVariant & 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
void SelectPoint(int x, int y) const
Definition: ImageVariant.h:883
size_type NumberOfNominalSamples() const
Definition: ImageVariant.h:583
bool Clip(T &x0, T &y0, T &x1, T &y1) const
Definition: ImageVariant.h:760
ImageVariant & ShiftBy(int dx, int dy, const GenericVector< T > &fillValues)
ImageVariant & ShiftToBottomRight(int width, int height)
ImageVariant Minimum(T scalar, const Rect &rect=Rect(0), int firstChannel=-1, int lastChannel=-1) const
size_type NumberOfSamples() const
Definition: ImageVariant.h:571
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.
void ResetChannelRange() const
Definition: ImageVariant.h:831
pcl::StatusCallback * StatusCallback() const
Thread-safe reference counter for copy-on-write data structures.
ImageVariant & AllocateData(const Rect &rect, int numberOfChannels=1, color_space colorSpace=ColorSpace::Gray)
color_space ColorSpace() const
A platform-independent interface to the local file system.
Definition: File.h:496
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)