bioformats  5.1.3
VariantPixelBuffer.h
1 /*
2  * #%L
3  * OME-BIOFORMATS 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_BIOFORMATS_VARIANTPIXELBUFFER_H
39 #define OME_BIOFORMATS_VARIANTPIXELBUFFER_H
40 
41 #include <ome/bioformats/PixelBuffer.h>
42 
43 #include <ome/common/variant.h>
44 
45 namespace ome
46 {
47  namespace bioformats
48  {
49 
73  {
74  private:
75  /*
76  * The following series of typedefs may appear a little
77  * complicated, and perhaps unnecessary, but they do have a
78  * purpose. They exist to work around pre-C++11 compiler
79  * limitations (lack of variadic templates), primarily a limit
80  * to the maximum number of types which may be used with
81  * boost::variant. To exceed this limit (minimum guaranteed is
82  * 10), boost::mpl sequences are used to define the variant
83  * types. These also have length limits, so the type list is
84  * built up by defining separate type sequences, then
85  * concatenating them, and transforming them to provide list
86  * variants. Note that none of this is code per se; it's all
87  * compile-time template expansion which evaluates to a list of
88  * permitted types.
89  */
90 
92  typedef boost::mpl::vector<PixelProperties< ::ome::xml::model::enums::PixelType::INT8>,
99 
101  typedef boost::mpl::vector< PixelProperties< ::ome::xml::model::enums::PixelType::FLOAT>,
105 
107  typedef boost::mpl::joint_view<integer_pixel_types,
108  float_pixel_types>::type basic_pixel_types_view;
109 
111  template<typename T>
112  struct make_buffer
113  {
115  typedef ome::compat::shared_ptr<PixelBuffer<typename T::std_type> > type;
116  };
117 
119  typedef boost::mpl::transform_view<basic_pixel_types_view, make_buffer<boost::mpl::_1> >::type pixel_buffer_types_view;
120 
122  typedef boost::mpl::vector<> empty_types;
123 
125  typedef boost::mpl::insert_range<empty_types, boost::mpl::end<empty_types>::type, pixel_buffer_types_view>::type pixel_buffer_types;
126 
127  public:
129  typedef boost::make_variant_over<pixel_buffer_types>::type variant_buffer_type;
130 
133 
135  typedef boost::multi_array_types::size_type size_type;
136 
138  typedef ome::compat::array<boost::multi_array_types::index, PixelBufferBase::dimensions> indices_type;
139 
142 
145 
146  public:
154  explicit
156  buffer(createBuffer(boost::extents[1][1][1][1][1][1][1][1][1]))
157  {
158  }
159 
170  template<class ExtentList>
171  explicit
172  VariantPixelBuffer(const ExtentList& extents,
174  const storage_order_type& storage = PixelBufferBase::default_storage_order()):
175  buffer(createBuffer(extents, pixeltype, storage))
176  {
177  }
178 
189  explicit
190  VariantPixelBuffer(const range_type& range,
192  const storage_order_type& storage = PixelBufferBase::default_storage_order()):
193  buffer(createBuffer(range, pixeltype, storage))
194  {
195  }
196 
205  explicit
207 
213  template<typename T>
214  explicit
215  VariantPixelBuffer(ome::compat::shared_ptr<PixelBuffer<T> >& buffer):
216  buffer(buffer)
217  {
218  }
219 
221  virtual
223  {}
224 
230  variant_buffer_type&
232  {
233  return buffer;
234  }
235 
241  const variant_buffer_type&
242  vbuffer() const
243  {
244  return buffer;
245  }
246 
247  protected:
259  template<class T, class ExtentList>
260  static variant_buffer_type
261  makeBuffer(const ExtentList& extents,
262  const storage_order_type& storage,
264  {
265  return ome::compat::shared_ptr<PixelBuffer<T> >(new PixelBuffer<T>(extents, pixeltype, ENDIAN_NATIVE, storage));
266  }
267 
279  template<class T>
280  static variant_buffer_type
281  makeBuffer(const range_type& range,
282  const storage_order_type& storage,
284  {
285  return ome::compat::shared_ptr<PixelBuffer<T> >(new PixelBuffer<T>(range, pixeltype, ENDIAN_NATIVE, storage));
286  }
287 
288  // No switch default to avoid -Wunreachable-code errors.
289  // However, this then makes -Wswitch-default complain. Disable
290  // temporarily.
291 #ifdef __GNUC__
292 # pragma GCC diagnostic push
293 # pragma GCC diagnostic ignored "-Wswitch-default"
294 #endif
295 
307  template<class ExtentList>
308  static variant_buffer_type
309  createBuffer(const ExtentList& extents,
311  const storage_order_type& storage = PixelBufferBase::default_storage_order())
312  {
313  variant_buffer_type buf;
314 
315  switch(pixeltype)
316  {
317  case ::ome::xml::model::enums::PixelType::INT8:
318  buf = makeBuffer<PixelProperties< ::ome::xml::model::enums::PixelType::INT8>::std_type>(extents, storage, pixeltype);
319  break;
320  case ::ome::xml::model::enums::PixelType::INT16:
321  buf = makeBuffer<PixelProperties< ::ome::xml::model::enums::PixelType::INT16>::std_type>(extents, storage, pixeltype);
322  break;
323  case ::ome::xml::model::enums::PixelType::INT32:
324  buf = makeBuffer<PixelProperties< ::ome::xml::model::enums::PixelType::INT32>::std_type>(extents, storage, pixeltype);
325  break;
326  case ::ome::xml::model::enums::PixelType::UINT8:
327  buf = makeBuffer<PixelProperties< ::ome::xml::model::enums::PixelType::UINT8>::std_type>(extents, storage, pixeltype);
328  break;
329  case ::ome::xml::model::enums::PixelType::UINT16:
330  buf = makeBuffer<PixelProperties< ::ome::xml::model::enums::PixelType::UINT16>::std_type>(extents, storage, pixeltype);
331  break;
332  case :: ome::xml::model::enums::PixelType::UINT32:
333  buf = makeBuffer<PixelProperties< ::ome::xml::model::enums::PixelType::UINT32>::std_type>(extents, storage, pixeltype);
334  break;
335  case ::ome::xml::model::enums::PixelType::FLOAT:
336  buf = makeBuffer<PixelProperties< ::ome::xml::model::enums::PixelType::FLOAT>::std_type>(extents, storage, pixeltype);
337  break;
338  case ::ome::xml::model::enums::PixelType::DOUBLE:
339  buf = makeBuffer<PixelProperties< ::ome::xml::model::enums::PixelType::DOUBLE>::std_type>(extents, storage, pixeltype);
340  break;
341  case ::ome::xml::model::enums::PixelType::BIT:
342  buf = makeBuffer<PixelProperties< ::ome::xml::model::enums::PixelType::BIT>::std_type>(extents, storage, pixeltype);
343  break;
344  case ::ome::xml::model::enums::PixelType::COMPLEX:
345  buf = makeBuffer<PixelProperties< ::ome::xml::model::enums::PixelType::COMPLEX>::std_type>(extents, storage, pixeltype);
346  break;
347  case ::ome::xml::model::enums::PixelType::DOUBLECOMPLEX:
348  buf = makeBuffer<PixelProperties< ::ome::xml::model::enums::PixelType::DOUBLECOMPLEX>::std_type>(extents, storage, pixeltype);
349  break;
350  }
351 
352  return buf;
353  }
354 
366  static variant_buffer_type
367  createBuffer(const range_type& range,
369  const storage_order_type& storage = PixelBufferBase::default_storage_order())
370  {
371  variant_buffer_type buf;
372 
373  switch(pixeltype)
374  {
375  case ::ome::xml::model::enums::PixelType::INT8:
376  buf = makeBuffer<PixelProperties< ::ome::xml::model::enums::PixelType::INT8>::std_type>(range, storage, pixeltype);
377  break;
378  case ::ome::xml::model::enums::PixelType::INT16:
379  buf = makeBuffer<PixelProperties< ::ome::xml::model::enums::PixelType::INT16>::std_type>(range, storage, pixeltype);
380  break;
381  case ::ome::xml::model::enums::PixelType::INT32:
382  buf = makeBuffer<PixelProperties< ::ome::xml::model::enums::PixelType::INT32>::std_type>(range, storage, pixeltype);
383  break;
384  case ::ome::xml::model::enums::PixelType::UINT8:
385  buf = makeBuffer<PixelProperties< ::ome::xml::model::enums::PixelType::UINT8>::std_type>(range, storage, pixeltype);
386  break;
387  case ::ome::xml::model::enums::PixelType::UINT16:
388  buf = makeBuffer<PixelProperties< ::ome::xml::model::enums::PixelType::UINT16>::std_type>(range, storage, pixeltype);
389  break;
390  case :: ome::xml::model::enums::PixelType::UINT32:
391  buf = makeBuffer<PixelProperties< ::ome::xml::model::enums::PixelType::UINT32>::std_type>(range, storage, pixeltype);
392  break;
393  case ::ome::xml::model::enums::PixelType::FLOAT:
394  buf = makeBuffer<PixelProperties< ::ome::xml::model::enums::PixelType::FLOAT>::std_type>(range, storage, pixeltype);
395  break;
396  case ::ome::xml::model::enums::PixelType::DOUBLE:
397  buf = makeBuffer<PixelProperties< ::ome::xml::model::enums::PixelType::DOUBLE>::std_type>(range, storage, pixeltype);
398  break;
399  case ::ome::xml::model::enums::PixelType::BIT:
400  buf = makeBuffer<PixelProperties< ::ome::xml::model::enums::PixelType::BIT>::std_type>(range, storage, pixeltype);
401  break;
402  case ::ome::xml::model::enums::PixelType::COMPLEX:
403  buf = makeBuffer<PixelProperties< ::ome::xml::model::enums::PixelType::COMPLEX>::std_type>(range, storage, pixeltype);
404  break;
405  case ::ome::xml::model::enums::PixelType::DOUBLECOMPLEX:
406  buf = makeBuffer<PixelProperties< ::ome::xml::model::enums::PixelType::DOUBLECOMPLEX>::std_type>(range, storage, pixeltype);
407  break;
408  }
409 
410  return buf;
411  }
412 
413 #ifdef __GNUC__
414 # pragma GCC diagnostic pop
415 #endif
416 
417  public:
428  template<class ExtentList>
429  void
430  setBuffer(const ExtentList& extents,
432  const storage_order_type& storage = PixelBufferBase::default_storage_order())
433  {
434  buffer = createBuffer(extents, pixeltype, storage);
435  }
436 
447  void
448  setBuffer(const range_type& range,
450  const storage_order_type& storage = PixelBufferBase::default_storage_order())
451  {
452  buffer = createBuffer(range, pixeltype, storage);
453  }
454 
462  bool
463  managed() const;
464 
468  size_type
469  num_elements() const;
470 
474  size_type
475  num_dimensions() const;
476 
484  const size_type *
485  shape() const;
486 
494  const boost::multi_array_types::index *
495  strides() const;
496 
505  const boost::multi_array_types::index *
506  index_bases() const;
507 
518  template <typename T>
519  const T *
520  origin() const;
521 
527  const storage_order_type&
528  storage_order() const;
529 
534  pixelType() const;
535 
539  EndianType
540  endianType() const;
541 
550  template<typename T>
552  array();
553 
562  template<typename T>
563  const typename PixelBuffer<T>::array_ref_type&
564  array() const;
565 
571  raw_type *
572  data();
573 
579  const raw_type *
580  data() const;
581 
589  template<typename T>
590  T *
591  data();
592 
600  template<typename T>
601  const T *
602  data() const;
603 
614  bool
615  valid() const;
616 
628  operator = (const VariantPixelBuffer& rhs);
629 
636  bool
637  operator == (const VariantPixelBuffer& rhs) const;
638 
645  bool
646  operator != (const VariantPixelBuffer& rhs) const;
647 
656  template <typename InputIterator>
657  void
658  assign(InputIterator begin,
659  InputIterator end);
660 
671  template<class charT, class traits>
672  inline void
673  read(std::basic_istream<charT,traits>& stream);
674 
685  template<class charT, class traits>
686  inline void
687  write(std::basic_ostream<charT,traits>& stream) const;
688 
689  protected:
691  variant_buffer_type buffer;
692  };
693 
694  namespace detail
695  {
696 
698  template<typename T>
699  struct VariantPixelBufferVisitor : public boost::static_visitor<PixelBuffer<T>&>
700  {
709  operator() (ome::compat::shared_ptr<PixelBuffer<T> >& v) const
710  {
711  if (!v)
712  throw std::runtime_error("Null pixel type");
713  return *v;
714  }
715 
722  template <typename U>
724  operator() (U& /* v */) const
725  {
726  throw std::runtime_error("Unsupported pixel type conversion for buffer");
727  }
728  };
729 
731  template<typename T>
732  struct VariantPixelBufferConstVisitor : public boost::static_visitor<const PixelBuffer<T>&>
733  {
741  const PixelBuffer<T>&
742  operator() (const ome::compat::shared_ptr<PixelBuffer<T> >& v) const
743  {
744  if (!v)
745  throw std::runtime_error("Null pixel type");
746  return *v;
747  }
748 
755  template <typename U>
756  const PixelBuffer<T>&
757  operator() (U& /* v */) const
758  {
759  throw std::runtime_error("Unsupported pixel type conversion for buffer");
760  }
761  };
762 
764  template <typename InputIterator>
765  struct VariantPixelBufferAssignVisitor : public boost::static_visitor<>
766  {
768  InputIterator begin;
770  InputIterator end;
771 
778  VariantPixelBufferAssignVisitor(InputIterator begin, InputIterator end):
779  begin(begin), end(end)
780  {}
781 
788  void
789  operator() (ome::compat::shared_ptr<PixelBuffer<typename std::iterator_traits<InputIterator>::value_type> >& v) const
790  {
791  if (!v)
792  throw std::runtime_error("Null pixel type");
793  v->array().assign(begin, end);
794  }
795 
801  template <typename T>
802  void
803  operator() (T& /* v */) const
804  {
805  throw std::runtime_error("Unsupported pixel type conversion for assignment");
806  }
807  };
808 
810  template<class charT, class traits>
811  struct VariantPixelBufferReadVisitor : public boost::static_visitor<>
812  {
814  std::basic_istream<charT,traits>& stream;
815 
821  VariantPixelBufferReadVisitor(std::basic_istream<charT,traits>& stream):
822  stream(stream)
823  {}
824 
830  template <typename T>
831  void
832  operator() (T& v) const
833  {
834  if (!v)
835  throw std::runtime_error("Null pixel type");
836  v->read(stream);
837  }
838  };
839 
841  template<class charT, class traits>
842  struct VariantPixelBufferWriteVisitor : public boost::static_visitor<>
843  {
845  std::basic_ostream<charT,traits>& stream;
846 
852  VariantPixelBufferWriteVisitor(std::basic_ostream<charT,traits>& stream):
853  stream(stream)
854  {}
855 
861  template <typename T>
862  void
863  operator() (const T& v) const
864  {
865  if (!v)
866  throw std::runtime_error("Null pixel type");
867  v->write(stream);
868  }
869  };
870 
872  struct CopySubchannelVisitor : public boost::static_visitor<>
873  {
878 
886  dimension_size_type subC):
887  dest(dest),
888  subC(subC)
889  {}
890 
896  template<typename T>
897  void
898  operator()(const T& v)
899  {
900  // Shape is the same as the source buffer, but with one subchannel.
901  ome::compat::array<VariantPixelBuffer::size_type, 9> dest_shape;
902  const VariantPixelBuffer::size_type *shape_ptr(v->shape());
903  std::copy(shape_ptr, shape_ptr + PixelBufferBase::dimensions,
904  dest_shape.begin());
905  dest_shape[DIM_SUBCHANNEL] = 1;
906 
907  // Default to planar ordering; since openByes/saveBytes
908  // don't use ZTC the DimensionOrder doesn't matter here so
909  // long as it matches what the TIFF reader/writer uses.
911 
914  dest.setBuffer(dest_shape, v->pixelType(), order);
915 
916  T& destbuf = boost::get<T>(dest.vbuffer());
917 
918  typename boost::multi_array_types::index_gen indices;
919  typedef boost::multi_array_types::index_range range;
920  destbuf->array() = v->array()[boost::indices[range()][range()][range()][range()][range()][range(subC,subC+1)][range()][range()][range()]];
921  }
922  };
923 
925  struct MergeSubchannelVisitor : public boost::static_visitor<>
926  {
931 
939  dimension_size_type subC):
940  dest(dest),
941  subC(subC)
942  {}
943 
949  template<typename T>
950  void
951  operator()(const T& v)
952  {
953  T& destbuf = boost::get<T>(dest.vbuffer());
954 
955  typename boost::multi_array_types::index_gen indices;
956  typedef boost::multi_array_types::index_range range;
957  destbuf->array()[boost::indices[range()][range()][range()][range()][range()][range(subC,subC+1)][range()][range()][range()]] = v->array();
958  }
959  };
960 
961  }
962 
964  template<typename T>
965  inline typename PixelBuffer<T>::array_ref_type&
967  {
969  return boost::apply_visitor(v, buffer).array();
970  }
971 
973  template<typename T>
974  inline const typename PixelBuffer<T>::array_ref_type&
976  {
978  return boost::apply_visitor(v, buffer).array();
979  }
980 
981  template<typename T>
982  inline T *
984  {
986  return boost::apply_visitor(v, buffer).data();
987  }
988 
989  template<typename T>
990  inline const T *
992  {
994  return boost::apply_visitor(v, buffer).data();
995  }
996 
997  template<typename T>
998  inline const T *
1000  {
1002  return boost::apply_visitor(v, buffer).origin();
1003  }
1004 
1012  template <typename InputIterator>
1013  inline void
1014  VariantPixelBuffer::assign(InputIterator begin,
1015  InputIterator end)
1016  {
1018  boost::apply_visitor(v, buffer);
1019  }
1020 
1021  template<class charT, class traits>
1022  inline void
1023  VariantPixelBuffer::read(std::basic_istream<charT,traits>& stream)
1024  {
1026  boost::apply_visitor(v, buffer);
1027  }
1028 
1029  template<class charT, class traits>
1030  inline void
1031  VariantPixelBuffer::write(std::basic_ostream<charT,traits>& stream) const
1032  {
1034  boost::apply_visitor(v, buffer);
1035  }
1036 
1037  }
1038 }
1039 
1040 namespace std
1041 {
1042 
1050  template<class charT, class traits>
1051  inline std::basic_istream<charT,traits>&
1052  operator>> (std::basic_istream<charT,traits>& is,
1054  {
1055  buf.read(is);
1056  return is;
1057  }
1058 
1066  template<class charT, class traits>
1067  inline std::basic_ostream<charT,traits>&
1068  operator<< (std::basic_ostream<charT,traits>& os,
1069  const ::ome::bioformats::VariantPixelBuffer& buf)
1070  {
1071  buf.write(os);
1072  return os;
1073  }
1074 
1075 }
1076 
1077 #endif // OME_BIOFORMATS_VARIANTPIXELBUFFER_H
1078 
1079 /*
1080  * Local Variables:
1081  * mode:C++
1082  * End:
1083  */
Find a PixelBuffer data array of a specific pixel type.
Definition: VariantPixelBuffer.h:699
uint8
Definition: PixelType.h:83
EndianType
Endianness.
Definition: Types.h:68
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:125
Properties of COMPLEX pixels.
Definition: PixelProperties.h:335
Properties of DOUBLE pixels.
Definition: PixelProperties.h:277
Convert T into a buffer.
Definition: VariantPixelBuffer.h:112
bool operator==(const VariantPixelBuffer &rhs) const
Compare a pixel buffer for equality.
Definition: VariantPixelBuffer.cpp:417
boost::mpl::joint_view< integer_pixel_types, float_pixel_types >::type basic_pixel_types_view
Aggregate view of all numeric types.
Definition: VariantPixelBuffer.h:108
bool managed() const
Check if the buffer is internally managed.
Definition: VariantPixelBuffer.cpp:333
const PixelBuffer< T > & operator()(const ome::compat::shared_ptr< PixelBuffer< T > > &v) const
PixelBuffer of correct type.
Definition: VariantPixelBuffer.h:742
std::basic_istream< charT, traits > & stream
The input stream.
Definition: VariantPixelBuffer.h:814
Definition: length.h:576
const boost::multi_array_types::index * strides() const
Get the strides of the multi-dimensional array.
Definition: VariantPixelBuffer.cpp:361
void operator()(ome::compat::shared_ptr< PixelBuffer< typename std::iterator_traits< InputIterator >::value_type > > &v) const
PixelBuffer of correct type.
Definition: VariantPixelBuffer.h:789
Map a given PixelPropertiesType enum to the corresponding language types.
Definition: PixelProperties.h:61
size_type num_dimensions() const
Get the number of dimensions in the multi-dimensional array.
Definition: VariantPixelBuffer.cpp:347
Properties of INT32 pixels.
Definition: PixelProperties.h:162
Native endian.
Definition: Types.h:72
boost::mpl::vector< PixelProperties< ::ome::xml::model::enums::PixelType::FLOAT >, PixelProperties< ::ome::xml::model::enums::PixelType::DOUBLE >, PixelProperties< ::ome::xml::model::enums::PixelType::COMPLEX >, PixelProperties< ::ome::xml::model::enums::PixelType::DOUBLECOMPLEX > > float_pixel_types
Floating-point pixel types.
Definition: VariantPixelBuffer.h:104
const boost::multi_array_types::index * index_bases() const
Get the index bases of the multi-dimensional array.
Definition: VariantPixelBuffer.cpp:368
::ome::xml::model::enums::PixelType pixelType() const
Get the type of pixels stored in the buffer.
Definition: VariantPixelBuffer.cpp:382
bool operator!=(const VariantPixelBuffer &rhs) const
Compare a pixel buffer for inequality.
Definition: VariantPixelBuffer.cpp:423
VariantPixelBufferWriteVisitor(std::basic_ostream< charT, traits > &stream)
Constructor.
Definition: VariantPixelBuffer.h:852
Properties of DOUBLECOMPLEX pixels.
Definition: PixelProperties.h:358
Find a PixelBuffer data array of a specific pixel type.
Definition: VariantPixelBuffer.h:732
PixelBufferBase::storage_order_type storage_order_type
Storage ordering type for controlling pixel memory layout.
Definition: VariantPixelBuffer.h:141
ome::compat::shared_ptr< PixelBuffer< typename T::std_type > > type
Buffer type.
Definition: VariantPixelBuffer.h:115
virtual ~VariantPixelBuffer()
Destructor.
Definition: VariantPixelBuffer.h:222
static storage_order_type default_storage_order()
Generate default storage ordering.
Definition: PixelBuffer.cpp:133
const T * origin() const
Get the origin of the array.
Definition: VariantPixelBuffer.h:999
STL namespace.
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
raw_type * data()
Get raw buffered data.
Definition: VariantPixelBuffer.cpp:396
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:172
void write(std::basic_ostream< charT, traits > &stream) const
Write raw pixel data to a stream in physical storage order.
Definition: VariantPixelBuffer.h:1031
Logical sub-channel (typically used for RGB channel sub-components) (S).
Definition: PixelBuffer.h:84
dimension_size_type subC
Subchannel to copy.
Definition: VariantPixelBuffer.h:877
Buffer for a specific pixel type.
Definition: PixelBuffer.h:234
void read(std::basic_istream< charT, traits > &stream)
Read raw pixel data from a stream in physical storage order.
Definition: VariantPixelBuffer.h:1023
VariantPixelBufferReadVisitor(std::basic_istream< charT, traits > &stream)
Constructor.
Definition: VariantPixelBuffer.h:821
VariantPixelBuffer(ome::compat::shared_ptr< PixelBuffer< T > > &buffer)
Construct from existing pixel buffer.
Definition: VariantPixelBuffer.h:215
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:190
variant_buffer_type & vbuffer()
Get a reference to the variant buffer.
Definition: VariantPixelBuffer.h:231
void operator()(const T &v)
Copy subchannel.
Definition: VariantPixelBuffer.h:898
Variant type limit workaround.
Properties of UINT8 pixels.
Definition: PixelProperties.h:185
Open Microscopy Environment C++ implementation.
Definition: CoreMetadata.cpp:40
variant_buffer_type buffer
Pixel storage.
Definition: VariantPixelBuffer.h:691
VariantPixelBuffer & dest
Destination pixel buffer.
Definition: VariantPixelBuffer.h:928
VariantPixelBuffer()
Default constructor.
Definition: VariantPixelBuffer.h:155
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:98
void operator()(const T &v)
Merge subchannel.
Definition: VariantPixelBuffer.h:951
InputIterator begin
Input start.
Definition: VariantPixelBuffer.h:768
PixelBufferBase::range_type range_type
Extent range type.
Definition: VariantPixelBuffer.h:144
void operator()(const T &v) const
Write data from specific PixelBuffer type.
Definition: VariantPixelBuffer.h:863
Assign a PixelBuffer from an input iterator.
Definition: VariantPixelBuffer.h:765
VariantPixelBuffer & dest
Destination pixel buffer.
Definition: VariantPixelBuffer.h:875
Properties of UINT32 pixels.
Definition: PixelProperties.h:231
bool valid() const
Check the buffer validity.
Definition: VariantPixelBuffer.cpp:326
boost::multi_array_types::size_type size_type
Size type.
Definition: VariantPixelBuffer.h:135
VariantPixelBufferAssignVisitor(InputIterator begin, InputIterator end)
Constructor.
Definition: VariantPixelBuffer.h:778
size_type num_elements() const
Get the number of pixel elements in the multi-dimensional array.
Definition: VariantPixelBuffer.cpp:340
VariantPixelBuffer & operator=(const VariantPixelBuffer &rhs)
Assign a pixel buffer.
Definition: VariantPixelBuffer.cpp:410
boost::mpl::vector empty_types
Empty vector placeholder.
Definition: VariantPixelBuffer.h:122
Write data from a PixelBuffer.
Definition: VariantPixelBuffer.h:842
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:261
XYZTC.
Definition: DimensionOrder.h:79
ome::compat::array< boost::multi_array_types::index, PixelBufferBase::dimensions > indices_type
Type used to index all dimensions in public interfaces.
Definition: VariantPixelBuffer.h:138
Merge a single subchannel into a PixelBuffer.
Definition: VariantPixelBuffer.h:925
PixelType enumeration.
Definition: PixelType.h:70
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:309
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:448
static const uint16_t dimensions
Total number of supported dimensions.
Definition: PixelBuffer.h:106
const variant_buffer_type & vbuffer() const
Get a reference to the variant buffer.
Definition: VariantPixelBuffer.h:242
Read data into a PixelBuffer.
Definition: VariantPixelBuffer.h:811
EndianType endianType() const
Get the endianness of the pixel type stored in the buffer.
Definition: VariantPixelBuffer.cpp:389
MergeSubchannelVisitor(VariantPixelBuffer &dest, dimension_size_type subC)
Constructor.
Definition: VariantPixelBuffer.h:938
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:367
PixelBuffer< T >::array_ref_type & array()
Get the pixel data.
Buffer for all pixel types.
Definition: VariantPixelBuffer.h:72
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:119
boost::multi_array_ref< value_type, dimensions > array_ref_type
Type for multi-dimensional pixel array view referencing external data.
Definition: PixelBuffer.h:245
Properties of UINT16 pixels.
Definition: PixelProperties.h:208
const size_type * shape() const
Get the shape of the multi-dimensional array.
Definition: VariantPixelBuffer.cpp:354
boost::make_variant_over< pixel_buffer_types >::type variant_buffer_type
Buffer type, allowing assignment of all buffer types.
Definition: VariantPixelBuffer.h:129
const storage_order_type & storage_order() const
Get the array storage order.
Definition: VariantPixelBuffer.cpp:375
dimension_size_type subC
Subchannel to copy.
Definition: VariantPixelBuffer.h:930
Properties of INT16 pixels.
Definition: PixelProperties.h:139
Properties of BIT pixels.
Definition: PixelProperties.h:300
std::size_t dimension_size_type
Size type for image dimensions.
Definition: Types.h:59
boost::general_storage_order< dimensions > storage_order_type
Storage ordering type for controlling pixel memory layout.
Definition: PixelBuffer.h:119
boost::detail::multi_array::extent_gen< dimensions > range_type
Extent range type.
Definition: PixelBuffer.h:122
PixelProperties< ::ome::xml::model::enums::PixelType::UINT8 >::std_type raw_type
Raw pixel type used in public interfaces.
Definition: VariantPixelBuffer.h:132
std::basic_ostream< charT, traits > & stream
The output stream.
Definition: VariantPixelBuffer.h:845
Copy a single subchannel from a PixelBuffer.
Definition: VariantPixelBuffer.h:872
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:430
void assign(InputIterator begin, InputIterator end)
Assign pixel values.
Definition: VariantPixelBuffer.h:1014
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:281
void operator()(T &v) const
Read data into specific PixelBuffer type.
Definition: VariantPixelBuffer.h:832
InputIterator end
Input end.
Definition: VariantPixelBuffer.h:770
CopySubchannelVisitor(VariantPixelBuffer &dest, dimension_size_type subC)
Constructor.
Definition: VariantPixelBuffer.h:885
PixelBuffer< T > & operator()(ome::compat::shared_ptr< PixelBuffer< T > > &v) const
PixelBuffer of correct type.
Definition: VariantPixelBuffer.h:709