IOLink  IOL_v1.6.1_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 
608  static std::shared_ptr<ImageView> stack(std::shared_ptr<MultiImageView> view, ImageDimension newDimension);
609 
633  static std::shared_ptr<ImageView> stack(std::shared_ptr<MultiImageView> view);
634 
653  static std::shared_ptr<ImageView> assembleChannels(std::shared_ptr<ImageView> image);
654 
674  static std::shared_ptr<ImageView> disassembleChannels(std::shared_ptr<ImageView> image);
675 
708  static std::shared_ptr<ImageView> interlace(std::shared_ptr<MultiImageView> multiView,
709  ImageInterpretation newInterpretation,
710  bool hasAlpha);
711 
742  static std::shared_ptr<ImageView> interlace(std::shared_ptr<MultiImageView> multiView);
743 
770  static std::shared_ptr<ImageView> reinterpret(std::shared_ptr<ImageView> image, ImageType newImageType);
771 
809  static std::shared_ptr<ImageView> reinterpretAxes(std::shared_ptr<ImageView> image,
810  std::initializer_list<ImageDimension> dimensionsList);
811 
831  static std::shared_ptr<ImageView> reinterpretAxes(std::shared_ptr<ImageView> image,
832  const ImageDimension* dimensionsList,
833  size_t count);
834 
856  static std::shared_ptr<ImageView> subSample(std::shared_ptr<ImageView> image, size_t step);
857 
876  static std::shared_ptr<ImageView> flip(std::shared_ptr<ImageView> image, ImageDimension dimension);
877 
895  static std::shared_ptr<ImageView> flip(std::shared_ptr<ImageView> image, size_t dimensionIndex);
896 
908  static std::shared_ptr<ImageView> makeThreadSafe(std::shared_ptr<ImageView> image);
909 };
910 
911 } // end namespace iolink