 |
LibraryLink Utilities
3.0.1
Modern C++ wrapper over LibraryLink and WSTP
|
Go to the documentation of this file.
6 #ifndef LLU_CONTAINERS_VIEWS_IMAGE_HPP
7 #define LLU_CONTAINERS_VIEWS_IMAGE_HPP
44 mint
rows()
const override {
74 bool is3D()
const override {
89 imagedata_t
type() const final {
103 class ImageTypedView :
public ImageView,
public IterableContainer<T> {
105 ImageTypedView() =
default;
112 ImageTypedView(
const GenericImage& gIm) : ImageView(gIm) {
113 if (ImageType<T> != type()) {
123 ImageTypedView(ImageView iv) : ImageView(std::move(iv)) {
124 if (ImageType<T> !=
type()) {
134 ImageTypedView(MImage mi) : ImageView(mi) {
135 if (ImageType<T> !=
type()) {
141 T* getData() const noexcept
override {
142 return static_cast<T*
>(
rawData());
145 mint getSize() const noexcept
override {
158 template<
typename ImageT,
typename F>
160 switch (img.type()) {
161 case MImage_Type_Bit:
return std::forward<F>(callable)(ImageTypedView<std::int8_t>(std::forward<ImageT>(img)));
162 case MImage_Type_Bit8:
return std::forward<F>(callable)(ImageTypedView<std::uint8_t>(std::forward<ImageT>(img)));
163 case MImage_Type_Bit16:
return std::forward<F>(callable)(ImageTypedView<std::uint16_t>(std::forward<ImageT>(img)));
164 case MImage_Type_Real32:
return std::forward<F>(callable)(ImageTypedView<float>(std::forward<ImageT>(img)));
165 case MImage_Type_Real:
return std::forward<F>(callable)(ImageTypedView<double>(std::forward<ImageT>(img)));
174 return asTypedImage(ImageView {img}, std::forward<F>(callable));
179 #endif // LLU_CONTAINERS_VIEWS_IMAGE_HPP
mint slices() const override
Get number of slices.
Definition: Views/Image.hpp:54
mint rows() const override
Get number of rows.
Definition: Views/Image.hpp:44
MContainer< MArgumentType::Image > GenericImage
MContainer specialization for MImage is called GenericImage.
Definition: Generic/Image.hpp:17
Main namespace of LibraryLink Utilities.
Definition: Queue.h:13
bool alphaChannelQ() const override
Check if there is an alpha channel in the image.
Definition: Views/Image.hpp:64
colorspace_t colorspace() const override
Get colorspace which describes how colors are represented as numbers.
Definition: Views/Image.hpp:39
void * rawData() const override
Get access to raw image data.
Definition: Views/Image.hpp:94
const std::string ImageTypeError
Image type mismatch.
Abstract class that defines a basic set of operations on an image.
Definition: Interfaces.h:17
MContainer specialization for MImage.
Definition: Generic/Image.hpp:23
ImageView(MImage mi)
Create a ImageView from a raw MImage.
Definition: Views/Image.hpp:36
imagedata_t type() const final
Get the data type of the image.
Definition: Views/Image.hpp:89
GenericImage definition and implementation.
static const st_WolframImageLibrary_Functions * ImageAPI()
Get a pointer to structure with function pointers to MImage API.
Definition: LibraryData.cpp:41
Container getContainer() const noexcept
Get internal container.
Definition: Base.hpp:97
Definition of the ErrorManager class responsible for error registration and throwing.
mint channels() const override
Get number of channels.
Definition: Views/Image.hpp:59
mint getRank() const override
Get rank.
Definition: Views/Image.hpp:79
ImageView(const GenericImage &gIm)
Create a ImageView from a GenericImage.
Definition: Views/Image.hpp:30
static void throwException(const std::string &errorName, T &&... args)
Throw exception with given name.
Definition: ErrorManager.h:199
mint getFlattenedLength() const override
Get the total number of pixels in the image.
Definition: Views/Image.hpp:84
bool interleavedQ() const override
Check if the image is interleaved.
Definition: Views/Image.hpp:69
bool is3D() const override
Check if the image is 3D.
Definition: Views/Image.hpp:74
mint columns() const override
Get number of columns.
Definition: Views/Image.hpp:49
Implementation of the IterableContainer class.
auto asTypedImage(ImageT &&img, F &&callable)
Take a Image-like object img and a function callable and call the function with a ImageTypedView crea...
Definition: Views/Image.hpp:159
Simple, light-weight, non-owning wrappper over MImage.
Definition: Views/Image.hpp:22