import cv2
import numpy as np
import PIL
from matplotlib import pyplot
img1 = cv2.imread('D:/MyProject/SeniorProject/Mushroom Pictures/train/Class A/IMG_9604.jpg')
img2 = cv2.imread('D:/MyProject/SeniorProject/Mushroom Pictures/train/Class A/IMG_9605.jpg')
img1_hsv = cv2.cvtColor(img1,cv2.COLOR_BGR2HSV)
img2_hsv = cv2.cvtColor(img2,cv2.COLOR_BGR2HSV)
h_bins = 18
s_bins = 32
histSize = [h_bins, s_bins]
h_ranges = [0,180]
s_ranges = [0,256]
ranges = h_ranges + s_ranges
channels = [0,1]
hist1c = cv2.calcHist([img1_hsv],channels,None,histSize,ranges,accumulate=False)
hist2c = cv2.calcHist([img2_hsv],[0],None,[180],[0,180],accumulate=False)
pyplot.imshow(hist1c,interpolation = 'nearest')
pyplot.show()
我得到了作为AxeImage的hs直方图,但我想转换为数组以应用于机器学习模型训练输入。你能帮我吗。 为什么我没有使用hist1c和hist2c是模型的输入,因为它不是单独的H-s,每个直径只保存在H箱中。 非常感谢:) 大的
重新保存直方图数据:
np.array(hist1c).重塑(-1,yourDataSize)
相关问题 更多 >
编程相关推荐