.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples\RelatedFields\plot_deformfield.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_RelatedFields_plot_deformfield.py: ============================================ Anisotropic textures from field deformations ============================================ .. codeauthor:: Frédéric Richard In this example, we show how to simulate :term:`anisotropic` textures from the deformation of an :term:`isotropic` random field. Given a fractional Brownian field :math:`X` and an affine transformation :math:`T`, the transformed field is defined by composition .. math:: Y = X \circ T. The anisotropic texture is obtained by simulation of :math:`Y`. .. note:: This approach could also be applied to more generic afbf. .. seealso:: Deformed fields have been of interest in several studies; see for instance :cite:p:`Guyon2000`. .. GENERATED FROM PYTHON SOURCE LINES 65-92 .. rst-class:: sphx-glr-horizontal * .. image:: /auto_examples/RelatedFields/images/sphx_glr_plot_deformfield_001.png :alt: Simulation of the deformed field. :class: sphx-glr-multi-img * .. image:: /auto_examples/RelatedFields/images/sphx_glr_plot_deformfield_002.png :alt: Simulation of the undeformed field. :class: sphx-glr-multi-img .. code-block:: default 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) .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 16.995 seconds) .. _sphx_glr_download_auto_examples_RelatedFields_plot_deformfield.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_deformfield.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_deformfield.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_