.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/virtual_imaging/creating_virtual_images_from_vectors.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_examples_virtual_imaging_creating_virtual_images_from_vectors.py: ==================================== Creating Virtual Images from Vectors ==================================== In this example we will show how to create virtual images from vectors. We will use the `find_peaks` method to find the vectors and then use the `get_unique_vectors` method to reduce the number of vectors to a unique set of vectors. We can convert the unique vectors to regions of interest (ROIs) objects using the `to_roi` method and then use the `get_virtual_image` method to create the virtual images. This method is flexible and any type of ROI defined in hyperspy can be used to create virtual images. We also included the include_labels argument to the `to_roi` method which will also return the labels for each ROI for use plotting on the signal. .. GENERATED FROM PYTHON SOURCE LINES 18-36 .. code-block:: Python import pyxem as pxm c = pxm.data.dummy_data.get_cbed_signal() pks = c.template_match_disk(5, subtract_min=False).find_peaks( interactive=False, threshold_abs=0.8, min_distance=6 ) dv = pxm.signals.DiffractionVectors.from_peaks(pks) vectors = dv.get_unique_vectors() roi, texts = vectors.to_roi(radius=5, include_labels=True, sizes=3, facecolor="black") c.plot() for r in roi: r.add_widget(c, axes=(2, 3)) vdfs = c.get_virtual_image(roi) c.add_marker(texts) .. rst-class:: sphx-glr-horizontal * .. image-sg:: /examples/virtual_imaging/images/sphx_glr_creating_virtual_images_from_vectors_001.png :alt: creating virtual images from vectors :srcset: /examples/virtual_imaging/images/sphx_glr_creating_virtual_images_from_vectors_001.png :class: sphx-glr-multi-img * .. image-sg:: /examples/virtual_imaging/images/sphx_glr_creating_virtual_images_from_vectors_002.png :alt: Signal :srcset: /examples/virtual_imaging/images/sphx_glr_creating_virtual_images_from_vectors_002.png :class: sphx-glr-multi-img .. rst-class:: sphx-glr-script-out .. code-block:: none 0%| | 0/33 [00:00` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: creating_virtual_images_from_vectors.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: creating_virtual_images_from_vectors.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_