首页 > 技术文章 > Python实现二维数组输出为图片

xiaochouk 2022-03-13 10:38 原文

 

 

import matplotlib.pyplot as pyplot 
pyplot.imshow(binary_mask)
pyplot.show()

 binary_mask显示为:

array([[0, 0, 0, ..., 0, 0, 0],
[0, 1, 0, ..., 0, 0, 0],
[0, 0, 1, ..., 0, 0, 0],
...,
[0, 1, 0, ..., 0, 1, 0],
[0, 0, 0, ..., 0, 0, 1],
[0, 1, 0, ..., 0, 1, 0]], dtype=uint8)

图片显示为:

 

推荐阅读