我正在编写此代码以仅针对图像的每个补丁计算归一化直方图。但是最后一个补丁没有空白。
from skimage.io import imread
from matplotlib import pyplot as plt
def patches(array, rows, cols):
h, w = array.shape
return (array.reshape(h//rows, rows, -1, cols)
.swapaxes(1,2)
.reshape(-1, rows, cols))
img= imread('example.bmp')
b = patches(img,256,256)
for i in range(1, o+1):
plt.hist(b[i-1].ravel(),256,[0,256])
plt.subplot(v, v, i)
plt.show()