提取图像兴趣点

一般来讲,我们图像的兴趣点都有边缘(edges)和角点(corners),这是两种比较常见的兴趣点类型,我们现在来撸撸代码,看一个提取美女兴趣点的例子:

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)

最后我们显示得到的结果红色部分就是我们的兴趣点所在位置:

虽然结果没有深色图像的好,但也是可以很明显地看到兴趣点被我们提取出来了。

posted @ 2019-07-15 15:08  Geeksongs  阅读(799)  评论(0编辑  收藏  举报

Coded by Geeksongs on Linux

All rights reserved, no one is allowed to pirate or use the document for other purposes.