.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/flim/plot_crop.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_flim_plot_crop.py: =============== Image cropping =============== By cropping unwanted outer areas can be removed from a CLSM image. The process usually consists of the removal of peripheral areas of an image to remove extraneous trash from the picture, to improve its framing, to change the aspect ratio. Cropping of CLSM images in tttrlib preserves the information contained in the associated photons, i.e., the micro time, the macro time, and the routing channel numbers. .. GENERATED FROM PYTHON SOURCE LINES 12-17 .. code-block:: Python from __future__ import print_function import tttrlib import numpy as np import pylab as plt .. GENERATED FROM PYTHON SOURCE LINES 18-19 Read data of the CLSM image and fill CLSM image with photon information. .. GENERATED FROM PYTHON SOURCE LINES 19-27 .. code-block:: Python data = tttrlib.TTTR('../../tttr-data/imaging/pq/ht3/crn_clv_img.ht3') settings = { "channels": [0, 1], "fill": True, } image = tttrlib.CLSMImage(data, **settings) .. GENERATED FROM PYTHON SOURCE LINES 28-29 The CLSM image of this example has 40 frames and 256x256 pixles. .. GENERATED FROM PYTHON SOURCE LINES 29-34 .. code-block:: Python image.shape == (40, 256, 256) im = image.intensity.sum(axis=0) plt.imshow(im) plt.show() .. image-sg:: /auto_examples/flim/images/sphx_glr_plot_crop_001.png :alt: plot crop :srcset: /auto_examples/flim/images/sphx_glr_plot_crop_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 35-37 The CLSM image is cropped by providing the frame index bounds amoung the shape of the new CLSM image. .. GENERATED FROM PYTHON SOURCE LINES 37-45 .. code-block:: Python frame_start = 5 frame_stop = 20 image.crop(frame_start, frame_stop, 0, 128, 0, 96) image.shape == (15, 128, 96) im = image.intensity.sum(axis=0) plt.imshow(im) plt.show() .. image-sg:: /auto_examples/flim/images/sphx_glr_plot_crop_002.png :alt: plot crop :srcset: /auto_examples/flim/images/sphx_glr_plot_crop_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.825 seconds) .. _sphx_glr_download_auto_examples_flim_plot_crop.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_crop.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_crop.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_