spice namespace

Contains the entire public interface of the library.

Namespaces

namespace blend_function
blend operations
namespace blur
namespace helpers
namespace interpolation
Interpolation operations on images.
namespace noise
namespace print
namespace statistics

Classes

template<typename T>
class image
template<typename T>
class matrix
template<size_t Dimensions, typename T, bool Owner = true>
class nd_vector_impl
template<size_t Dimensions, typename T>
class nd_vector_impl<Dimensions, T, true>
template<typename T>
struct range
class transform_2d

Typedefs

using channel_list = std::vector<std::string>
template<typename T = float>
using color = nd_vector<T, 1>
template<typename T = float>
using pixel_view = nd_span<T, 1>
template<typename T = float>
using column_view = nd_vector<T, 2>
template<typename T, size_t Dimensions>
using nd_span = nd_vector_impl<Dimensions, T, false>
template<typename T, size_t Dimensions>
using nd_vector = nd_vector_impl<Dimensions, T, true>

Functions

template<typename T, typename Interpolation = interpolation::bilinear<T>, typename BlendFunction = blend_function::overlay<T>>
void merge(image<T>& a, image<T> const& b, transform_2d tx)
Copy values from image b, transformed by tx, into image a.
template<typename T>
auto operator<<(std::ostream& os, color<T> const& pxl) -> std::ostream&
template<typename T>
auto operator<<(std::ostream& os, pixel_view<T> const& pxl) -> std::ostream&
template<typename T>
auto transpose(image<T> const& img) -> image<T>
template<typename T>
auto load_image(char const* filename, const OIIO::ImageSpec* config = nullptr, bool ensure_alpha = false) -> image<T>
template<typename T>
auto write_image(char const* filename, image<T> const& data, OIIO::TypeDesc const& format = helpers::type_to_typedesc<T>()) -> bool
template<typename T, bool Throws = true>
auto invert(matrix<T> m) -> matrix<T>
Invert matrix m.
auto translate(float x, float y) -> transform_2d
auto rotate(float angle) -> transform_2d
auto scale(float x, float y) -> transform_2d

Variables

const int NO_ALPHA
Symbolic alpha channel index signifying the absence of opacity data.
const int DISABLE_ALPHA_DEDUCTION
Symbolic alpha channel index used to disable automatic detection of the alpha channel where applicable.

Typedef documentation

using spice::channel_list = std::vector<std::string>

Alias for convenience and forwards compatibility (channel_list might pack much more information in the future: channel to index mapping etc...).

template<typename T = float>
using spice::color = nd_vector<T, 1>

Represents a color. Type alias for convenience and forwards compatibility.

template<typename T = float>
using spice::pixel_view = nd_span<T, 1>

Refers to a single pixel in a spice::image. Note that this class has no information about the size of the image it is referring to and thus cannot perform bounds checking. Use image::at for that.

template<typename T = float>
using spice::column_view = nd_vector<T, 2>

Refers to a column of pixel data in a spice::image. Note that this class has no information about the size of the image it is referring to and thus cannot perform bounds checking. Use image::at for that.

template<typename T, size_t Dimensions>
using spice::nd_span = nd_vector_impl<Dimensions, T, false>

Non-owning nd_vector_impl providing a view over a slice of an nd_vector. Can also be used to wrap a raw pointer representing the start of a multidimensional buffer.

template<typename T, size_t Dimensions>
using spice::nd_vector = nd_vector_impl<Dimensions, T, true>

Owning nd_vector_impl managing its own buffer.

Function documentation

template<typename T, typename Interpolation = interpolation::bilinear<T>, typename BlendFunction = blend_function::overlay<T>>
void spice::merge(image<T>& a, image<T> const& b, transform_2d tx)

Copy values from image b, transformed by tx, into image a.

Template parameters
T
Interpolation The interpolation function type
BlendFunction The blend function type
Parameters
a the destination image
b the source image
tx the transformation to be applied to image b

template<typename T>
std::ostream& spice::operator<<(std::ostream& os, color<T> const& pxl)

Specialized formatter for spice::color.

template<typename T>
std::ostream& spice::operator<<(std::ostream& os, pixel_view<T> const& pxl)

Specialized formatter for spice::pixel_view.

template<typename T>
image<T> spice::transpose(image<T> const& img)

Parameters
img The image to be rotated
Returns a transposed copy of the image

Transposes the image pixel-wise

template<typename T>
image<T> spice::load_image(char const* filename, const OIIO::ImageSpec* config = nullptr, bool ensure_alpha = false)

Parameters
filename The path on disk relative to the current working directory
config file format specific parameters in the form of an ImageSpec configuration that will be handed through to OIIO
ensure_alpha if this is true, load_image will add an alpha channel (labelled "A") if none is present in the source image.
Returns An image object representing the file contents

Loads an image from disk and returns a representation of the indicated data type. All conversions are handled internally by OIIO. If the image could not be read, an empty image is returned (size 0x0x0).

template<typename T>
bool spice::write_image(char const* filename, image<T> const& data, OIIO::TypeDesc const& format = helpers::type_to_typedesc<T>())

Parameters
filename The path to write to relative to the current working directory
data The image to save to disk
format The data format the file should be written with
Returns true if the image was successfully written, false if an error occurred.

Writes an image to a file at the specified location.

template<typename T, bool Throws = true>
matrix<T> spice::invert(matrix<T> m)

Invert matrix m.

Template parameters
T
Throws set this to false to presume invertibility
Parameters
m the matrix to invert
Returns matrix<T>
Exceptions
std::domain_error if the matrix is not invertible. Only applicable if template aregument Throws is set to true.

transform_2d spice::translate(float x, float y)

Creates a transform_2d describing the translation by the given vector.

transform_2d spice::rotate(float angle)

Creates a transform_2d describing the rotation by the given angle.

transform_2d spice::scale(float x, float y)

Creates a transform_2d describing the scale by the given factors.