import numpy as np import matplotlib.pyplot as plt def generate_random_matrix(rows, cols): matrix = np.random.randint(0, 10, size=(rows, cols)) # 生成范围为0-9的随机整数 return matrix.tolist() # 转换为普通的Python列表 x=generate_random_matrix(10,10) y=np.random.randint(0,256,size=(10,10)) print(y) plt.imshow(y,cmap='gray') # plt.xlim(0,20)#x轴范围设置 # ply. plt.colorbar() plt.show() print(len(x))
生成0-256的随机灰度图
于 2024-07-01 15:15:10 首次发布