|
xentara-plugin v2.1
The Xentara Plugin Framework
|
An image data point value. More...
#include <xentara/data/Image.hpp>
Public Member Functions | |
| Image () | |
| Constructor that creates an empty monochrome image. | |
| template<std::ranges::contiguous_range Data> requires PixelCppType<std::remove_cv_t<std::ranges::range_value_t<Data>>> | |
| Image (const Data &data, std::size_t width, std::size_t height, ColorSpace colorSpace, ColorDepth colorDepth=defaultColorDepth< std::ranges::range_value_t< Data > >()) | |
| Constructor that sets the image data. | |
| template<std::contiguous_iterator Iterator, std::sized_sentinel_for< Iterator > Sentinel> requires PixelCppType<std::remove_cv_t<std::iter_value_t<Iterator>>> | |
| Image (Iterator first, Sentinel last, std::size_t width, std::size_t height, ColorSpace colorSpace, ColorDepth colorDepth=defaultColorDepth< std::iter_value_t< Iterator > >()) | |
| Constructor that sets the image data using an iterator/sentinel pair. | |
| auto | width () const noexcept -> std::size_t |
| Gets the width of the image. | |
| auto | height () const noexcept -> std::size_t |
| Gets the height of the image. | |
| auto | empty () const noexcept -> bool |
| Checks whether the image is empty and contains no pixels. | |
| auto | colorSpace () const noexcept -> ColorSpace |
| Gets the colour space used by the image. | |
| auto | colorDepth () const noexcept -> ColorDepth |
| Gets the colour depth of the image. | |
| auto | channelCount () const noexcept -> std::size_t |
| Gets the number of channels in the image. | |
| auto | pixelType () const noexcept -> PixelType |
| Gets C++ type used for the individual pixels, as determined by the colour depth. | |
| auto | combinedPlaneHeight () const noexcept -> std::size_t |
| Gets the height of the image, plus any extra height to store necessary additional planes. | |
| auto | data () const -> std::variant< std::span< const std::uint8_t >, std::span< const std::uint16_t >, std::span< const std::int8_t >, std::span< const std::int16_t >, std::span< const float >, std::span< const double > > |
| Gets the image data as a variant. | |
| template<PixelCppType PixelType> | |
| auto | data () const -> std::span< const PixelType > |
| Gets the image data if the C++ type is already known. | |
| template<std::same_as< std::byte > > | |
| auto | data () const -> std::span< const std::byte > |
| Gets the image data as raw bytes. | |
| template<utils::tools::CharType Char, typename CharTraits = std::char_traits<Char>> | |
| auto | toBasicString () const -> std::basic_string< Char, CharTraits > |
| Converts the image info to a string. | |
| auto | toString () const -> std::string |
| Converts the image info to a string of type char. | |
| auto | toWString () const -> std::wstring |
| Converts the image info to a string of type wchar_t. | |
| auto | toU8String () const -> std::u8string |
| Converts the image info to a string of type char8_t. | |
| auto | toU16String () const -> std::u16string |
| Converts the image info to a string of type char16_t. | |
| auto | toU32String () const -> std::u32string |
| Converts the image info to a string of type char32_t. | |
Static Public Member Functions | |
| template<PixelCppType PixelType> | |
| static auto | makeForOverwrite (std::size_t width, std::size_t height, ColorSpace colorSpace, ColorDepth colorDepth=defaultColorDepth< PixelType >()) -> std::pair< Image, std::span< PixelType > > |
| Creates an image with uninitialized pixel data. | |
| template<std::same_as< std::byte > > | |
| static auto | makeForOverwrite (std::size_t width, std::size_t height, ColorSpace colorSpace, ColorDepth colorDepth) -> std::pair< Image, std::span< std::byte > > |
| Creates an image with uninitialized pixel data, returning the data as raw bytes. | |
| template<typename PixelType > requires PixelCppType<std::remove_cv_t<PixelType>> | |
| static constexpr auto | defaultColorDepth () -> ColorDepth |
| Gets the default color depth used for a certain CPP type. | |
OpenCV interoperability | |
| |
| enum class | OpenCvColorSpace { COLOR_BGR , COLOR_RGB , COLOR_BGRA , COLOR_RGBA , COLOR_GRAY , internal } |
| Supported target colour spaces for conversion to OpenCV types. More... | |
| auto | cvMat () const noexcept -> cv::Mat |
| Gets the data as an OpenCV matrix. | |
| auto | copyTo (cv::OutputArray data) const noexcept -> void |
| Copies the data to an OpenCV matrix, or another type of OpenCV output array. | |
| auto | cvSize () const noexcept -> cv::Size |
| Gets the OpenCV size code of the image data. | |
| auto | cvDepth () const noexcept -> int |
| Gets the OpenCV depth code of the image data. | |
| auto | cvType () const noexcept -> int |
| Gets the OpenCV matrix type code of the image data. | |
| auto | cvChannels () const noexcept -> int |
| Gets the OpenCV channel count. | |
| auto | cvColorConversionCode (OpenCvColorSpace targetColorSpace) const -> std::optional< int > |
| Gets a color conversion code for use with cv::cvtColor(). | |
| template<std::same_as< cv::Mat > > | |
| static auto | makeForOverwrite (std::size_t width, std::size_t height, ColorSpace colorSpace, ColorDepth colorDepth) -> std::pair< Image, cv::Mat > |
| Creates an image with uninitialized pixel data, returning the data as a cv::Mat. | |
An image data point value.
This class uses sharing for the actual image data, similar to std::shared_ptr. If you make a copy of an image object, the copy will share the image data with the original. This means that images can be copied in constant time, irrespective of their size.
|
strong |
Supported target colour spaces for conversion to OpenCV types.
| xentara::data::Image::Image | ( | ) |
Constructor that creates an empty monochrome image.
This constructor creates a BRG image with a size of 0 × 0 pixels.
| xentara::data::Image::Image | ( | const Data & | data, |
| std::size_t | width, | ||
| std::size_t | height, | ||
| ColorSpace | colorSpace, | ||
| ColorDepth | colorDepth = defaultColorDepth<std::ranges::range_value_t<Data>>() |
||
| ) |
Constructor that sets the image data.
| data | The image data. This must be a range of pixels, like std::vector<PixelType>, std::array<PixelType>, or std::span<const PixelType>. The data type and size of the data must match the specified width, height, and colour settings. |
| width | The the width of the image. |
| height | The the height of the image. |
| colorSpace | The the colour space used by the image. |
| colorDepth | The the colour depth of the image. |
| std::invalid_argument | data has the wrong element data type or wrong size for the specified width, height, and colour settings. |
| xentara::data::Image::Image | ( | Iterator | first, |
| Sentinel | last, | ||
| std::size_t | width, | ||
| std::size_t | height, | ||
| ColorSpace | colorSpace, | ||
| ColorDepth | colorDepth = defaultColorDepth<std::iter_value_t<Iterator>>() |
||
| ) |
Constructor that sets the image data using an iterator/sentinel pair.
| first | The beginning of the image data. The data type of the data must match the specified colour depth. |
| last | The sntinel object for the image data. The distance between first and last, must match the specified width, height, and colour space. |
| width | The the width of the image. |
| height | The the height of the image. |
| colorSpace | The the colour space used by the image. |
| colorDepth | The the colour depth of the image. |
| std::invalid_argument | data has the wrong element data type or wrong size for the specified width, height, and colour settings. |
|
noexcept |
Gets the number of channels in the image.
|
noexcept |
Gets the colour depth of the image.
|
noexcept |
Gets the colour space used by the image.
|
noexcept |
Gets the height of the image, plus any extra height to store necessary additional planes.
Gets the height of the image data. For most color spaces this is the same as the image height, but for Y′UV 4:2:0 images, the data height includes space of the extra half-plane used to store the U/V data.
|
noexcept |
Copies the data to an OpenCV matrix, or another type of OpenCV output array.
|
noexcept |
Gets the OpenCV channel count.
| auto xentara::data::Image::cvColorConversionCode | ( | OpenCvColorSpace | targetColorSpace | ) | const -> std::optional< int > |
Gets a color conversion code for use with cv::cvtColor().
| targetColorSpace | The color space to convert to. |
| std::runtime_error | The conversion is not supported by OpenCV |
|
noexcept |
Gets the OpenCV depth code of the image data.
|
noexcept |
Gets the data as an OpenCV matrix.
|
noexcept |
Gets the OpenCV size code of the image data.
|
noexcept |
Gets the OpenCV matrix type code of the image data.
| auto xentara::data::Image::data | ( | ) | const -> std::span< const PixelType > |
Gets the image data if the C++ type is already known.
| std::invalid_argument | The data is not of type PixelType. |
| auto xentara::data::Image::data | ( | ) | const -> std::span< const std::byte > |
Gets the image data as raw bytes.
Calling this function is equivalent to calling data<PixelCppType PixelType>(), and passing the result through std::as_bytes().
| auto xentara::data::Image::data | ( | ) | const -> std::variant< std::span< const std::uint8_t >, std::span< const std::uint16_t >, std::span< const std::int8_t >, std::span< const std::int16_t >, std::span< const float >, std::span< const double > > |
Gets the image data as a variant.
|
staticconstexpr |
Gets the default color depth used for a certain CPP type.
This function retrurns the following types:
| Pixel Type | Colour Depth |
|---|---|
| std::uint8_t | PixelType::Unsigned8Bit |
| std::uint16_t | PixelType::Unsigned16Bit |
| std::int8_t | PixelType::Signed8Bit |
| std::int16_t | PixelType::Signed16Bit |
| float | PixelType::Float |
| double | PixelType::Double |
| PixelType | The C++ type used for the pixels. cv-qualifiers are ignored, so const std::uint8_t is treated the same as std::uint8_t |
|
noexcept |
Checks whether the image is empty and contains no pixels.
|
noexcept |
Gets the height of the image.
|
static |
Creates an image with uninitialized pixel data, returning the data as a cv::Mat.
Calling this function is equivalent to calling makeForOverwriteWithRawBytes<PixelCppType PixelType>(), and creating a cv::Mat object referencing the returned data span.
| width | The the width of the image. |
| height | The the height of the image. |
| colorSpace | The the colour space used by the image. |
| colorDepth | The the colour depth of the image. |
| std::invalid_argument | PixelType does not match the specified colour depth. |
|
static |
Creates an image with uninitialized pixel data, returning the data as raw bytes.
Calling this function is equivalent to calling makeForOverwriteWithRawBytes<PixelCppType PixelType>(), and passing the resulting data span through std::as_writable_bytes().
| width | The the width of the image. |
| height | The the height of the image. |
| colorSpace | The the colour space used by the image. |
| colorDepth | The the colour depth of the image. |
| std::invalid_argument | PixelType does not match the specified colour depth. |
|
static |
Creates an image with uninitialized pixel data.
| PixelType | The C++ type to be used for storing the pixels. |
| width | The the width of the image. |
| height | The the height of the image. |
| colorSpace | The the colour space used by the image. |
| colorDepth | The the colour depth of the image. |
| std::invalid_argument | PixelType does not match the specified colour depth. |
|
noexcept |
Gets C++ type used for the individual pixels, as determined by the colour depth.
| auto xentara::data::Image::toBasicString | ( | ) | const -> std::basic_string<Char, CharTraits> |
Converts the image info to a string.
| auto xentara::data::Image::toString | ( | ) | const -> std::string |
Converts the image info to a string of type char.
| auto xentara::data::Image::toU16String | ( | ) | const -> std::u16string |
Converts the image info to a string of type char16_t.
| auto xentara::data::Image::toU32String | ( | ) | const -> std::u32string |
Converts the image info to a string of type char32_t.
| auto xentara::data::Image::toU8String | ( | ) | const -> std::u8string |
Converts the image info to a string of type char8_t.
| auto xentara::data::Image::toWString | ( | ) | const -> std::wstring |
Converts the image info to a string of type wchar_t.
|
noexcept |
Gets the width of the image.