ome-files  0.4.0
VariantPixelBuffer.h
1 /*
2  * #%L
3  * OME-FILES C++ library for image IO.
4  * Copyright © 2006 - 2015 Open Microscopy Environment:
5  * - Massachusetts Institute of Technology
6  * - National Institutes of Health
7  * - University of Dundee
8  * - Board of Regents of the University of Wisconsin-Madison
9  * - Glencoe Software, Inc.
10  * %%
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions are met:
13  *
14  * 1. Redistributions of source code must retain the above copyright notice,
15  * this list of conditions and the following disclaimer.
16  * 2. Redistributions in binary form must reproduce the above copyright notice,
17  * this list of conditions and the following disclaimer in the documentation
18  * and/or other materials provided with the distribution.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
24  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  *
32  * The views and conclusions contained in the software and documentation are
33  * those of the authors and should not be interpreted as representing official
34  * policies, either expressed or implied, of any organization.
35  * #L%
36  */
37 
38 #ifndef OME_FILES_VARIANTPIXELBUFFER_H
39 #define OME_FILES_VARIANTPIXELBUFFER_H
40 
41 #include <memory>
42 
43 #include <ome/files/PixelBuffer.h>
44 #include <ome/files/PixelProperties.h>
45 
46 #include <ome/common/variant.h>
47 
48 namespace ome
49 {
50  namespace files
51  {
52 
76  {
77  private:
78  /*
79  * The following series of typedefs may appear a little
80  * complicated, and perhaps unnecessary, but they do have a
81  * purpose. They exist to work around pre-C++11 compiler
82  * limitations (lack of variadic templates), primarily a limit
83  * to the maximum number of types which may be used with
84  * boost::variant. To exceed this limit (minimum guaranteed is
85  * 10), boost::mpl sequences are used to define the variant
86  * types. These also have length limits, so the type list is
87  * built up by defining separate type sequences, then
88  * concatenating them, and transforming them to provide list
89  * variants. Note that none of this is code per se; it's all
90  * compile-time template expansion which evaluates to a list of
91  * permitted types.
92  */
93 
95  typedef boost::mpl::vector<PixelProperties<::ome::xml::model::enums::PixelType::INT8>,
102 
104  typedef boost::mpl::vector< PixelProperties<::ome::xml::model::enums::PixelType::FLOAT>,
108 
110  typedef boost::mpl::joint_view<integer_pixel_types,
111  float_pixel_types>::type basic_pixel_types_view;
112 
114  template<typename T>
115  struct make_buffer
116  {
118  typedef std::shared_ptr<PixelBuffer<typename T::std_type>> type;
119  };
120 
122  typedef boost::mpl::transform_view<basic_pixel_types_view, make_buffer<boost::mpl::_1>>::type pixel_buffer_types_view;
123 
125  typedef boost::mpl::vector<> empty_types;
126 
128  typedef boost::mpl::insert_range<empty_types, boost::mpl::end<empty_types>::type, pixel_buffer_types_view>::type pixel_buffer_types;
129 
130  public:
132  typedef boost::make_variant_over<pixel_buffer_types>::type variant_buffer_type;
133 
136 
138  typedef boost::multi_array_types::size_type size_type;
139 
141  typedef std::array<boost::multi_array_types::index, PixelBufferBase::dimensions> indices_type;
142 
145 
148 
149  public:
157  explicit
159  buffer(createBuffer(boost::extents[1][1][1][1][1][1][1][1][1]))
160  {
161  }
162 
173  template<class ExtentList>
174  explicit
175  VariantPixelBuffer(const ExtentList& extents,
177  const storage_order_type& storage = PixelBufferBase::default_storage_order()):
178  buffer(createBuffer(extents, pixeltype, storage))
179  {
180  }
181 
192  explicit
193  VariantPixelBuffer(const range_type& range,
195  const storage_order_type& storage = PixelBufferBase::default_storage_order()):
196  buffer(createBuffer(range, pixeltype, storage))
197  {
198  }
199 
208  explicit
210 
216  template<typename T>
217  explicit
218  VariantPixelBuffer(std::shared_ptr<PixelBuffer<T>>& buffer):
219  buffer(buffer)
220  {
221  }
222 
224  virtual
226  {}
227 
233  variant_buffer_type&
235  {
236  return buffer;
237  }
238 
244  const variant_buffer_type&
245  vbuffer() const
246  {
247  return buffer;
248  }
249 
250  protected:
262  template<class T, class ExtentList>
263  static variant_buffer_type
264  makeBuffer(const ExtentList& extents,
265  const storage_order_type& storage,
267  {
268  return variant_buffer_type(std::shared_ptr<PixelBuffer<T>>(new PixelBuffer<T>(extents, pixeltype, ENDIAN_NATIVE, storage)));
269  }
270 
282  template<class T>
283  static variant_buffer_type
284  makeBuffer(const range_type& range,
285  const storage_order_type& storage,
287  {
288  return variant_buffer_type(std::shared_ptr<PixelBuffer<T>>(new PixelBuffer<T>(range, pixeltype, ENDIAN_NATIVE, storage)));
289  }
290 
291  // No switch default to avoid -Wunreachable-code errors.
292  // However, this then makes -Wswitch-default complain. Disable
293  // temporarily.
294 #ifdef __GNUC__
295 # pragma GCC diagnostic push
296 # pragma GCC diagnostic ignored "-Wswitch-default"
297 #endif
298 
299 #define OME_FILES_VARIANTPIXELBUFFER_CREATEEXTENTS_CASE(maR, maProperty, maType) \
300  case ::ome::xml::model::enums::PixelType::maType: \
301  buf = makeBuffer<PixelProperties<::ome::xml::model::enums::PixelType::maType>::std_type>(extents, storage, pixeltype); \
302  break;
303 
315  template<class ExtentList>
316  static variant_buffer_type
317  createBuffer(const ExtentList& extents,
319  const storage_order_type& storage = PixelBufferBase::default_storage_order())
320  {
321  variant_buffer_type buf;
322 
323  switch(pixeltype)
324  {
325  BOOST_PP_SEQ_FOR_EACH(OME_FILES_VARIANTPIXELBUFFER_CREATEEXTENTS_CASE, size, OME_XML_MODEL_ENUMS_PIXELTYPE_VALUES);
326  }
327 
328  return buf;
329  }
330 
331 #undef OME_FILES_VARIANTPIXELBUFFER_CREATEEXTENTS_CASE
332 
333 #define OME_FILES_VARIANTPIXELBUFFER_CREATERANGE_CASE(maR, maProperty, maType) \
334  case ::ome::xml::model::enums::PixelType::maType: \
335  buf = makeBuffer<PixelProperties<::ome::xml::model::enums::PixelType::maType>::std_type>(range, storage, pixeltype); \
336  break;
337 
349  static variant_buffer_type
350  createBuffer(const range_type& range,
352  const storage_order_type& storage = PixelBufferBase::default_storage_order())
353  {
354  variant_buffer_type buf;
355 
356  switch(pixeltype)
357  {
358  BOOST_PP_SEQ_FOR_EACH(OME_FILES_VARIANTPIXELBUFFER_CREATERANGE_CASE, size, OME_XML_MODEL_ENUMS_PIXELTYPE_VALUES);
359  }
360 
361  return buf;
362  }
363 
364 #undef OME_FILES_VARIANTPIXELBUFFER_CREATERANGE_CASE
365 
366 #ifdef __GNUC__
367 # pragma GCC diagnostic pop
368 #endif
369 
370  public:
381  template<class ExtentList>
382  void
383  setBuffer(const ExtentList& extents,
385  const storage_order_type& storage = PixelBufferBase::default_storage_order())
386  {
387  buffer = createBuffer(extents, pixeltype, storage);
388  }
389 
400  void
401  setBuffer(const range_type& range,
403  const storage_order_type& storage = PixelBufferBase::default_storage_order())
404  {
405  buffer = createBuffer(range, pixeltype, storage);
406  }
407 
415  bool
416  managed() const;
417 
423  size_type
424  num_elements() const;
425 
431  size_type
432  num_dimensions() const;
433 
441  const size_type *
442  shape() const;
443 
451  const boost::multi_array_types::index *
452  strides() const;
453 
462  const boost::multi_array_types::index *
463  index_bases() const;
464 
475  template <typename T>
476  const T *
477  origin() const;
478 
484  const storage_order_type&
485  storage_order() const;
486 
493  pixelType() const;
494 
500  EndianType
501  endianType() const;
502 
511  template<typename T>
513  array();
514 
523  template<typename T>
524  const typename PixelBuffer<T>::array_ref_type&
525  array() const;
526 
532  raw_type *
533  data();
534 
540  const raw_type *
541  data() const;
542 
550  template<typename T>
551  T *
552  data();
553 
561  template<typename T>
562  const T *
563  data() const;
564 
575  bool
576  valid() const;
577 
589  operator = (const VariantPixelBuffer& rhs);
590 
597  bool
598  operator == (const VariantPixelBuffer& rhs) const;
599 
606  bool
607  operator != (const VariantPixelBuffer& rhs) const;
608 
617  template <typename InputIterator>
618  void
619  assign(InputIterator begin,
620  InputIterator end);
621 
632  template<class charT, class traits>
633  inline void
634  read(std::basic_istream<charT,traits>& stream);
635 
646  template<class charT, class traits>
647  inline void
648  write(std::basic_ostream<charT,traits>& stream) const;
649 
650  protected:
652  variant_buffer_type buffer;
653  };
654 
655  namespace detail
656  {
657 
659  template<typename T>
660  struct VariantPixelBufferVisitor : public boost::static_visitor<PixelBuffer<T> *>
661  {
670  operator() (std::shared_ptr<PixelBuffer<T>>& v) const
671  {
672  if (!v)
673  throw std::runtime_error("Null pixel type");
674  return v.get();
675  }
676 
683  template <typename U>
685  operator() (U& /* v */) const
686  {
687  throw std::runtime_error("Unsupported pixel type conversion for buffer");
688  }
689  };
690 
692  template<typename T>
693  struct VariantPixelBufferConstVisitor : public boost::static_visitor<const PixelBuffer<T> *>
694  {
702  const PixelBuffer<T> *
703  operator() (const std::shared_ptr<PixelBuffer<T>>& v) const
704  {
705  if (!v)
706  throw std::runtime_error("Null pixel type");
707  return v.get();
708  }
709 
716  template <typename U>
717  const PixelBuffer<T> *
718  operator() (U& /* v */) const
719  {
720  throw std::runtime_error("Unsupported pixel type conversion for buffer");
721  }
722  };
723 
725  template <typename InputIterator>
726  struct VariantPixelBufferAssignVisitor : public boost::static_visitor<>
727  {
729  InputIterator begin;
731  InputIterator end;
732 
739  VariantPixelBufferAssignVisitor(InputIterator begin, InputIterator end):
740  begin(begin), end(end)
741  {}
742 
749  void
750  operator() (std::shared_ptr<PixelBuffer<typename std::iterator_traits<InputIterator>::value_type>>& v) const
751  {
752  if (!v)
753  throw std::runtime_error("Null pixel type");
754  v->array().assign(begin, end);
755  }
756 
762  template <typename T>
763  void
764  operator() (T& /* v */) const
765  {
766  throw std::runtime_error("Unsupported pixel type conversion for assignment");
767  }
768  };
769 
771  template<class charT, class traits>
772  struct VariantPixelBufferReadVisitor : public boost::static_visitor<>
773  {
775  std::basic_istream<charT,traits>& stream;
776 
782  VariantPixelBufferReadVisitor(std::basic_istream<charT,traits>& stream):
783  stream(stream)
784  {}
785 
791  template <typename T>
792  void
793  operator() (T& v) const
794  {
795  if (!v)
796  throw std::runtime_error("Null pixel type");
797  v->read(stream);
798  }
799  };
800 
802  template<class charT, class traits>
803  struct VariantPixelBufferWriteVisitor : public boost::static_visitor<>
804  {
806  std::basic_ostream<charT,traits>& stream;
807 
813  VariantPixelBufferWriteVisitor(std::basic_ostream<charT,traits>& stream):
814  stream(stream)
815  {}
816 
822  template <typename T>
823  void
824  operator() (const T& v) const
825  {
826  if (!v)
827  throw std::runtime_error("Null pixel type");
828  v->write(stream);
829  }
830  };
831 
833  struct CopySubchannelVisitor : public boost::static_visitor<>
834  {
839 
847  dimension_size_type subC):
848  dest(dest),
849  subC(subC)
850  {}
851 
857  template<typename T>
858  void
859  operator()(const T& v)
860  {
861  // Shape is the same as the source buffer, but with one subchannel.
862  std::array<VariantPixelBuffer::size_type, 9> dest_shape;
863  const VariantPixelBuffer::size_type *shape_ptr(v->shape());
864  std::copy(shape_ptr, shape_ptr + PixelBufferBase::dimensions,
865  dest_shape.begin());
866  dest_shape[DIM_SUBCHANNEL] = 1;
867 
868  // Default to planar ordering; since openByes/saveBytes
869  // don't use ZTC the DimensionOrder doesn't matter here so
870  // long as it matches what the TIFF reader/writer uses.
872 
875  dest.setBuffer(dest_shape, v->pixelType(), order);
876 
877  T& destbuf = boost::get<T>(dest.vbuffer());
878 
879  typename boost::multi_array_types::index_gen indices;
880  typedef boost::multi_array_types::index_range range;
881  destbuf->array() = v->array()[boost::indices[range()][range()][range()][range()][range()][range(subC,subC+1)][range()][range()][range()]];
882  }
883  };
884 
886  struct MergeSubchannelVisitor : public boost::static_visitor<>
887  {
892 
900  dimension_size_type subC):
901  dest(dest),
902  subC(subC)
903  {}
904 
910  template<typename T>
911  void
912  operator()(const T& v)
913  {
914  T& destbuf = boost::get<T>(dest.vbuffer());
915 
916  typename boost::multi_array_types::index_gen indices;
917  typedef boost::multi_array_types::index_range range;
918  destbuf->array()[boost::indices[range()][range()][range()][range()][range()][range(subC,subC+1)][range()][range()][range()]] = v->array();
919  }
920  };
921 
922  }
923 
925  template<typename T>
926  inline typename PixelBuffer<T>::array_ref_type&
928  {
930  return boost::apply_visitor(v, buffer)->array();
931  }
932 
934  template<typename T>
935  inline const typename PixelBuffer<T>::array_ref_type&
937  {
939  return boost::apply_visitor(v, buffer)->array();
940  }
941 
942  template<typename T>
943  inline T *
945  {
947  return boost::apply_visitor(v, buffer)->data();
948  }
949 
950  template<typename T>
951  inline const T *
953  {
955  return boost::apply_visitor(v, buffer)->data();
956  }
957 
958  template<typename T>
959  inline const T *
961  {
963  return boost::apply_visitor(v, buffer)->origin();
964  }
965 
973  template <typename InputIterator>
974  inline void
975  VariantPixelBuffer::assign(InputIterator begin,
976  InputIterator end)
977  {
979  boost::apply_visitor(v, buffer);
980  }
981 
982  template<class charT, class traits>
983  inline void
984  VariantPixelBuffer::read(std::basic_istream<charT,traits>& stream)
985  {
987  boost::apply_visitor(v, buffer);
988  }
989 
990  template<class charT, class traits>
991  inline void
992  VariantPixelBuffer::write(std::basic_ostream<charT,traits>& stream) const
993  {
995  boost::apply_visitor(v, buffer);
996  }
997 
998  }
999 }
1000 
1001 namespace std
1002 {
1003 
1011  template<class charT, class traits>
1012  inline std::basic_istream<charT,traits>&
1013  operator>> (std::basic_istream<charT,traits>& is,
1015  {
1016  buf.read(is);
1017  return is;
1018  }
1019 
1027  template<class charT, class traits>
1028  inline std::basic_ostream<charT,traits>&
1029  operator<< (std::basic_ostream<charT,traits>& os,
1030  const ::ome::files::VariantPixelBuffer& buf)
1031  {
1032  buf.write(os);
1033  return os;
1034  }
1035 
1036 }
1037 
1038 #endif // OME_FILES_VARIANTPIXELBUFFER_H
1039 
1040 /*
1041  * Local Variables:
1042  * mode:C++
1043  * End:
1044  */
VariantPixelBufferWriteVisitor(std::basic_ostream< charT, traits > &stream)
Constructor.
Definition: VariantPixelBuffer.h:813
boost::mpl::joint_view< integer_pixel_types, float_pixel_types >::type basic_pixel_types_view
Aggregate view of all numeric types.
Definition: VariantPixelBuffer.h:111
boost::multi_array_ref< value_type, dimensions > array_ref_type
Type for multi-dimensional pixel array view referencing external data.
Definition: PixelBuffer.h:246
VariantPixelBuffer & dest
Destination pixel buffer.
Definition: VariantPixelBuffer.h:889
void read(std::basic_istream< charT, traits > &stream)
Read raw pixel data from a stream in physical storage order.
Definition: VariantPixelBuffer.h:984
VariantPixelBuffer(const ExtentList &extents, ::ome::xml::model::enums::PixelType pixeltype=::ome::xml::model::enums::PixelType::UINT8, const storage_order_type &storage=PixelBufferBase::default_storage_order())
Construct from extents (internal storage).
Definition: VariantPixelBuffer.h:175
Properties of BIT pixels.
Definition: PixelProperties.h:299
InputIterator end
Input end.
Definition: VariantPixelBuffer.h:731
Buffer for a specific pixel type.
Definition: PixelBuffer.h:235
void setBuffer(const range_type &range, ::ome::xml::model::enums::PixelType pixeltype=::ome::xml::model::enums::PixelType::UINT8, const storage_order_type &storage=PixelBufferBase::default_storage_order())
Set the buffer from ranges (internal storage).
Definition: VariantPixelBuffer.h:401
boost::mpl::vector empty_types
Empty vector placeholder.
Definition: VariantPixelBuffer.h:125
std::size_t dimension_size_type
Size type for image dimensions.
Definition: Types.h:58
const storage_order_type & storage_order() const
Get the array storage order.
Definition: VariantPixelBuffer.cpp:375
static variant_buffer_type makeBuffer(const range_type &range, const storage_order_type &storage, ::ome::xml::model::enums::PixelType pixeltype)
Create buffer from ranges (helper).
Definition: VariantPixelBuffer.h:284
virtual ~VariantPixelBuffer()
Destructor.
Definition: VariantPixelBuffer.h:225
InputIterator begin
Input start.
Definition: VariantPixelBuffer.h:729
EndianType endianType() const
Get the endianness of the pixel type stored in the buffer.
Definition: VariantPixelBuffer.cpp:389
VariantPixelBufferReadVisitor(std::basic_istream< charT, traits > &stream)
Constructor.
Definition: VariantPixelBuffer.h:782
STL namespace.
void setBuffer(const ExtentList &extents, ::ome::xml::model::enums::PixelType pixeltype=::ome::xml::model::enums::PixelType::UINT8, const storage_order_type &storage=PixelBufferBase::default_storage_order())
Set the buffer from extents (helper).
Definition: VariantPixelBuffer.h:383
Map a given PixelPropertiesType enum to the corresponding language types.
Definition: PixelProperties.h:60
PixelBuffer< T >::array_ref_type & array()
Get the pixel data.
Definition: VariantPixelBuffer.h:927
bool valid() const
Check the buffer validity.
Definition: VariantPixelBuffer.cpp:326
variant_buffer_type & vbuffer()
Get a reference to the variant buffer.
Definition: VariantPixelBuffer.h:234
VariantPixelBuffer & dest
Destination pixel buffer.
Definition: VariantPixelBuffer.h:836
const T * origin() const
Get the origin of the array.
Definition: VariantPixelBuffer.h:960
std::basic_ostream< charT, traits > & stream
The output stream.
Definition: VariantPixelBuffer.h:806
Properties of COMPLEXFLOAT pixels.
Definition: PixelProperties.h:334
VariantPixelBuffer()
Default constructor.
Definition: VariantPixelBuffer.h:158
dimension_size_type subC
Subchannel to copy.
Definition: VariantPixelBuffer.h:838
::ome::xml::model::enums::PixelType pixelType() const
Get the type of pixels stored in the buffer.
Definition: VariantPixelBuffer.cpp:382
boost::mpl::vector< PixelProperties<::ome::xml::model::enums::PixelType::INT8 >, PixelProperties<::ome::xml::model::enums::PixelType::INT16 >, PixelProperties<::ome::xml::model::enums::PixelType::INT32 >, PixelProperties<::ome::xml::model::enums::PixelType::UINT8 >, PixelProperties<::ome::xml::model::enums::PixelType::UINT16 >, PixelProperties<::ome::xml::model::enums::PixelType::UINT32 >, PixelProperties<::ome::xml::model::enums::PixelType::BIT > > integer_pixel_types
Integer pixel types.
Definition: VariantPixelBuffer.h:101
boost::mpl::transform_view< basic_pixel_types_view, make_buffer< boost::mpl::_1 > >::type pixel_buffer_types_view
Aggregate view of all buffer types.
Definition: VariantPixelBuffer.h:122
Properties of UINT16 pixels.
Definition: PixelProperties.h:207
Convert T into a buffer.
Definition: VariantPixelBuffer.h:115
dimension_size_type subC
Subchannel to copy.
Definition: VariantPixelBuffer.h:891
Properties of INT32 pixels.
Definition: PixelProperties.h:161
VariantPixelBuffer & operator=(const VariantPixelBuffer &rhs)
Assign a pixel buffer.
Definition: VariantPixelBuffer.cpp:410
Open Microscopy Environment C++.
Copy a single subchannel from a PixelBuffer.
Definition: VariantPixelBuffer.h:833
const variant_buffer_type & vbuffer() const
Get a reference to the variant buffer.
Definition: VariantPixelBuffer.h:245
boost::general_storage_order< dimensions > storage_order_type
Storage ordering type for controlling pixel memory layout.
Definition: PixelBuffer.h:120
Native endian.
Definition: Types.h:71
static storage_order_type make_storage_order(ome::xml::model::enums::DimensionOrder order, bool interleaved)
Generate storage ordering for a given dimension order.
Definition: PixelBuffer.cpp:54
MergeSubchannelVisitor(VariantPixelBuffer &dest, dimension_size_type subC)
Constructor.
Definition: VariantPixelBuffer.h:899
void operator()(const T &v)
Copy subchannel.
Definition: VariantPixelBuffer.h:859
static variant_buffer_type createBuffer(const range_type &range, ::ome::xml::model::enums::PixelType pixeltype=::ome::xml::model::enums::PixelType::UINT8, const storage_order_type &storage=PixelBufferBase::default_storage_order())
Create buffer from ranges (helper).
Definition: VariantPixelBuffer.h:350
boost::mpl::insert_range< empty_types, boost::mpl::end< empty_types >::type, pixel_buffer_types_view >::type pixel_buffer_types
List of all pixel buffer types.
Definition: VariantPixelBuffer.h:128
Read data into a PixelBuffer.
Definition: VariantPixelBuffer.h:772
Merge a single subchannel into a PixelBuffer.
Definition: VariantPixelBuffer.h:886
VariantPixelBuffer(std::shared_ptr< PixelBuffer< T >> &buffer)
Construct from existing pixel buffer.
Definition: VariantPixelBuffer.h:218
EndianType
Endianness.
Definition: Types.h:67
PixelProperties<::ome::xml::model::enums::PixelType::UINT8 >::std_type raw_type
Raw pixel type used in public interfaces.
Definition: VariantPixelBuffer.h:135
Properties of INT16 pixels.
Definition: PixelProperties.h:138
CopySubchannelVisitor(VariantPixelBuffer &dest, dimension_size_type subC)
Constructor.
Definition: VariantPixelBuffer.h:846
bool operator!=(const VariantPixelBuffer &rhs) const
Compare a pixel buffer for inequality.
Definition: VariantPixelBuffer.cpp:423
Find a PixelBuffer data array of a specific pixel type.
Definition: VariantPixelBuffer.h:693
VariantPixelBufferAssignVisitor(InputIterator begin, InputIterator end)
Constructor.
Definition: VariantPixelBuffer.h:739
boost::mpl::vector< PixelProperties<::ome::xml::model::enums::PixelType::FLOAT >, PixelProperties<::ome::xml::model::enums::PixelType::DOUBLE >, PixelProperties<::ome::xml::model::enums::PixelType::COMPLEXFLOAT >, PixelProperties<::ome::xml::model::enums::PixelType::COMPLEXDOUBLE > > float_pixel_types
Floating-point pixel types.
Definition: VariantPixelBuffer.h:107
size_type num_dimensions() const
Get the number of dimensions in the multi-dimensional array.
Definition: VariantPixelBuffer.cpp:347
bool managed() const
Check if the buffer is internally managed.
Definition: VariantPixelBuffer.cpp:333
void operator()(const T &v)
Merge subchannel.
Definition: VariantPixelBuffer.h:912
Assign a PixelBuffer from an input iterator.
Definition: VariantPixelBuffer.h:726
void write(std::basic_ostream< charT, traits > &stream) const
Write raw pixel data to a stream in physical storage order.
Definition: VariantPixelBuffer.h:992
variant_buffer_type buffer
Pixel storage.
Definition: VariantPixelBuffer.h:652
Write data from a PixelBuffer.
Definition: VariantPixelBuffer.h:803
std::basic_istream< charT, traits > & stream
The input stream.
Definition: VariantPixelBuffer.h:775
VariantPixelBuffer(const range_type &range, ::ome::xml::model::enums::PixelType pixeltype=::ome::xml::model::enums::PixelType::UINT8, const storage_order_type &storage=PixelBufferBase::default_storage_order())
Construct from ranges (internal storage).
Definition: VariantPixelBuffer.h:193
Properties of UINT32 pixels.
Definition: PixelProperties.h:230
boost::detail::multi_array::extent_gen< dimensions > range_type
Extent range type.
Definition: PixelBuffer.h:123
static variant_buffer_type createBuffer(const ExtentList &extents, ::ome::xml::model::enums::PixelType pixeltype=::ome::xml::model::enums::PixelType::UINT8, const storage_order_type &storage=PixelBufferBase::default_storage_order())
Create buffer from extents (internal storage).
Definition: VariantPixelBuffer.h:317
const boost::multi_array_types::index * index_bases() const
Get the index bases of the multi-dimensional array.
Definition: VariantPixelBuffer.cpp:368
Find a PixelBuffer data array of a specific pixel type.
Definition: VariantPixelBuffer.h:660
PixelBufferBase::range_type range_type
Extent range type.
Definition: VariantPixelBuffer.h:147
static const uint16_t dimensions
Total number of supported dimensions.
Definition: PixelBuffer.h:107
const size_type * shape() const
Get the shape of the multi-dimensional array.
Definition: VariantPixelBuffer.cpp:354
bool operator==(const VariantPixelBuffer &rhs) const
Compare a pixel buffer for equality.
Definition: VariantPixelBuffer.cpp:417
size_type num_elements() const
Get the number of pixel elements in the multi-dimensional array.
Definition: VariantPixelBuffer.cpp:340
const boost::multi_array_types::index * strides() const
Get the strides of the multi-dimensional array.
Definition: VariantPixelBuffer.cpp:361
Properties of UINT8 pixels.
Definition: PixelProperties.h:184
static variant_buffer_type makeBuffer(const ExtentList &extents, const storage_order_type &storage, ::ome::xml::model::enums::PixelType pixeltype)
Create buffer from extents (helper).
Definition: VariantPixelBuffer.h:264
static storage_order_type default_storage_order()
Generate default storage ordering.
Definition: PixelBuffer.cpp:133
raw_type * data()
Get raw buffered data.
Definition: VariantPixelBuffer.cpp:396
std::shared_ptr< PixelBuffer< typename T::std_type > > type
Buffer type.
Definition: VariantPixelBuffer.h:118
Buffer for all pixel types.
Definition: VariantPixelBuffer.h:75
Properties of DOUBLE pixels.
Definition: PixelProperties.h:276
boost::multi_array_types::size_type size_type
Size type.
Definition: VariantPixelBuffer.h:138
void assign(InputIterator begin, InputIterator end)
Assign pixel values.
Definition: VariantPixelBuffer.h:975
boost::make_variant_over< pixel_buffer_types >::type variant_buffer_type
Buffer type, allowing assignment of all buffer types.
Definition: VariantPixelBuffer.h:132
PixelBufferBase::storage_order_type storage_order_type
Storage ordering type for controlling pixel memory layout.
Definition: VariantPixelBuffer.h:144
std::array< boost::multi_array_types::index, PixelBufferBase::dimensions > indices_type
Type used to index all dimensions in public interfaces.
Definition: VariantPixelBuffer.h:141
Properties of COMPLEXDOUBLE pixels.
Definition: PixelProperties.h:357
Logical sub-channel (typically used for RGB channel sub-components) (S).
Definition: PixelBuffer.h:85