IOLink  IOL_v1.1.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 
216  static std::shared_ptr<ImageView> copyOnDisk(std::shared_ptr<ImageView> image);
217 
245  static std::shared_ptr<ImageView> copyOnDisk(std::shared_ptr<ImageView> image, const std::string& dirPath);
246 
268  static std::shared_ptr<ImageView> fromBuffer(const VectorXu64& shape,
269  DataType type,
270  void* buffer,
271  size_t bufferSize,
272  std::shared_ptr<ImageProperties> properties,
273  const std::shared_ptr<MetadataNode> metadata);
274 
291  static std::shared_ptr<ImageView> fromBuffer(const VectorXu64& shape, DataType type, void* buffer, size_t bufferSize);
292 
311  static std::shared_ptr<ImageView> fromRandomAccess(std::shared_ptr<RandomAccess> accessor,
312  MemoryLayout layout,
313  const VectorXu64& shape,
314  const DataType type,
315  std::shared_ptr<ImageProperties> properties,
316  const std::shared_ptr<const MetadataNode> metadata);
317 
332  static std::shared_ptr<ImageView> fromRandomAccess(std::shared_ptr<RandomAccess> accessor,
333  MemoryLayout layout,
334  const VectorXu64& shape,
335  const DataType type);
336 
357  static std::shared_ptr<ImageView> fromRandomAccess(std::shared_ptr<RandomAccess> accessor,
358  const VectorXu64& shape,
359  const DataType type,
360  std::shared_ptr<ImageProperties> properties,
361  std::shared_ptr<const MetadataNode> metadata);
362 
380  static std::shared_ptr<ImageView> fromRandomAccess(std::shared_ptr<RandomAccess> accessor,
381  const VectorXu64& shape,
382  const DataType type);
383 
397  static std::shared_ptr<ImageView> fromImageView(std::shared_ptr<ImageView> view,
398  std::shared_ptr<const ImageProperties> properties,
399  std::shared_ptr<const MetadataNode> metadata);
400 
419  static std::shared_ptr<ImageView> uniform(const VectorXu64& shape,
420  DataType type,
421  void* value,
422  std::shared_ptr<ImageProperties> properties,
423  std::shared_ptr<const MetadataNode> metadata);
424 
439  static std::shared_ptr<ImageView> uniform(const VectorXu64& shape, DataType type, void* value);
440 
441  // ==================== //
442  // Adapting Image Views //
443  // ==================== //
444 
477  static std::shared_ptr<ImageView> adaptDynamicRange(std::shared_ptr<ImageView> view,
478  DataType type,
479  const Vector2d& inputRange,
480  const Vector2d& outputRange);
481 
506  static std::shared_ptr<ImageView> adaptDataType(std::shared_ptr<ImageView> view, DataType type);
507 
526  static std::shared_ptr<ImageView> extractChannel(std::shared_ptr<ImageView> view, size_t idxChannel);
527 
545  static std::shared_ptr<ImageView> extractRegion(std::shared_ptr<ImageView> view, const RegionXu64& region);
546 
568  static std::shared_ptr<ImageView> extractAdjustedRegion(std::shared_ptr<ImageView> view, const RegionXu64& region);
569 
594  static std::shared_ptr<ImageView> stack(std::shared_ptr<MultiImageView> view, ImageDimension newDimension);
595 
618  static std::shared_ptr<ImageView> stack(std::shared_ptr<MultiImageView> view);
619 
637  static std::shared_ptr<ImageView> assembleChannels(std::shared_ptr<ImageView> image);
638 
657  static std::shared_ptr<ImageView> disassembleChannels(std::shared_ptr<ImageView> image);
658 
690  static std::shared_ptr<ImageView> interlace(std::shared_ptr<MultiImageView> multiView,
691  ImageInterpretation newInterpretation,
692  bool hasAlpha);
693 
723  static std::shared_ptr<ImageView> interlace(std::shared_ptr<MultiImageView> multiView);
724 
749  static std::shared_ptr<ImageView> reinterpret(std::shared_ptr<ImageView> image, ImageType newImageType);
750 
787  static std::shared_ptr<ImageView> reinterpretAxes(std::shared_ptr<ImageView> image,
788  std::initializer_list<ImageDimension> dimensionsList);
789 
808  static std::shared_ptr<ImageView> reinterpretAxes(std::shared_ptr<ImageView> image,
809  const ImageDimension* dimensionsList,
810  size_t count);
811 
832  static std::shared_ptr<ImageView> subSample(std::shared_ptr<ImageView> image, size_t step);
833 
851  static std::shared_ptr<ImageView> flip(std::shared_ptr<ImageView> image, ImageDimension dimension);
852 
869  static std::shared_ptr<ImageView> flip(std::shared_ptr<ImageView> image, size_t dimensionIndex);
870 
881  static std::shared_ptr<ImageView> makeThreadSafe(std::shared_ptr<ImageView> image);
882 };
883 
884 } // end namespace iolink