.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_tutorials/tutorials/image_class.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_tutorials_tutorials_image_class.py: ASPIRE Image Class ================== This tutorial demonstrates some methods of the ASPIRE ``Image`` class .. GENERATED FROM PYTHON SOURCE LINES 7-19 .. code-block:: Python import os import numpy as np from aspire.image import Image from aspire.operators import CTFFilter file_path = os.path.join(os.path.dirname(os.getcwd()), "data", "monuments.npy") img_data = np.load(file_path) print(img_data.shape, img_data.dtype) .. rst-class:: sphx-glr-script-out .. code-block:: none (4, 600, 600) uint8 .. GENERATED FROM PYTHON SOURCE LINES 20-22 Create an Image Instance ------------------------ .. GENERATED FROM PYTHON SOURCE LINES 22-27 .. code-block:: Python # Create an ASPIRE Image instance from the data # We'll tell it to convert to floating point data as well. im = Image(img_data, dtype=np.float64) .. GENERATED FROM PYTHON SOURCE LINES 28-30 Plot the Image Stack -------------------- .. GENERATED FROM PYTHON SOURCE LINES 30-34 .. code-block:: Python # Plot the Image stack im.show() .. image-sg:: /auto_tutorials/tutorials/images/sphx_glr_image_class_001.png :alt: image class :srcset: /auto_tutorials/tutorials/images/sphx_glr_image_class_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 35-37 Apply a Uniform Shift --------------------- .. GENERATED FROM PYTHON SOURCE LINES 37-42 .. code-block:: Python # Apply a single shift to each image. shifts = np.array([100, 30]) im.shift(shifts).show() .. image-sg:: /auto_tutorials/tutorials/images/sphx_glr_image_class_002.png :alt: image class :srcset: /auto_tutorials/tutorials/images/sphx_glr_image_class_002.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 43-45 Apply Image-wise Shifts ----------------------- .. GENERATED FROM PYTHON SOURCE LINES 45-50 .. code-block:: Python # Or apply shifts corresponding to to each image. shifts = np.array([[300 * i, 100 * i] for i in range(1, im.n_images + 1)]) im.shift(shifts).show() .. image-sg:: /auto_tutorials/tutorials/images/sphx_glr_image_class_003.png :alt: image class :srcset: /auto_tutorials/tutorials/images/sphx_glr_image_class_003.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 51-53 Downsampling ------------ .. GENERATED FROM PYTHON SOURCE LINES 53-56 .. code-block:: Python im.downsample(80).show() .. image-sg:: /auto_tutorials/tutorials/images/sphx_glr_image_class_004.png :alt: image class :srcset: /auto_tutorials/tutorials/images/sphx_glr_image_class_004.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 57-59 CTF Filter ---------- .. GENERATED FROM PYTHON SOURCE LINES 59-63 .. code-block:: Python # pixel_size/defous_u/defocus_v in angstrom, voltage in kV filter = CTFFilter(pixel_size=1, voltage=100, defocus_u=1500, defocus_v=2000) im.filter(filter).show() .. image-sg:: /auto_tutorials/tutorials/images/sphx_glr_image_class_005.png :alt: image class :srcset: /auto_tutorials/tutorials/images/sphx_glr_image_class_005.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 2.189 seconds) .. _sphx_glr_download_auto_tutorials_tutorials_image_class.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: image_class.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: image_class.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: image_class.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_