首页 > 解决方案 > 为什么最后一个子图中没有图表?

问题描述

我正在编写此代码来单独计算图像的每个补丁的归一化直方图。但是最后一个补丁有一个空图。

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()

在此处输入图像描述

标签: python-3.xmatplotlib

解决方案


推荐阅读