且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

matplotlib中的低对比度图像(对比度拉伸)问题

更新时间:2023-09-03 16:10:28

如果不希望自动缩放颜色图,则可以使用vminvmax设置所需的范围,如下所示:

If you do not want the automatic scaling of the colormap, you can use vmin and vmax to set the range you prefer, like this:

plt.imshow(arr, vmin=0, vmax=255)

在显示一个numpy数组时,matplotlib只能自动知道实际输入数据的范围(而不是它取自的范围),因此它需要完整的 input 范围并将其映射到完整的输出范围.但是,如果您知道输入数据的不同范围,则可以使用vminvmax进行指定.

When showing a numpy array, matplotlib can only automatically know the range of the actual input data (not the range it was taken from), so it takes the full input range an maps it to the full output range. But if you know a different range of the input data, you can use vmin and vmax to specify it.