Note
Click here to download the full example code
Anisotropic textures from field deformations¶
Code author: Frédéric Richard <frederic.richard_at_univ-amu.fr>
In this example, we show how to simulate anisotropic textures from the deformation of an isotropic random field.
Given a fractional Brownian field \(X\) and an affine transformation \(T\), the transformed field is defined by composition
\[Y = X \circ T.\]
The anisotropic texture is obtained by simulation of \(Y\).
Note
This approach could also be applied to more generic afbf.
See also
Deformed fields have been of interest in several studies; see for instance [15].
import numpy as np
from afbf import coordinates, tbfield
# Define a fractional Brownian field.
X = tbfield()
# Define an affine transform.
T = np.array([[1, 0], [2, 1]], dtype=int)
# Define a uniform grid.
coord = coordinates(256)
# Simulate the field without transformation.
n0 = int(np.random.randn())
np.random.seed(n0)
y0 = X.Simulate()
# Apply the coordinate transform to the grid.
coord.ApplyAffineTransform(T)
# Simulate the field with transformation (with a same seed).
np.random.seed(n0)
y = X.Simulate(coord)
# Display of simulations.
y.name = 'Simulation of the deformed field.'
y.Display(1)
y0.name = 'Simulation of the undeformed field.'
y0.Display(2)
Total running time of the script: ( 0 minutes 16.995 seconds)