# 在绘图中显示中文字体,而非乱码
from pylab import mpl
mpl.rcParams["font.sans-serif"] = ["SimHei"]
import cv2
import matplotlib.pyplot as plt
import numpy as np
import skimage.feature
import skimage.segmentation
import skimage.data
from pylab import mpl
mpl.rcParams['axes.unicode_minus'] = False
根据本章所学内容,选取两类若干张图片(例如5张猫和5张狗的图片),对其抽取一些特征,并简要分析两类图像之间差异较大的特征,例如猫和狗之间差异较大的特征。根据本章所学内容,选取两类若干张图片(例如5张猫和5张狗的图片),对其抽取一些特征,并简要分析两类图像之间差异较大的特征,例如猫和狗之间差异较大的特征。
#SIFT尺度不变特征变换方法
def detect_sift_features(image_path):
sift = cv2.SIFT_create()
img = cv2.imread(image_path, cv2.IMREAD_GRAYSCALE)
keypoints, descriptors = sift.detectAndCompute(img, None)
img_with_keypoints = cv2.drawKeypoints(img, keypoints, None)
return img_with_keypoints
a=[你的图片,你的图片,你的图片,你的图片]
b=0
fig, axs = plt.subplots(len(a),1 , figsize=(60, 40))
for i in a:
img_with_keypoints = detect_sift_features(i)
img_with_keypoints = cv2.cvtColor(img_with_keypoints, cv2.COLOR_BGR2RGB)
axs[b].imshow(img_with_keypoints)
axs[b].set_title('SIFT Features Image {}'.format(b+1))
axs[b].axis('off')
b+=1
plt.show()
差异较大的特征请根据你所使用的图片而特异性描述