当读取低对比度图像时,它会自动采用以下示例:
In [1]: from PIL import Image
In [2]: import numpy as np
In [3]: import matplotlib.pyplot as plt
In [4]: img = Image.open('images/map.jpg')
In [5]: arr = np.asarray(img)
In [6]: plt.gray()
In [7]: plt.imshow(arr)
Out[7]: <matplotlib.image.AxesImage at 0x7f9c7e88f490>
In [8]: plt.show()
Input
large https://i.stack.imgur.com/HRYRV.png
绘图(没有任何变化,这是由 matplotlib 自动生成的。)
large https://i.stack.imgur.com/Vce3X.jpg
因为这个输入与没有修改任何内容的绘图不同。
我需要低对比度图像来实现对比度拉伸算法
读这本书amazon http://amzn.com/013168728X数字图像处理(Rafael C. Gonzalez、Richard E. Woods)
PS:matplotlib是转换自动的。我不需要。
如果您不希望颜色图自动缩放,您可以使用vmin
and vmax
设置您喜欢的范围,如下所示:
plt.imshow(arr, vmin=0, vmax=255)
当显示 numpy 数组时,matplotlib 只能自动知道实际输入数据的范围(而不是从中获取的范围),因此它需要完整的input范围将其映射到完整output范围。但是如果您知道输入数据的不同范围,您可以使用vmin
and vmax
来指定它。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)