ome-files 0.1.0

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List

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 <ome/files/PixelBuffer.h>
42 #include <ome/files/PixelProperties.h>
43
44 #include <ome/common/variant.h>
45
46 #include <ome/compat/memory.h>
47
48 namespace ome
49 {
50 namespace files
51 {
52
75 class VariantPixelBuffer
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>,
96 PixelProperties< ::ome::xml::model::enums::PixelType::INT16>,
97 PixelProperties< ::ome::xml::model::enums::PixelType::INT32>,
98 PixelProperties< ::ome::xml::model::enums::PixelType::UINT8>,
99 PixelProperties< ::ome::xml::model::enums::PixelType::UINT16>,
100 PixelProperties< ::ome::xml::model::enums::PixelType::UINT32>,
101 PixelProperties< ::ome::xml::model::enums::PixelType::BIT> > integer_pixel_types;
102
104 typedef boost::mpl::vector< PixelProperties< ::ome::xml::model::enums::PixelType::FLOAT>,
105 PixelProperties< ::ome::xml::model::enums::PixelType::DOUBLE>,
106 PixelProperties< ::ome::xml::model::enums::PixelType::COMPLEX>,
107 PixelProperties< ::ome::xml::model::enums::PixelType::DOUBLECOMPLEX> > float_pixel_types;
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
135 typedef PixelProperties< ::ome::xml::model::enums::PixelType::UINT8>::std_type raw_type;
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
144 typedef PixelBufferBase::storage_order_type storage_order_type;
145
147 typedef PixelBufferBase::range_type range_type;
148
149 public:
157 explicit
158 VariantPixelBuffer():
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,
176 ::ome::xml::model::enums::PixelType pixeltype = ::ome::xml::model::enums::PixelType::UINT8,
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,
194 ::ome::xml::model::enums::PixelType pixeltype = ::ome::xml::model::enums::PixelType::UINT8,
195 const storage_order_type& storage = PixelBufferBase::default_storage_order()):
196 buffer(createBuffer(range, pixeltype, storage))
197 {
198 }
199
208 explicit
209 VariantPixelBuffer(const VariantPixelBuffer& buffer);
210
216 template<typename T>
217 explicit
218 VariantPixelBuffer(ome::compat::shared_ptr<PixelBuffer<T> >& buffer):
219 buffer(buffer)
220 {
221 }
222
224 virtual
225 ~VariantPixelBuffer()
226 {}
227
233 variant_buffer_type&
234 vbuffer()
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,
266 ::ome::xml::model::enums::PixelType pixeltype)
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,
286 ::ome::xml::model::enums::PixelType pixeltype)
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
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,
318 ::ome::xml::model::enums::PixelType pixeltype = ::ome::xml::model::enums::PixelType::UINT8,
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,
351 ::ome::xml::model::enums::PixelType pixeltype = ::ome::xml::model::enums::PixelType::UINT8,
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,
384 ::ome::xml::model::enums::PixelType pixeltype = ::ome::xml::model::enums::PixelType::UINT8,
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,
402 ::ome::xml::model::enums::PixelType pixeltype = ::ome::xml::model::enums::PixelType::UINT8,
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
421 size_type
422 num_elements() const;
423
427 size_type
428 num_dimensions() const;
429
437 const size_type *
438 shape() const;
439
447 const boost::multi_array_types::index *
448 strides() const;
449
458 const boost::multi_array_types::index *
459 index_bases() const;
460
471 template <typename T>
472 const T *
473 origin() const;
474
480 const storage_order_type&
481 storage_order() const;
482
486 ::ome::xml::model::enums::PixelType
487 pixelType() const;
488
492 EndianType
493 endianType() const;
494
503 template<typename T>
504 typename PixelBuffer<T>::array_ref_type&
505 array();
506
515 template<typename T>
516 const typename PixelBuffer<T>::array_ref_type&
517 array() const;
518
524 raw_type *
525 data();
526
532 const raw_type *
533 data() const;
534
542 template<typename T>
543 T *
544 data();
545
553 template<typename T>
554 const T *
555 data() const;
556
567 bool
568 valid() const;
569
580 VariantPixelBuffer&
581 operator = (const VariantPixelBuffer& rhs);
582
589 bool
590 operator == (const VariantPixelBuffer& rhs) const;
591
598 bool
599 operator != (const VariantPixelBuffer& rhs) const;
600
609 template <typename InputIterator>
610 void
611 assign(InputIterator begin,
612 InputIterator end);
613
624 template<class charT, class traits>
625 inline void
626 read(std::basic_istream<charT,traits>& stream);
627
638 template<class charT, class traits>
639 inline void
640 write(std::basic_ostream<charT,traits>& stream) const;
641
642 protected:
644 variant_buffer_type buffer;
645 };
646
647 namespace detail
648 {
649
651 template<typename T>
652 struct VariantPixelBufferVisitor : public boost::static_visitor<PixelBuffer<T>&>
653 {
661 PixelBuffer<T>&
662 operator() (ome::compat::shared_ptr<PixelBuffer<T> >& v) const
663 {
664 if (!v)
665 throw std::runtime_error("Null pixel type");
666 return *v;
667 }
668
675 template <typename U>
676 PixelBuffer<T>&
677 operator() (U& /* v */) const
678 {
679 throw std::runtime_error("Unsupported pixel type conversion for buffer");
680 }
681 };
682
684 template<typename T>
685 struct VariantPixelBufferConstVisitor : public boost::static_visitor<const PixelBuffer<T>&>
686 {
694 const PixelBuffer<T>&
695 operator() (const ome::compat::shared_ptr<PixelBuffer<T> >& v) const
696 {
697 if (!v)
698 throw std::runtime_error("Null pixel type");
699 return *v;
700 }
701
708 template <typename U>
709 const PixelBuffer<T>&
710 operator() (U& /* v */) const
711 {
712 throw std::runtime_error("Unsupported pixel type conversion for buffer");
713 }
714 };
715
717 template <typename InputIterator>
718 struct VariantPixelBufferAssignVisitor : public boost::static_visitor<>
719 {
721 InputIterator begin;
723 InputIterator end;
724
731 VariantPixelBufferAssignVisitor(InputIterator begin, InputIterator end):
732 begin(begin), end(end)
733 {}
734
741 void
742 operator() (ome::compat::shared_ptr<PixelBuffer<typename std::iterator_traits<InputIterator>::value_type> >& v) const
743 {
744 if (!v)
745 throw std::runtime_error("Null pixel type");
746 v->array().assign(begin, end);
747 }
748
754 template <typename T>
755 void
756 operator() (T& /* v */) const
757 {
758 throw std::runtime_error("Unsupported pixel type conversion for assignment");
759 }
760 };
761
763 template<class charT, class traits>
764 struct VariantPixelBufferReadVisitor : public boost::static_visitor<>
765 {
767 std::basic_istream<charT,traits>& stream;
768
774 VariantPixelBufferReadVisitor(std::basic_istream<charT,traits>& stream):
775 stream(stream)
776 {}
777
783 template <typename T>
784 void
785 operator() (T& v) const
786 {
787 if (!v)
788 throw std::runtime_error("Null pixel type");
789 v->read(stream);
790 }
791 };
792
794 template<class charT, class traits>
795 struct VariantPixelBufferWriteVisitor : public boost::static_visitor<>
796 {
798 std::basic_ostream<charT,traits>& stream;
799
805 VariantPixelBufferWriteVisitor(std::basic_ostream<charT,traits>& stream):
806 stream(stream)
807 {}
808
814 template <typename T>
815 void
816 operator() (const T& v) const
817 {
818 if (!v)
819 throw std::runtime_error("Null pixel type");
820 v->write(stream);
821 }
822 };
823
825 struct CopySubchannelVisitor : public boost::static_visitor<>
826 {
828 VariantPixelBuffer& dest;
830 dimension_size_type subC;
831
838 CopySubchannelVisitor(VariantPixelBuffer& dest,
839 dimension_size_type subC):
840 dest(dest),
841 subC(subC)
842 {}
843
849 template<typename T>
850 void
851 operator()(const T& v)
852 {
853 // Shape is the same as the source buffer, but with one subchannel.
854 ome::compat::array<VariantPixelBuffer::size_type, 9> dest_shape;
855 const VariantPixelBuffer::size_type *shape_ptr(v->shape());
856 std::copy(shape_ptr, shape_ptr + PixelBufferBase::dimensions,
857 dest_shape.begin());
858 dest_shape[DIM_SUBCHANNEL] = 1;
859
860 // Default to planar ordering; since openByes/saveBytes
861 // don't use ZTC the DimensionOrder doesn't matter here so
862 // long as it matches what the TIFF reader/writer uses.
863 PixelBufferBase::storage_order_type order(PixelBufferBase::make_storage_order(ome::xml::model::enums::DimensionOrder::XYZTC, false));
864
867 dest.setBuffer(dest_shape, v->pixelType(), order);
868
869 T& destbuf = boost::get<T>(dest.vbuffer());
870
871 typename boost::multi_array_types::index_gen indices;
872 typedef boost::multi_array_types::index_range range;
873 destbuf->array() = v->array()[boost::indices[range()][range()][range()][range()][range()][range(subC,subC+1)][range()][range()][range()]];
874 }
875 };
876
878 struct MergeSubchannelVisitor : public boost::static_visitor<>
879 {
881 VariantPixelBuffer& dest;
883 dimension_size_type subC;
884
891 MergeSubchannelVisitor(VariantPixelBuffer& dest,
892 dimension_size_type subC):
893 dest(dest),
894 subC(subC)
895 {}
896
902 template<typename T>
903 void
904 operator()(const T& v)
905 {
906 T& destbuf = boost::get<T>(dest.vbuffer());
907
908 typename boost::multi_array_types::index_gen indices;
909 typedef boost::multi_array_types::index_range range;
910 destbuf->array()[boost::indices[range()][range()][range()][range()][range()][range(subC,subC+1)][range()][range()][range()]] = v->array();
911 }
912 };
913
914 }
915
917 template<typename T>
918 inline typename PixelBuffer<T>::array_ref_type&
919 VariantPixelBuffer::array()
920 {
921 detail::VariantPixelBufferVisitor<T> v;
922 return boost::apply_visitor(v, buffer).array();
923 }
924
926 template<typename T>
927 inline const typename PixelBuffer<T>::array_ref_type&
928 VariantPixelBuffer::array() const
929 {
930 detail::VariantPixelBufferConstVisitor<T> v;
931 return boost::apply_visitor(v, buffer).array();
932 }
933
934 template<typename T>
935 inline T *
936 VariantPixelBuffer::data()
937 {
938 detail::VariantPixelBufferVisitor<T> v;
939 return boost::apply_visitor(v, buffer).data();
940 }
941
942 template<typename T>
943 inline const T *
944 VariantPixelBuffer::data() const
945 {
946 detail::VariantPixelBufferConstVisitor<T> v;
947 return boost::apply_visitor(v, buffer).data();
948 }
949
950 template<typename T>
951 inline const T *
952 VariantPixelBuffer::origin() const
953 {
954 detail::VariantPixelBufferConstVisitor<T> v;
955 return boost::apply_visitor(v, buffer).origin();
956 }
957
965 template <typename InputIterator>
966 inline void
967 VariantPixelBuffer::assign(InputIterator begin,
968 InputIterator end)
969 {
970 detail::VariantPixelBufferAssignVisitor<InputIterator> v(begin, end);
971 boost::apply_visitor(v, buffer);
972 }
973
974 template<class charT, class traits>
975 inline void
976 VariantPixelBuffer::read(std::basic_istream<charT,traits>& stream)
977 {
978 detail::VariantPixelBufferReadVisitor<charT, traits> v(stream);
979 boost::apply_visitor(v, buffer);
980 }
981
982 template<class charT, class traits>
983 inline void
984 VariantPixelBuffer::write(std::basic_ostream<charT,traits>& stream) const
985 {
986 detail::VariantPixelBufferWriteVisitor<charT, traits> v(stream);
987 boost::apply_visitor(v, buffer);
988 }
989
990 }
991 }
992
993 namespace std
994 {
995
1003 template<class charT, class traits>
1004 inline std::basic_istream<charT,traits>&
1005 operator>> (std::basic_istream<charT,traits>& is,
1006 ::ome::files::VariantPixelBuffer& buf)
1007 {
1008 buf.read(is);
1009 return is;
1010 }
1011
1019 template<class charT, class traits>
1020 inline std::basic_ostream<charT,traits>&
1021 operator<< (std::basic_ostream<charT,traits>& os,
1022 const ::ome::files::VariantPixelBuffer& buf)
1023 {
1024 buf.write(os);
1025 return os;
1026 }
1027
1028 }
1029
1030 #endif // OME_FILES_VARIANTPIXELBUFFER_H
1031
1032 /*
1033 * Local Variables:
1034 * mode:C++
1035 * End:
1036 */
ome::files::detail::VariantPixelBufferWriteVisitor::VariantPixelBufferWriteVisitor
VariantPixelBufferWriteVisitor(std::basic_ostream< charT, traits > &stream)
Constructor.
Definition: VariantPixelBuffer.h:805
ome::xml::model::enums::PixelType::UINT8
UINT8
ome::files::VariantPixelBuffer::createBuffer
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
ome::files::VariantPixelBuffer::basic_pixel_types_view
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
ome::files::PixelBuffer::array_ref_type
boost::multi_array_ref< value_type, dimensions > array_ref_type
Type for multi-dimensional pixel array view referencing external data.
Definition: PixelBuffer.h:247
ome::files::detail::MergeSubchannelVisitor::dest
VariantPixelBuffer & dest
Destination pixel buffer.
Definition: VariantPixelBuffer.h:881
ome::files::VariantPixelBuffer::index_bases
const boost::multi_array_types::index * index_bases() const
Get the index bases of the multi-dimensional array.
Definition: VariantPixelBuffer.cpp:368
ome::files::VariantPixelBuffer::read
void read(std::basic_istream< charT, traits > &stream)
Read raw pixel data from a stream in physical storage order.
Definition: VariantPixelBuffer.h:976
memory.h
ome::files::VariantPixelBuffer::setBuffer
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
ome::files::detail::VariantPixelBufferAssignVisitor::end
InputIterator end
Input end.
Definition: VariantPixelBuffer.h:723
ome::files::PixelBuffer
Buffer for a specific pixel type.
Definition: PixelBuffer.h:236
ome::files::VariantPixelBuffer::operator!=
bool operator!=(const VariantPixelBuffer &rhs) const
Compare a pixel buffer for inequality.
Definition: VariantPixelBuffer.cpp:423
ome::files::VariantPixelBuffer::integer_pixel_types
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
ome::files::VariantPixelBuffer::VariantPixelBuffer
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
ome::files::VariantPixelBuffer::makeBuffer
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
ome::files::VariantPixelBuffer::num_dimensions
size_type num_dimensions() const
Get the number of dimensions in the multi-dimensional array.
Definition: VariantPixelBuffer.cpp:347
ome::files::VariantPixelBuffer::empty_types
boost::mpl::vector empty_types
Empty vector placeholder.
Definition: VariantPixelBuffer.h:125
ome::files::dimension_size_type
std::size_t dimension_size_type
Size type for image dimensions.
Definition: Types.h:59
ome::files::VariantPixelBuffer::setBuffer
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
ome::files::VariantPixelBuffer::~VariantPixelBuffer
virtual ~VariantPixelBuffer()
Destructor.
Definition: VariantPixelBuffer.h:225
ome::files::detail::VariantPixelBufferAssignVisitor::begin
InputIterator begin
Input start.
Definition: VariantPixelBuffer.h:721
ome::files::detail::VariantPixelBufferReadVisitor::VariantPixelBufferReadVisitor
VariantPixelBufferReadVisitor(std::basic_istream< charT, traits > &stream)
Constructor.
Definition: VariantPixelBuffer.h:774
std
STL namespace.
ome::files::PixelProperties< ::ome::xml::model::enums::PixelType::UINT16 >
Properties of UINT16 pixels.
Definition: PixelProperties.h:208
ome::files::PixelProperties
Map a given PixelPropertiesType enum to the corresponding language types.
Definition: PixelProperties.h:61
ome::files::PixelProperties< ::ome::xml::model::enums::PixelType::COMPLEX >
Properties of COMPLEX pixels.
Definition: PixelProperties.h:335
ome::files::PixelProperties< ::ome::xml::model::enums::PixelType::UINT32 >
Properties of UINT32 pixels.
Definition: PixelProperties.h:231
ome::files::VariantPixelBuffer::strides
const boost::multi_array_types::index * strides() const
Get the strides of the multi-dimensional array.
Definition: VariantPixelBuffer.cpp:361
ome::files::VariantPixelBuffer::vbuffer
variant_buffer_type & vbuffer()
Get a reference to the variant buffer.
Definition: VariantPixelBuffer.h:234
ome::files::detail::CopySubchannelVisitor::dest
VariantPixelBuffer & dest
Destination pixel buffer.
Definition: VariantPixelBuffer.h:828
ome::files::VariantPixelBuffer::shape
const size_type * shape() const
Get the shape of the multi-dimensional array.
Definition: VariantPixelBuffer.cpp:354
ome::files::VariantPixelBuffer::raw_type
PixelProperties< ::ome::xml::model::enums::PixelType::UINT8 >::std_type raw_type
Raw pixel type used in public interfaces.
Definition: VariantPixelBuffer.h:135
ome::files::detail::VariantPixelBufferAssignVisitor::operator()
void operator()(ome::compat::shared_ptr< PixelBuffer< typename std::iterator_traits< InputIterator >::value_type > > &v) const
PixelBuffer of correct type.
Definition: VariantPixelBuffer.h:742
ome::files::detail::VariantPixelBufferWriteVisitor::stream
std::basic_ostream< charT, traits > & stream
The output stream.
Definition: VariantPixelBuffer.h:798
ome::files::VariantPixelBuffer::VariantPixelBuffer
VariantPixelBuffer()
Default constructor.
Definition: VariantPixelBuffer.h:158
ome::files::detail::CopySubchannelVisitor::subC
dimension_size_type subC
Subchannel to copy.
Definition: VariantPixelBuffer.h:830
ome::files::PixelProperties< ::ome::xml::model::enums::PixelType::INT32 >
Properties of INT32 pixels.
Definition: PixelProperties.h:162
ome::files::VariantPixelBuffer::pixel_buffer_types_view
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
ome::files::VariantPixelBuffer::make_buffer
Convert T into a buffer.
Definition: VariantPixelBuffer.h:115
variant.h
ome::files::VariantPixelBuffer::make_buffer::type
ome::compat::shared_ptr< PixelBuffer< typename T::std_type > > type
Buffer type.
Definition: VariantPixelBuffer.h:118
ome::files::PixelProperties< ::ome::xml::model::enums::PixelType::DOUBLECOMPLEX >
Properties of DOUBLECOMPLEX pixels.
Definition: PixelProperties.h:358
ome::files::detail::MergeSubchannelVisitor::subC
dimension_size_type subC
Subchannel to copy.
Definition: VariantPixelBuffer.h:883
ome::files::VariantPixelBuffer::origin
const T * origin() const
Get the origin of the array.
Definition: VariantPixelBuffer.h:952
ome::files::VariantPixelBuffer::operator=
VariantPixelBuffer & operator=(const VariantPixelBuffer &rhs)
Assign a pixel buffer.
Definition: VariantPixelBuffer.cpp:410
ome
ome::files::detail::CopySubchannelVisitor
Copy a single subchannel from a PixelBuffer.
Definition: VariantPixelBuffer.h:825
ome::files::PixelProperties< ::ome::xml::model::enums::PixelType::UINT8 >
Properties of UINT8 pixels.
Definition: PixelProperties.h:185
ome::files::PixelBufferBase::storage_order_type
boost::general_storage_order< dimensions > storage_order_type
Storage ordering type for controlling pixel memory layout.
Definition: PixelBuffer.h:121
ome::files::ENDIAN_NATIVE
Native endian.
Definition: Types.h:72
ome::files::PixelBufferBase::make_storage_order
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
ome::files::detail::MergeSubchannelVisitor::MergeSubchannelVisitor
MergeSubchannelVisitor(VariantPixelBuffer &dest, dimension_size_type subC)
Constructor.
Definition: VariantPixelBuffer.h:891
ome::files::detail::CopySubchannelVisitor::operator()
void operator()(const T &v)
Copy subchannel.
Definition: VariantPixelBuffer.h:851
ome::files::VariantPixelBuffer::float_pixel_types
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
ome::files::VariantPixelBuffer::array
PixelBuffer< T >::array_ref_type & array()
Get the pixel data.
ome::files::VariantPixelBuffer::pixel_buffer_types
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
ome::files::detail::VariantPixelBufferReadVisitor
Read data into a PixelBuffer.
Definition: VariantPixelBuffer.h:764
ome::files::detail::MergeSubchannelVisitor
Merge a single subchannel into a PixelBuffer.
Definition: VariantPixelBuffer.h:878
ome::files::VariantPixelBuffer::valid
bool valid() const
Check the buffer validity.
Definition: VariantPixelBuffer.cpp:326
boost
ome::files::VariantPixelBuffer::num_elements
size_type num_elements() const
Get the number of pixel elements in the multi-dimensional array.
Definition: VariantPixelBuffer.cpp:340
ome::files::EndianType
EndianType
Endianness.
Definition: Types.h:68
ome::files::VariantPixelBuffer::VariantPixelBuffer
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
ome::files::VariantPixelBuffer::vbuffer
const variant_buffer_type & vbuffer() const
Get a reference to the variant buffer.
Definition: VariantPixelBuffer.h:245
ome::files::detail::VariantPixelBufferConstVisitor::operator()
const PixelBuffer< T > & operator()(const ome::compat::shared_ptr< PixelBuffer< T > > &v) const
PixelBuffer of correct type.
Definition: VariantPixelBuffer.h:695
ome::files::PixelProperties< ::ome::xml::model::enums::PixelType::DOUBLE >
Properties of DOUBLE pixels.
Definition: PixelProperties.h:277
ome::files::detail::CopySubchannelVisitor::CopySubchannelVisitor
CopySubchannelVisitor(VariantPixelBuffer &dest, dimension_size_type subC)
Constructor.
Definition: VariantPixelBuffer.h:838
ome::files::detail::VariantPixelBufferConstVisitor
Find a PixelBuffer data array of a specific pixel type.
Definition: VariantPixelBuffer.h:685
ome::files::detail::VariantPixelBufferAssignVisitor::VariantPixelBufferAssignVisitor
VariantPixelBufferAssignVisitor(InputIterator begin, InputIterator end)
Constructor.
Definition: VariantPixelBuffer.h:731
ome::files::detail::VariantPixelBufferReadVisitor::operator()
void operator()(T &v) const
Read data into specific PixelBuffer type.
Definition: VariantPixelBuffer.h:785
ome::files::VariantPixelBuffer::write
void write(std::basic_ostream< charT, traits > &stream) const
Write raw pixel data to a stream in physical storage order.
Definition: VariantPixelBuffer.h:984
ome::xml::model::enums::DimensionOrder::XYZTC
XYZTC
ome::files::detail::VariantPixelBufferWriteVisitor::operator()
void operator()(const T &v) const
Write data from specific PixelBuffer type.
Definition: VariantPixelBuffer.h:816
ome::files::detail::MergeSubchannelVisitor::operator()
void operator()(const T &v)
Merge subchannel.
Definition: VariantPixelBuffer.h:904
ome::files::detail::VariantPixelBufferAssignVisitor
Assign a PixelBuffer from an input iterator.
Definition: VariantPixelBuffer.h:718
ome::files::VariantPixelBuffer::endianType
EndianType endianType() const
Get the endianness of the pixel type stored in the buffer.
Definition: VariantPixelBuffer.cpp:389
ome::xml::model::enums::PixelType
ome::files::VariantPixelBuffer::makeBuffer
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
ome::files::VariantPixelBuffer::buffer
variant_buffer_type buffer
Pixel storage.
Definition: VariantPixelBuffer.h:644
ome::files::detail::VariantPixelBufferWriteVisitor
Write data from a PixelBuffer.
Definition: VariantPixelBuffer.h:795
ome::files::VariantPixelBuffer::indices_type
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
ome::files::detail::VariantPixelBufferReadVisitor::stream
std::basic_istream< charT, traits > & stream
The input stream.
Definition: VariantPixelBuffer.h:767
ome::files::PixelBufferBase::range_type
boost::detail::multi_array::extent_gen< dimensions > range_type
Extent range type.
Definition: PixelBuffer.h:124
ome::files::detail::VariantPixelBufferVisitor
Find a PixelBuffer data array of a specific pixel type.
Definition: VariantPixelBuffer.h:652
ome::files::VariantPixelBuffer::range_type
PixelBufferBase::range_type range_type
Extent range type.
Definition: VariantPixelBuffer.h:147
ome::files::PixelBufferBase::dimensions
static const uint16_t dimensions
Total number of supported dimensions.
Definition: PixelBuffer.h:108
ome::files::VariantPixelBuffer::operator==
bool operator==(const VariantPixelBuffer &rhs) const
Compare a pixel buffer for equality.
Definition: VariantPixelBuffer.cpp:417
ome::files::PixelProperties< ::ome::xml::model::enums::PixelType::BIT >
Properties of BIT pixels.
Definition: PixelProperties.h:300
ome::files::VariantPixelBuffer::createBuffer
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
ome::files::VariantPixelBuffer::storage_order
const storage_order_type & storage_order() const
Get the array storage order.
Definition: VariantPixelBuffer.cpp:375
ome::files::PixelBufferBase::default_storage_order
static storage_order_type default_storage_order()
Generate default storage ordering.
Definition: PixelBuffer.cpp:133
ome::files::VariantPixelBuffer::data
raw_type * data()
Get raw buffered data.
Definition: VariantPixelBuffer.cpp:396
ome::files::VariantPixelBuffer
Buffer for all pixel types.
Definition: VariantPixelBuffer.h:75
ome::files::VariantPixelBuffer::VariantPixelBuffer
VariantPixelBuffer(ome::compat::shared_ptr< PixelBuffer< T > > &buffer)
Construct from existing pixel buffer.
Definition: VariantPixelBuffer.h:218
ome::files::VariantPixelBuffer::size_type
boost::multi_array_types::size_type size_type
Size type.
Definition: VariantPixelBuffer.h:138
ome::files::VariantPixelBuffer::managed
bool managed() const
Check if the buffer is internally managed.
Definition: VariantPixelBuffer.cpp:333
ome::files::VariantPixelBuffer::assign
void assign(InputIterator begin, InputIterator end)
Assign pixel values.
Definition: VariantPixelBuffer.h:967
ome::files::VariantPixelBuffer::variant_buffer_type
boost::make_variant_over< pixel_buffer_types >::type variant_buffer_type
Buffer type, allowing assignment of all buffer types.
Definition: VariantPixelBuffer.h:132
ome::files::VariantPixelBuffer::storage_order_type
PixelBufferBase::storage_order_type storage_order_type
Storage ordering type for controlling pixel memory layout.
Definition: VariantPixelBuffer.h:144
ome::files::detail::VariantPixelBufferVisitor::operator()
PixelBuffer< T > & operator()(ome::compat::shared_ptr< PixelBuffer< T > > &v) const
PixelBuffer of correct type.
Definition: VariantPixelBuffer.h:662
ome::files::VariantPixelBuffer::pixelType
::ome::xml::model::enums::PixelType pixelType() const
Get the type of pixels stored in the buffer.
Definition: VariantPixelBuffer.cpp:382
ome::files::PixelProperties< ::ome::xml::model::enums::PixelType::INT16 >
Properties of INT16 pixels.
Definition: PixelProperties.h:139
ome::files::DIM_SUBCHANNEL
Logical sub-channel (typically used for RGB channel sub-components) (S).
Definition: PixelBuffer.h:86