IOLink  IOL_v1.2.0_release
ImageViewFactory.h
1 #pragma once
2 
3 #include <iolink/IOLinkAPI.h>
4 #include <iolink/MemoryLayout.h>
5 #include <iolink/storage/RandomAccess.h>
6 #include <iolink/view/ImageView.h>
7 #include <iolink/view/MultiImageView.h>
8 
9 #include <memory>
10 
11 namespace iolink
12 {
13 
26 class IOLINK_API ImageViewFactory
27 {
28 public:
29  ImageViewFactory() = delete;
30  ImageViewFactory(const ImageViewFactory& other) = delete; // copy constructor
31  ImageViewFactory(ImageViewFactory&& other) = delete; // move constructor
32  ImageViewFactory& operator=(const ImageViewFactory& other) = delete; // copy assignment
33  ImageViewFactory& operator=(ImageViewFactory&& other) = delete; // move assignment
34 
35  // ==================== //
36  // Creating Image Views //
37  // ==================== //
38 
58  static std::shared_ptr<ImageView> allocate(const VectorXu64& shape,
59  DataType type,
60  std::shared_ptr<ImageProperties> properties,
61  std::shared_ptr<MetadataNode> metadata);
62 
77  static std::shared_ptr<ImageView> allocate(const VectorXu64& shape, DataType type);
78 
99  static std::shared_ptr<ImageView> copyInMemory(std::shared_ptr<ImageView> image);
100 
122  static std::shared_ptr<ImageView> createOnDisk(const std::string& dirPath,
123  const VectorXu64& shape,
124  DataType type,
125  std::shared_ptr<ImageProperties> properties,
126  std::shared_ptr<MetadataNode> metadata);
127 
146  static std::shared_ptr<ImageView> createOnDisk(const std::string& dirPath, const VectorXu64& shape, DataType type);
147 
168  static std::shared_ptr<ImageView> createOnDisk(const VectorXu64& shape,
169  DataType type,
170  std::shared_ptr<ImageProperties> properties,
171  std::shared_ptr<MetadataNode> metadata);
172 
189  static std::shared_ptr<ImageView> createOnDisk(const VectorXu64& shape, DataType type);
190 
217  static std::shared_ptr<ImageView> copyOnDisk(std::shared_ptr<ImageView> image);
218 
247  static std::shared_ptr<ImageView> copyOnDisk(std::shared_ptr<ImageView> image, const std::string& dirPath);
248 
270  static std::shared_ptr<ImageView> fromBuffer(const VectorXu64& shape,
271  DataType type,
272  void* buffer,
273  size_t bufferSize,
274  std::shared_ptr<ImageProperties> properties,
275  const std::shared_ptr<MetadataNode> metadata);
276 
293  static std::shared_ptr<ImageView> fromBuffer(const VectorXu64& shape, DataType type, void* buffer, size_t bufferSize);
294 
313  static std::shared_ptr<ImageView> fromRandomAccess(std::shared_ptr<RandomAccess> accessor,
314  MemoryLayout layout,
315  const VectorXu64& shape,
316  const DataType type,
317  std::shared_ptr<ImageProperties> properties,
318  const std::shared_ptr<const MetadataNode> metadata);
319 
335  static std::shared_ptr<ImageView> fromRandomAccess(std::shared_ptr<RandomAccess> accessor,
336  MemoryLayout layout,
337  const VectorXu64& shape,
338  const DataType type);
339 
361  static std::shared_ptr<ImageView> fromRandomAccess(std::shared_ptr<RandomAccess> accessor,
362  const VectorXu64& shape,
363  const DataType type,
364  std::shared_ptr<ImageProperties> properties,
365  std::shared_ptr<const MetadataNode> metadata);
366 
385  static std::shared_ptr<ImageView> fromRandomAccess(std::shared_ptr<RandomAccess> accessor,
386  const VectorXu64& shape,
387  const DataType type);
388 
403  static std::shared_ptr<ImageView> fromImageView(std::shared_ptr<ImageView> view,
404  std::shared_ptr<const ImageProperties> properties,
405  std::shared_ptr<const MetadataNode> metadata);
406 
425  static std::shared_ptr<ImageView> uniform(const VectorXu64& shape,
426  DataType type,
427  void* value,
428  std::shared_ptr<ImageProperties> properties,
429  std::shared_ptr<const MetadataNode> metadata);
430 
445  static std::shared_ptr<ImageView> uniform(const VectorXu64& shape, DataType type, void* value);
446 
447  // ==================== //
448  // Adapting Image Views //
449  // ==================== //
450 
484  static std::shared_ptr<ImageView> adaptDynamicRange(std::shared_ptr<ImageView> view,
485  DataType type,
486  const Vector2d& inputRange,
487  const Vector2d& outputRange);
488 
514  static std::shared_ptr<ImageView> adaptDataType(std::shared_ptr<ImageView> view, DataType type);
515 
535  static std::shared_ptr<ImageView> extractChannel(std::shared_ptr<ImageView> view, size_t idxChannel);
536 
555  static std::shared_ptr<ImageView> extractRegion(std::shared_ptr<ImageView> view, const RegionXu64& region);
556 
579  static std::shared_ptr<ImageView> extractAdjustedRegion(std::shared_ptr<ImageView> view, const RegionXu64& region);
580 
606  static std::shared_ptr<ImageView> stack(std::shared_ptr<MultiImageView> view, ImageDimension newDimension);
607 
631  static std::shared_ptr<ImageView> stack(std::shared_ptr<MultiImageView> view);
632 
651  static std::shared_ptr<ImageView> assembleChannels(std::shared_ptr<ImageView> image);
652 
672  static std::shared_ptr<ImageView> disassembleChannels(std::shared_ptr<ImageView> image);
673 
706  static std::shared_ptr<ImageView> interlace(std::shared_ptr<MultiImageView> multiView,
707  ImageInterpretation newInterpretation,
708  bool hasAlpha);
709 
740  static std::shared_ptr<ImageView> interlace(std::shared_ptr<MultiImageView> multiView);
741 
768  static std::shared_ptr<ImageView> reinterpret(std::shared_ptr<ImageView> image, ImageType newImageType);
769 
807  static std::shared_ptr<ImageView> reinterpretAxes(std::shared_ptr<ImageView> image,
808  std::initializer_list<ImageDimension> dimensionsList);
809 
829  static std::shared_ptr<ImageView> reinterpretAxes(std::shared_ptr<ImageView> image,
830  const ImageDimension* dimensionsList,
831  size_t count);
832 
854  static std::shared_ptr<ImageView> subSample(std::shared_ptr<ImageView> image, size_t step);
855 
874  static std::shared_ptr<ImageView> flip(std::shared_ptr<ImageView> image, ImageDimension dimension);
875 
893  static std::shared_ptr<ImageView> flip(std::shared_ptr<ImageView> image, size_t dimensionIndex);
894 
906  static std::shared_ptr<ImageView> makeThreadSafe(std::shared_ptr<ImageView> image);
907 };
908 
909 } // end namespace iolink