.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/features_detection/plot_corner.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 or to run this example in your browser via Binder .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_features_detection_plot_corner.py: ================ Corner detection ================ Detect corner points using the Harris corner detector and determine the subpixel position of corners ([1]_, [2]_). .. [1] https://en.wikipedia.org/wiki/Corner_detection .. [2] https://en.wikipedia.org/wiki/Interest_point_detection .. GENERATED FROM PYTHON SOURCE LINES 13-42 .. image-sg:: /auto_examples/features_detection/images/sphx_glr_plot_corner_001.png :alt: plot corner :srcset: /auto_examples/features_detection/images/sphx_glr_plot_corner_001.png :class: sphx-glr-single-img .. code-block:: default from matplotlib import pyplot as plt from skimage import data from skimage.feature import corner_harris, corner_subpix, corner_peaks from skimage.transform import warp, AffineTransform from skimage.draw import ellipse # Sheared checkerboard tform = AffineTransform(scale=(1.3, 1.1), rotation=1, shear=0.7, translation=(110, 30)) image = warp(data.checkerboard()[:90, :90], tform.inverse, output_shape=(200, 310)) # Ellipse rr, cc = ellipse(160, 175, 10, 100) image[rr, cc] = 1 # Two squares image[30:80, 200:250] = 1 image[80:130, 250:300] = 1 coords = corner_peaks(corner_harris(image), min_distance=5, threshold_rel=0.02) coords_subpix = corner_subpix(image, coords, window_size=13) fig, ax = plt.subplots() ax.imshow(image, cmap=plt.cm.gray) ax.plot(coords[:, 1], coords[:, 0], color='cyan', marker='o', linestyle='None', markersize=6) ax.plot(coords_subpix[:, 1], coords_subpix[:, 0], '+r', markersize=15) ax.axis((0, 310, 200, 0)) plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.245 seconds) .. _sphx_glr_download_auto_examples_features_detection_plot_corner.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: binder-badge .. image:: images/binder_badge_logo.svg :target: https://mybinder.org/v2/gh/scikit-image/scikit-image/v0.22.x?filepath=notebooks/auto_examples/features_detection/plot_corner.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_corner.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_corner.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_