通常來說,咱們圖像的興趣點都有邊緣(edges)和角點(corners),這是兩種比較常見的興趣點類型,咱們如今來擼擼代碼,看一個提取美女興趣點的例子:spa
import numpy as np from skimage.feature import corner_harris, corner_peaks from skimage.color import rgb2gray import matplotlib.pyplot as plt import skimage.io as io from skimage.exposure import equalize_hist def show_corners(corners, image): fig = plt.figure() plt.gray() plt.imshow(image) y_corner, x_corner = zip(*corners) plt.plot(x_corner, y_corner, 'or') plt.xlim(0, image.shape[1]) plt.ylim(image.shape[0], 0) fig.set_size_inches(np.array(fig.get_size_inches()) * 2) plt.show() mandrill = io.imread('112.png.') mandrill = equalize_hist(rgb2gray(mandrill)) corners = corner_peaks(corner_harris(mandrill), min_distance=1) show_corners(corners, mandrill)
最後咱們顯示獲得的結果紅色部分就是咱們的興趣點所在位置:
code
雖然結果沒有深色圖像的好,但也是能夠很明顯地看到興趣點被咱們提取出來了。blog