.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples\ExtendedFields\plot_extendedfield.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_ExtendedFields_plot_extendedfield.py: ======================================== Textured images with spectral variations ======================================== .. codeauthor:: Frédéric Richard In this example, we show how to simulate a field having a topothesy whose values may vary depending both on the direction and the amplitude. .. note:: The obtained simulation relates to a model with a semi-variogram of the form: .. math:: v(x) = \int_{\mathbb{R}^2} \vert e^{i\langle x, w \rangle} - 1 \vert^2 \tau(w) \vert w \vert^{2H-2} dw. where, contrarily to usual AFBF, the value :math:`\tau(w)` does not only depend on the direction :math:`\arg(w)` of :math:`w`, but also on its amplitude :math:`\vert w \vert`. .. GENERATED FROM PYTHON SOURCE LINES 62-115 .. rst-class:: sphx-glr-horizontal * .. image:: /auto_examples/ExtendedFields/images/sphx_glr_plot_extendedfield_001.png :alt: Extended field. :class: sphx-glr-multi-img * .. image:: /auto_examples/ExtendedFields/images/sphx_glr_plot_extendedfield_002.png :alt: Generalized topothesy :class: sphx-glr-multi-img .. code-block:: default import numpy as np from afbf import perfunction, tbfield from matplotlib import pyplot as plt nb_angle = 4 # Number of angle subdivisions. nb_spect = 3 # Number of spectrum subdivisions. # Definition of a fractional Brownian field. Z = tbfield('fbf') Z.hurst.ChangeParameters( np.array([0.1]) ) Z.NormalizeModel() Z.ExtendTopothesy(nb_spect, nb_angle) for j in range(nb_spect): # Set uniformly spaced interval for the step functions. Z.gtopo[j].SetUniformStepInterval() np.random.seed(1) z = Z.Simulate() z.name = 'Extended field.' z.Display(1) # Visualize the generalized topothesy. gtopo = perfunction('step-smooth', nb_spect) # Topothesy at an angle. gtopo.SetUniformStepInterval() z = np.linspace(-np.pi / 2, np.pi / 2, 1000) im = np.zeros((z.size, z.size)) for i in range(z.size): # Setting parameters of the topothesy at angle z[i] for j in range(nb_spect): Z.gtopo[j].Evaluate(np.array([z[i]])) # The value of Z.gtopo[j] at z[i] gives the values of the jth # parameter of the generalized topothesy at the ith angle. gtopo.fparam[0, j] = Z.gtopo[j].values[0, 0] # Evaluate the topothesy at angle z[i] gtopo.Evaluate(z) im[i, :] = gtopo.values.reshape((1, z.size)) plt.figure(2) plt.imshow(im, cmap='gray') plt.title('Generalized topothesy') plt.xlabel(r'Amplitude $\rho$') plt.ylabel(r'Angle $\varphi$') loc, lab = plt.yticks( np.linspace(0, z.size, 5), [r'$-\pi/2$', r'$-\pi/4$', r'$0$', r'$\pi/4$', r'$\pi/2$'] ) .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 2 minutes 31.324 seconds) .. _sphx_glr_download_auto_examples_ExtendedFields_plot_extendedfield.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_extendedfield.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_extendedfield.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_