#include "diplib.h"
dip::Image::Sample class

A sample represents a single numeric value in an image, see Image representation.

Objects of this class are meant as an interface between images and numbers. These objects are not actually how values are stored in an image, but rather represent a reference to a sample in an image. Through this reference, individual samples in an image can be changed. For example:

dip::Image img( { 256, 256 } );
img.At( 10, 20 )[ 0 ] = 3;

In the code above, img.At( 10, 20 )[ 0 ] returns a Sample object. Assigning to this object changes the sample in img that is referenced.

See Indexing for more information.

Derived classes

template<typename T>
class dip::Image::CastSample
Derived from dip::Image::Sample, works identically except it implicitly converts to type T. \relates dip::Image::Sample

Constructors, destructors, assignment and conversion operators

Sample(dip::DataType dataType = DT_SFLOAT) explicit
Construct a new Sample by giving the data type. Initialized to 0.
template<typename T, typename <SFINAE>>
Sample(T value) constexpr
A numeric value implicitly converts to a Sample.
Sample(dip::Image::Pixel const& pixel)
A dip::Image::Pixel, when cast to a Sample, references the first value in the pixel.
Sample(dip::Image const& image) explicit
A dip::Image, when cast to a Sample, references the first sample in the first pixel in the image.
auto operator=(dip::Image::Sample const& sample) -> dip::Image::Sample& constexpr
Assigning to a Sample copies the value over to the sample referenced.
template<typename T, typename <SFINAE>>
auto operator=(T value) -> dip::Image::Sample& constexpr
It is also possible to assign a constant directly.

Functions

void swap(dip::Image::Sample& other) noexcept
Swaps *this and other.
static auto Maximum(dip::DataType dt) -> dip::Image::Sample
Creates a sample with the largest finite value for the given data type. Not implemented for complex types.
static auto Minimum(dip::DataType dt) -> dip::Image::Sample
Creates a sample with the lowest finite value for the given data type. Not implemented for complex types.
template<typename T, typename <SFINAE>>
auto As() const -> T constexpr
Returns the value of the sample as the given numeric type, similar to using static_cast.
auto Origin() const -> void* constexpr
Returns a pointer to the sample referenced.
auto DataType() const -> dip::DataType constexpr
The data type of the sample referenced.

Operators

auto operator bool() const -> bool explicit constexpr
A Sample can be cast to basic numerical types.
auto operator dip::uint() const -> dip::uint explicit constexpr
A Sample can be cast to basic numerical types.
auto operator dip::sint() const -> dip::sint explicit constexpr
A Sample can be cast to basic numerical types.
auto operator sfloat() const -> dip::sfloat explicit constexpr
A Sample can be cast to basic numerical types.
auto operator dfloat() const -> dip::dfloat explicit constexpr
A Sample can be cast to basic numerical types.
auto operator scomplex() const -> dip::scomplex explicit constexpr
A Sample can be cast to basic numerical types.
template<typename T>
auto operator+=(T const& rhs) -> dip::Image::Sample&
Compound assignment operator.
template<typename T>
auto operator-=(T const& rhs) -> dip::Image::Sample&
Compound assignment operator.
template<typename T>
auto operator*=(T const& rhs) -> dip::Image::Sample&
Compound assignment operator.
template<typename T>
auto operator/=(T const& rhs) -> dip::Image::Sample&
Compound assignment operator.
template<typename T>
auto operator%=(T const& rhs) -> dip::Image::Sample&
Compound assignment operator.
template<typename T>
auto operator&=(T const& rhs) -> dip::Image::Sample&
Bit-wise compound assignment operator.
template<typename T>
auto operator|=(T const& rhs) -> dip::Image::Sample&
Bit-wise compound assignment operator.
template<typename T>
auto operator^=(T const& rhs) -> dip::Image::Sample&
Bit-wise compound assignment operator.