<jupyter_start><jupyter_text>> This is one of the 100 recipes of the [IPython Cookbook](http://ipython-books.github.io/), the definitive guide to high-performance scientific computing and data science in Python.  11.4. Finding points of interest in an image You need to download the *Child* dataset on the book's website. (http://ipython-books.github.io) 1. Let's import the packages.<jupyter_code>import numpy as np
import matplotlib.pyplot as plt
import skimage
import skimage.feature as sf
import matplotlib as mpl
%matplotlib inline<jupyter_output><empty_output><jupyter_text>2. We create a function to display a colored or grayscale image.<jupyter_code>def show(img, cmap=None):
    cmap = cmap or plt.cm.gray
    plt.figure(figsize=(4,2));
    plt.imshow(img, cmap=cmap);
    plt.axis('off');<jupyter_output><empty_output><jupyter_text>3. We load an image.<jupyter_code>img = plt.imread('data/pic2.jpg')
show(img)<jupyter_output><empty_output><jupyter_text>4. We find salient points in the image with the Harris corner method. The first step consists in computing the **Harris corner measure response image** with the `corner_harris` function (we will explain this measure in *How it works...*).<jupyter_code>corners = sf.corner_harris(img[:,:,0])
show(corners)<jupyter_output><empty_output><jupyter_text>We see that the patterns in the child's coat are particularly well detected by this algorithm. 5. The next step consists in detecting corners from this measure image, using the `corner_peaks` function.<jupyter_code>peaks = sf.corner_peaks(corners)
show(img)
plt.plot(peaks[:,1], peaks[:,0], 'or', ms=4);<jupyter_output><empty_output><jupyter_text>6. Finally, we create a box around the corner points to define our region of interest.<jupyter_code>ymin, xmin = peaks.min(axis=0)
ymax, xmax = peaks.max(axis=0)
w, h = xmax-xmin, ymax-ymin
k = .25
xmin -= k*w
xmax += k*w
ymin -= k*h
ymax += k*h
show(img[ymin:ymax,xmin:xmax])<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11558044806517312, 'fraction_numerical': 0.011710794297352342, 'mean_word_length': 5.822916666666667, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '356654', 'license': 'BSD-2-Clause', 'n_tokens_mistral': 695, 'n_tokens_neox': 670, 'n_words': 206, 'path': 'notebooks/chapter11_image/04_interest.ipynb', 'repo_name': 'khanparwaz/PythonProjects', 'size': '1964'}