Textures

Back to PastelGfx

A texture is a pair ''(g, h)'', where ''g'' is a continuous image, and ''h'' is a function ''RR^n -> RR'', called a detail filter.

Theory

Continuous image and texture

A continuous image is a continuous function ''RR^n -> V'', where ''V'' is a vector space over the reals.

Given a texture T = (g, h), its texture sampler is a function

''f_T : RR^{n xx n} xx RR^n -> V : f_T(M, x) = ((h circ M^-1) ox g)(x)'',

where ''ox'' denotes convolution, and ''circ'' denotes composition.

Discrete image and reconstruction

An image (or a discrete image) is a function ''ZZ^n -> V'' where ''V'' is a vector space over the reals. Given an image ''d'', if we assume that it has been obtained by sampling some band-limited continuous image ''I'', it can be shown that

''I = D ox s'',

where

''D : RR^n -> V : D = sum {delta_x * d(x) | x in ZZ^n}''

''s : RR^n -> RR : s(x) = prod_{i = 1}^n text(sinc)(x_i)''

where

''delta_x'' is the delta distribution in ''RR^n'' centered on ''x''.

The ''s'' is called a reconstruction filter, and as an approximation can be replaced by other low-pass filters, particularly with those having bounded support. The process of forming I from D (or d) is called reconstruction.

Practice

Pastel provides the abstract Texture class template to model textures in ''RR^n''. It is defined by:

template <typename Type, int N = 2>
class Texture
    : public ReferenceCounted
{
public:
    typedef CountedPtr<Texture> Ptr;
    typedef CountedPtr<const Texture> ConstPtr;
    typedef Type Element;

    virtual ~Texture() {}

    virtual Type operator()(
        const Vector<real, N>& p,
        const Matrix<real, N, N>& m) const = 0;

    virtual std::string name() const = 0;
};

where Type is a vector, such as Color, or real32, which defines the ''V'' in the definition, and N defines the dimensionality. Its abstract interface provides access to a texture sampler.

Types of textures

Pastel provides three types of concrete, predefined texture classes:

Visual quality of reconstruction filters

The ideal reconstruction filter most often can not be used for computational purposes because it has an infinite support. Therefore, it is approximated by finite-support filters. However, for images it is the case that the visual quality which results from reconstructing with the ideal filter is very bad (the reconstruction can be done in restricted cases by using the Fourier transform): it exhibits so called ringing where each discontinuity is echoed to its neighborhood. Therefore finite-support filters are not used just for necessity but also for better-looking reconstructions.

Learn more

Distortion textures

Image-based textures

Modifier textures

Synthetic textures

Files

An aggregate file for textures

textures.h

Testing for textures

test_texture.cpp

Texture class

An abstract class for textures

texture.h