.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_gallery/mesh/image_surface.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr__gallery_mesh_image_surface.py: Image surface ============= Example showing an image as a surface. .. GENERATED FROM PYTHON SOURCE LINES 7-37 .. image-sg:: /_gallery/mesh/images/sphx_glr_image_surface_001.webp :alt: image surface :srcset: /_gallery/mesh/images/sphx_glr_image_surface_001.webp :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none /opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/site-packages/pygfx/objects/_ruler.py:400: RuntimeWarning: divide by zero encountered in divide screen_full = (ndc_full[:, :2] / ndc_full[:, 3:4]) * half_canvas_size /opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/site-packages/pygfx/objects/_ruler.py:400: RuntimeWarning: invalid value encountered in divide screen_full = (ndc_full[:, :2] / ndc_full[:, 3:4]) * half_canvas_size /opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/site-packages/pygfx/objects/_ruler.py:412: RuntimeWarning: invalid value encountered in divide screen_sel = (ndc_sel[:, :2] / ndc_sel[:, 3:4]) * half_canvas_size /home/runner/work/fastplotlib/fastplotlib/fastplotlib/graphics/features/_base.py:18: UserWarning: casting float64 array to float32 warn(f"casting {array.dtype} array to float32") | .. code-block:: Python # test_example = true import imageio.v3 as iio import fastplotlib as fpl import scipy.ndimage im = iio.imread("imageio:astronaut.png") figure = fpl.Figure(size=(700, 560), cameras="3d", controller_types="orbit") # Create the height map from the image z = im.mean(axis=2) z = scipy.ndimage.gaussian_filter(z, 5) # 2nd arg is sigma mesh = figure[0, 0].add_surface(z, cmap=im) mesh.world_object.local.scale_y = -1 figure[0, 0].axes.grids.xy.visible = True figure[0, 0].camera.show_object(mesh.world_object, (1, 2, -1), up=(0, 0, 1)) figure.show() # NOTE: fpl.loop.run() should not be used for interactive sessions # See the "JupyterLab and IPython" section in the user guide if __name__ == "__main__": print(__doc__) fpl.loop.run() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.347 seconds) .. _sphx_glr_download__gallery_mesh_image_surface.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: image_surface.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: image_surface.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_