bioformats  5.1.5
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 #include <ome/bioformats/PixelProperties.h>
43 
44 #include <ome/common/variant.h>
45 
46 #include <ome/compat/memory.h>
47 
48 namespace ome
49 {
50  namespace bioformats
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 ome::compat::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 ome::compat::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(ome::compat::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(ome::compat::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(ome::compat::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 
310  template<class ExtentList>
311  static variant_buffer_type
312  createBuffer(const ExtentList& extents,
314  const storage_order_type& storage = PixelBufferBase::default_storage_order())
315  {
316  variant_buffer_type buf;
317 
318  switch(pixeltype)
319  {
320  case ::ome::xml::model::enums::PixelType::INT8:
321  buf = makeBuffer<PixelProperties< ::ome::xml::model::enums::PixelType::INT8>::std_type>(extents, storage, pixeltype);
322  break;
323  case ::ome::xml::model::enums::PixelType::INT16:
324  buf = makeBuffer<PixelProperties< ::ome::xml::model::enums::PixelType::INT16>::std_type>(extents, storage, pixeltype);
325  break;
326  case ::ome::xml::model::enums::PixelType::INT32:
327  buf = makeBuffer<PixelProperties< ::ome::xml::model::enums::PixelType::INT32>::std_type>(extents, storage, pixeltype);
328  break;
329  case ::ome::xml::model::enums::PixelType::UINT8:
330  buf = makeBuffer<PixelProperties< ::ome::xml::model::enums::PixelType::UINT8>::std_type>(extents, storage, pixeltype);
331  break;
332  case ::ome::xml::model::enums::PixelType::UINT16:
333  buf = makeBuffer<PixelProperties< ::ome::xml::model::enums::PixelType::UINT16>::std_type>(extents, storage, pixeltype);
334  break;
335  case :: ome::xml::model::enums::PixelType::UINT32:
336  buf = makeBuffer<PixelProperties< ::ome::xml::model::enums::PixelType::UINT32>::std_type>(extents, storage, pixeltype);
337  break;
338  case ::ome::xml::model::enums::PixelType::FLOAT:
339  buf = makeBuffer<PixelProperties< ::ome::xml::model::enums::PixelType::FLOAT>::std_type>(extents, storage, pixeltype);
340  break;
341  case ::ome::xml::model::enums::PixelType::DOUBLE:
342  buf = makeBuffer<PixelProperties< ::ome::xml::model::enums::PixelType::DOUBLE>::std_type>(extents, storage, pixeltype);
343  break;
344  case ::ome::xml::model::enums::PixelType::BIT:
345  buf = makeBuffer<PixelProperties< ::ome::xml::model::enums::PixelType::BIT>::std_type>(extents, storage, pixeltype);
346  break;
347  case ::ome::xml::model::enums::PixelType::COMPLEX:
348  buf = makeBuffer<PixelProperties< ::ome::xml::model::enums::PixelType::COMPLEX>::std_type>(extents, storage, pixeltype);
349  break;
350  case ::ome::xml::model::enums::PixelType::DOUBLECOMPLEX:
351  buf = makeBuffer<PixelProperties< ::ome::xml::model::enums::PixelType::DOUBLECOMPLEX>::std_type>(extents, storage, pixeltype);
352  break;
353  }
354 
355  return buf;
356  }
357 
369  static variant_buffer_type
370  createBuffer(const range_type& range,
372  const storage_order_type& storage = PixelBufferBase::default_storage_order())
373  {
374  variant_buffer_type buf;
375 
376  switch(pixeltype)
377  {
378  case ::ome::xml::model::enums::PixelType::INT8:
379  buf = makeBuffer<PixelProperties< ::ome::xml::model::enums::PixelType::INT8>::std_type>(range, storage, pixeltype);
380  break;
381  case ::ome::xml::model::enums::PixelType::INT16:
382  buf = makeBuffer<PixelProperties< ::ome::xml::model::enums::PixelType::INT16>::std_type>(range, storage, pixeltype);
383  break;
384  case ::ome::xml::model::enums::PixelType::INT32:
385  buf = makeBuffer<PixelProperties< ::ome::xml::model::enums::PixelType::INT32>::std_type>(range, storage, pixeltype);
386  break;
387  case ::ome::xml::model::enums::PixelType::UINT8:
388  buf = makeBuffer<PixelProperties< ::ome::xml::model::enums::PixelType::UINT8>::std_type>(range, storage, pixeltype);
389  break;
390  case ::ome::xml::model::enums::PixelType::UINT16:
391  buf = makeBuffer<PixelProperties< ::ome::xml::model::enums::PixelType::UINT16>::std_type>(range, storage, pixeltype);
392  break;
393  case :: ome::xml::model::enums::PixelType::UINT32:
394  buf = makeBuffer<PixelProperties< ::ome::xml::model::enums::PixelType::UINT32>::std_type>(range, storage, pixeltype);
395  break;
396  case ::ome::xml::model::enums::PixelType::FLOAT:
397  buf = makeBuffer<PixelProperties< ::ome::xml::model::enums::PixelType::FLOAT>::std_type>(range, storage, pixeltype);
398  break;
399  case ::ome::xml::model::enums::PixelType::DOUBLE:
400  buf = makeBuffer<PixelProperties< ::ome::xml::model::enums::PixelType::DOUBLE>::std_type>(range, storage, pixeltype);
401  break;
402  case ::ome::xml::model::enums::PixelType::BIT:
403  buf = makeBuffer<PixelProperties< ::ome::xml::model::enums::PixelType::BIT>::std_type>(range, storage, pixeltype);
404  break;
405  case ::ome::xml::model::enums::PixelType::COMPLEX:
406  buf = makeBuffer<PixelProperties< ::ome::xml::model::enums::PixelType::COMPLEX>::std_type>(range, storage, pixeltype);
407  break;
408  case ::ome::xml::model::enums::PixelType::DOUBLECOMPLEX:
409  buf = makeBuffer<PixelProperties< ::ome::xml::model::enums::PixelType::DOUBLECOMPLEX>::std_type>(range, storage, pixeltype);
410  break;
411  }
412 
413  return buf;
414  }
415 
416 #ifdef __GNUC__
417 # pragma GCC diagnostic pop
418 #endif
419 
420  public:
431  template<class ExtentList>
432  void
433  setBuffer(const ExtentList& extents,
435  const storage_order_type& storage = PixelBufferBase::default_storage_order())
436  {
437  buffer = createBuffer(extents, pixeltype, storage);
438  }
439 
450  void
451  setBuffer(const range_type& range,
453  const storage_order_type& storage = PixelBufferBase::default_storage_order())
454  {
455  buffer = createBuffer(range, pixeltype, storage);
456  }
457 
465  bool
466  managed() const;
467 
471  size_type
472  num_elements() const;
473 
477  size_type
478  num_dimensions() const;
479 
487  const size_type *
488  shape() const;
489 
497  const boost::multi_array_types::index *
498  strides() const;
499 
508  const boost::multi_array_types::index *
509  index_bases() const;
510 
521  template <typename T>
522  const T *
523  origin() const;
524 
530  const storage_order_type&
531  storage_order() const;
532 
537  pixelType() const;
538 
542  EndianType
543  endianType() const;
544 
553  template<typename T>
555  array();
556 
565  template<typename T>
566  const typename PixelBuffer<T>::array_ref_type&
567  array() const;
568 
574  raw_type *
575  data();
576 
582  const raw_type *
583  data() const;
584 
592  template<typename T>
593  T *
594  data();
595 
603  template<typename T>
604  const T *
605  data() const;
606 
617  bool
618  valid() const;
619 
631  operator = (const VariantPixelBuffer& rhs);
632 
639  bool
640  operator == (const VariantPixelBuffer& rhs) const;
641 
648  bool
649  operator != (const VariantPixelBuffer& rhs) const;
650 
659  template <typename InputIterator>
660  void
661  assign(InputIterator begin,
662  InputIterator end);
663 
674  template<class charT, class traits>
675  inline void
676  read(std::basic_istream<charT,traits>& stream);
677 
688  template<class charT, class traits>
689  inline void
690  write(std::basic_ostream<charT,traits>& stream) const;
691 
692  protected:
694  variant_buffer_type buffer;
695  };
696 
697  namespace detail
698  {
699 
701  template<typename T>
702  struct VariantPixelBufferVisitor : public boost::static_visitor<PixelBuffer<T>&>
703  {
712  operator() (ome::compat::shared_ptr<PixelBuffer<T> >& v) const
713  {
714  if (!v)
715  throw std::runtime_error("Null pixel type");
716  return *v;
717  }
718 
725  template <typename U>
727  operator() (U& /* v */) const
728  {
729  throw std::runtime_error("Unsupported pixel type conversion for buffer");
730  }
731  };
732 
734  template<typename T>
735  struct VariantPixelBufferConstVisitor : public boost::static_visitor<const PixelBuffer<T>&>
736  {
744  const PixelBuffer<T>&
745  operator() (const ome::compat::shared_ptr<PixelBuffer<T> >& v) const
746  {
747  if (!v)
748  throw std::runtime_error("Null pixel type");
749  return *v;
750  }
751 
758  template <typename U>
759  const PixelBuffer<T>&
760  operator() (U& /* v */) const
761  {
762  throw std::runtime_error("Unsupported pixel type conversion for buffer");
763  }
764  };
765 
767  template <typename InputIterator>
768  struct VariantPixelBufferAssignVisitor : public boost::static_visitor<>
769  {
771  InputIterator begin;
773  InputIterator end;
774 
781  VariantPixelBufferAssignVisitor(InputIterator begin, InputIterator end):
782  begin(begin), end(end)
783  {}
784 
791  void
792  operator() (ome::compat::shared_ptr<PixelBuffer<typename std::iterator_traits<InputIterator>::value_type> >& v) const
793  {
794  if (!v)
795  throw std::runtime_error("Null pixel type");
796  v->array().assign(begin, end);
797  }
798 
804  template <typename T>
805  void
806  operator() (T& /* v */) const
807  {
808  throw std::runtime_error("Unsupported pixel type conversion for assignment");
809  }
810  };
811 
813  template<class charT, class traits>
814  struct VariantPixelBufferReadVisitor : public boost::static_visitor<>
815  {
817  std::basic_istream<charT,traits>& stream;
818 
824  VariantPixelBufferReadVisitor(std::basic_istream<charT,traits>& stream):
825  stream(stream)
826  {}
827 
833  template <typename T>
834  void
835  operator() (T& v) const
836  {
837  if (!v)
838  throw std::runtime_error("Null pixel type");
839  v->read(stream);
840  }
841  };
842 
844  template<class charT, class traits>
845  struct VariantPixelBufferWriteVisitor : public boost::static_visitor<>
846  {
848  std::basic_ostream<charT,traits>& stream;
849 
855  VariantPixelBufferWriteVisitor(std::basic_ostream<charT,traits>& stream):
856  stream(stream)
857  {}
858 
864  template <typename T>
865  void
866  operator() (const T& v) const
867  {
868  if (!v)
869  throw std::runtime_error("Null pixel type");
870  v->write(stream);
871  }
872  };
873 
875  struct CopySubchannelVisitor : public boost::static_visitor<>
876  {
881 
889  dimension_size_type subC):
890  dest(dest),
891  subC(subC)
892  {}
893 
899  template<typename T>
900  void
901  operator()(const T& v)
902  {
903  // Shape is the same as the source buffer, but with one subchannel.
904  ome::compat::array<VariantPixelBuffer::size_type, 9> dest_shape;
905  const VariantPixelBuffer::size_type *shape_ptr(v->shape());
906  std::copy(shape_ptr, shape_ptr + PixelBufferBase::dimensions,
907  dest_shape.begin());
908  dest_shape[DIM_SUBCHANNEL] = 1;
909 
910  // Default to planar ordering; since openByes/saveBytes
911  // don't use ZTC the DimensionOrder doesn't matter here so
912  // long as it matches what the TIFF reader/writer uses.
914 
917  dest.setBuffer(dest_shape, v->pixelType(), order);
918 
919  T& destbuf = boost::get<T>(dest.vbuffer());
920 
921  typename boost::multi_array_types::index_gen indices;
922  typedef boost::multi_array_types::index_range range;
923  destbuf->array() = v->array()[boost::indices[range()][range()][range()][range()][range()][range(subC,subC+1)][range()][range()][range()]];
924  }
925  };
926 
928  struct MergeSubchannelVisitor : public boost::static_visitor<>
929  {
934 
942  dimension_size_type subC):
943  dest(dest),
944  subC(subC)
945  {}
946 
952  template<typename T>
953  void
954  operator()(const T& v)
955  {
956  T& destbuf = boost::get<T>(dest.vbuffer());
957 
958  typename boost::multi_array_types::index_gen indices;
959  typedef boost::multi_array_types::index_range range;
960  destbuf->array()[boost::indices[range()][range()][range()][range()][range()][range(subC,subC+1)][range()][range()][range()]] = v->array();
961  }
962  };
963 
964  }
965 
967  template<typename T>
968  inline typename PixelBuffer<T>::array_ref_type&
970  {
972  return boost::apply_visitor(v, buffer).array();
973  }
974 
976  template<typename T>
977  inline const typename PixelBuffer<T>::array_ref_type&
979  {
981  return boost::apply_visitor(v, buffer).array();
982  }
983 
984  template<typename T>
985  inline T *
987  {
989  return boost::apply_visitor(v, buffer).data();
990  }
991 
992  template<typename T>
993  inline const T *
995  {
997  return boost::apply_visitor(v, buffer).data();
998  }
999 
1000  template<typename T>
1001  inline const T *
1003  {
1005  return boost::apply_visitor(v, buffer).origin();
1006  }
1007 
1015  template <typename InputIterator>
1016  inline void
1017  VariantPixelBuffer::assign(InputIterator begin,
1018  InputIterator end)
1019  {
1021  boost::apply_visitor(v, buffer);
1022  }
1023 
1024  template<class charT, class traits>
1025  inline void
1026  VariantPixelBuffer::read(std::basic_istream<charT,traits>& stream)
1027  {
1029  boost::apply_visitor(v, buffer);
1030  }
1031 
1032  template<class charT, class traits>
1033  inline void
1034  VariantPixelBuffer::write(std::basic_ostream<charT,traits>& stream) const
1035  {
1037  boost::apply_visitor(v, buffer);
1038  }
1039 
1040  }
1041 }
1042 
1043 namespace std
1044 {
1045 
1053  template<class charT, class traits>
1054  inline std::basic_istream<charT,traits>&
1055  operator>> (std::basic_istream<charT,traits>& is,
1057  {
1058  buf.read(is);
1059  return is;
1060  }
1061 
1069  template<class charT, class traits>
1070  inline std::basic_ostream<charT,traits>&
1071  operator<< (std::basic_ostream<charT,traits>& os,
1072  const ::ome::bioformats::VariantPixelBuffer& buf)
1073  {
1074  buf.write(os);
1075  return os;
1076  }
1077 
1078 }
1079 
1080 #endif // OME_BIOFORMATS_VARIANTPIXELBUFFER_H
1081 
1082 /*
1083  * Local Variables:
1084  * mode:C++
1085  * End:
1086  */
Find a PixelBuffer data array of a specific pixel type.
Definition: VariantPixelBuffer.h:702
uint8
Definition: PixelType.h:82
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:128
Properties of COMPLEX pixels.
Definition: PixelProperties.h:335
Properties of DOUBLE pixels.
Definition: PixelProperties.h:277
Convert T into a buffer.
Definition: VariantPixelBuffer.h:115
bool operator==(const VariantPixelBuffer &rhs) const
Compare a pixel buffer for equality.
Definition: VariantPixelBuffer.cpp:417
Memory type substitution.
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
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:745
std::basic_istream< charT, traits > & stream
The input stream.
Definition: VariantPixelBuffer.h:817
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:792
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:107
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:855
Properties of DOUBLECOMPLEX pixels.
Definition: PixelProperties.h:358
Find a PixelBuffer data array of a specific pixel type.
Definition: VariantPixelBuffer.h:735
PixelBufferBase::storage_order_type storage_order_type
Storage ordering type for controlling pixel memory layout.
Definition: VariantPixelBuffer.h:144
ome::compat::shared_ptr< PixelBuffer< typename T::std_type > > type
Buffer type.
Definition: VariantPixelBuffer.h:118
virtual ~VariantPixelBuffer()
Destructor.
Definition: VariantPixelBuffer.h:225
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:1002
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:175
void write(std::basic_ostream< charT, traits > &stream) const
Write raw pixel data to a stream in physical storage order.
Definition: VariantPixelBuffer.h:1034
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:880
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:1026
VariantPixelBufferReadVisitor(std::basic_istream< charT, traits > &stream)
Constructor.
Definition: VariantPixelBuffer.h:824
VariantPixelBuffer(ome::compat::shared_ptr< PixelBuffer< T > > &buffer)
Construct from existing pixel buffer.
Definition: VariantPixelBuffer.h:218
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
variant_buffer_type & vbuffer()
Get a reference to the variant buffer.
Definition: VariantPixelBuffer.h:234
void operator()(const T &v)
Copy subchannel.
Definition: VariantPixelBuffer.h:901
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:694
VariantPixelBuffer & dest
Destination pixel buffer.
Definition: VariantPixelBuffer.h:931
VariantPixelBuffer()
Default constructor.
Definition: VariantPixelBuffer.h:158
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
void operator()(const T &v)
Merge subchannel.
Definition: VariantPixelBuffer.h:954
InputIterator begin
Input start.
Definition: VariantPixelBuffer.h:771
PixelBufferBase::range_type range_type
Extent range type.
Definition: VariantPixelBuffer.h:147
void operator()(const T &v) const
Write data from specific PixelBuffer type.
Definition: VariantPixelBuffer.h:866
Assign a PixelBuffer from an input iterator.
Definition: VariantPixelBuffer.h:768
VariantPixelBuffer & dest
Destination pixel buffer.
Definition: VariantPixelBuffer.h:878
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:138
VariantPixelBufferAssignVisitor(InputIterator begin, InputIterator end)
Constructor.
Definition: VariantPixelBuffer.h:781
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:125
Write data from a PixelBuffer.
Definition: VariantPixelBuffer.h:845
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
XYZTC.
Definition: DimensionOrder.h:78
ome::compat::array< boost::multi_array_types::index, PixelBufferBase::dimensions > indices_type
Type used to index all dimensions in public interfaces.
Definition: VariantPixelBuffer.h:141
Merge a single subchannel into a PixelBuffer.
Definition: VariantPixelBuffer.h:928
PixelType enumeration.
Definition: PixelType.h:69
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:312
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:451
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:245
Read data into a PixelBuffer.
Definition: VariantPixelBuffer.h:814
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:941
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:370
PixelBuffer< T >::array_ref_type & array()
Get the pixel data.
Buffer for all pixel types.
Definition: VariantPixelBuffer.h:75
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
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:132
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:933
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:135
std::basic_ostream< charT, traits > & stream
The output stream.
Definition: VariantPixelBuffer.h:848
Copy a single subchannel from a PixelBuffer.
Definition: VariantPixelBuffer.h:875
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:433
void assign(InputIterator begin, InputIterator end)
Assign pixel values.
Definition: VariantPixelBuffer.h:1017
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
void operator()(T &v) const
Read data into specific PixelBuffer type.
Definition: VariantPixelBuffer.h:835
InputIterator end
Input end.
Definition: VariantPixelBuffer.h:773
CopySubchannelVisitor(VariantPixelBuffer &dest, dimension_size_type subC)
Constructor.
Definition: VariantPixelBuffer.h:888
PixelBuffer< T > & operator()(ome::compat::shared_ptr< PixelBuffer< T > > &v) const
PixelBuffer of correct type.
Definition: VariantPixelBuffer.h:712