.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/processing/circular_hough_transform.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_processing_circular_hough_transform.py: Circular Hough Transform Peak Finding ===================================== The Circular Hough Transform is a method to detect circular features in an image. It can be used to detect rings (or disks) in the diffraction pattern. For strain mapping there is some evidence that the Circular Hough transform is more accurate than typical template matching and can provide subpixel accuracy. That being said, the Windowed Template Matching that pyxem uses is quite robust, (both to noise and in homogeniety in the diffraction disks) although a complete comparison hasn't been fully studied. .. GENERATED FROM PYTHON SOURCE LINES 16-17 Making a Dummy Dataset .. GENERATED FROM PYTHON SOURCE LINES 17-26 .. code-block:: Python import hyperspy.api as hs import pyxem as pxm from skimage.transform import hough_circle from skimage.feature import canny import numpy as np s = pxm.data.tilt_boundary_data(correct_pivot_point=True) .. GENERATED FROM PYTHON SOURCE LINES 27-31 Canny Filter --------------------- First we have to apply a Canny filter to the dataset to get a binary image of the outlines of the disks. This is basically a 1st diriviative in reciporical space .. GENERATED FROM PYTHON SOURCE LINES 31-43 .. code-block:: Python # Filter the image with a Canny filter. canny_img = s.map( canny, sigma=2, low_threshold=0.6, high_threshold=0.8, inplace=False, use_quantiles=True, ) canny_img.plot() # Plotting canny filtered image with outlines .. rst-class:: sphx-glr-horizontal * .. image-sg:: /examples/processing/images/sphx_glr_circular_hough_transform_001.png :alt: circular hough transform :srcset: /examples/processing/images/sphx_glr_circular_hough_transform_001.png :class: sphx-glr-multi-img * .. image-sg:: /examples/processing/images/sphx_glr_circular_hough_transform_002.png :alt: Signal :srcset: /examples/processing/images/sphx_glr_circular_hough_transform_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: circular_hough_transform.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: circular_hough_transform.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_