.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/plot_tif_image.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_auto_examples_plot_tif_image.py: Tif Image Processing ==================== This example opens a Zeiss TIF image, enhances the gray values, adds a scale bar, and displays the processed image. .. GENERATED FROM PYTHON SOURCE LINES 8-19 .. code-block:: Python from pathlib import Path import matplotlib.pyplot as plt import micromechanics from micromechanics.tif import Tif repository_root = Path(micromechanics.__file__).resolve().parents[1] file_name = repository_root / "examples" / "Zeiss" / "Zeiss.tif" .. GENERATED FROM PYTHON SOURCE LINES 20-23 ``Tif`` reads the Zeiss metadata, image width, and pixel size directly from the file. The resulting object keeps both the image and metadata needed for scale bar placement. .. GENERATED FROM PYTHON SOURCE LINES 23-26 .. code-block:: Python image = Tif(str(file_name)) .. GENERATED FROM PYTHON SOURCE LINES 27-29 Enhance the gray-value contrast and add a scale bar using the calibrated pixel size. These operations modify ``image.image`` in memory. .. GENERATED FROM PYTHON SOURCE LINES 29-33 .. code-block:: Python image.enhance() image.addScaleBar() .. GENERATED FROM PYTHON SOURCE LINES 34-36 Display the processed image without axes so the result resembles an exported SEM micrograph. .. GENERATED FROM PYTHON SOURCE LINES 36-39 .. code-block:: Python plt.imshow(image.image, cmap="gray") plt.axis("off") .. image-sg:: /auto_examples/images/sphx_glr_plot_tif_image_001.png :alt: plot tif image :srcset: /auto_examples/images/sphx_glr_plot_tif_image_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none (np.float64(-0.5), np.float64(1023.5), np.float64(767.5), np.float64(-0.5)) .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.128 seconds) .. _sphx_glr_download_auto_examples_plot_tif_image.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_tif_image.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_tif_image.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_tif_image.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_