python读取图像时遇到的奇怪问题
2017-02-21 00:32
471 查看
最近用python载入自己的图像数据时,遇到了一个奇怪的问题。
我的程序如下,想要把一张图片载入到data中:
结果在显示结果时,图片莫名其妙变成了下图所示
弄了好久,查了imshow的手册,终于搞明白了
If your grayscale image is single or double, the default display range
is [0 1]. If your image’s data range is much larger or smaller than
the default display range, you may need to experiment with setting the
display range to see features in the image that would not be visible
using the default display range. For all grayscale images having
integer types, the default display range is [intmin(class(I))
intmax(class(I))].
搞了半天原来是imshow搞鬼
完美解决
我的程序如下,想要把一张图片载入到data中:
from PIL import Image from scipy.misc import imread, imresize data = np.zeros((10,278,278,3)) img = Image.open('kitten.JPEG') arr = np.array(img) arr = imresize(arr, (278, 278)) data[0,:,:,:] = arr plt.subplot(1,2,1) plt.imshow(arr) plt.subplot(1,2,2) plt.imshow(data[0,:,:,:])
结果在显示结果时,图片莫名其妙变成了下图所示
弄了好久,查了imshow的手册,终于搞明白了
If your grayscale image is single or double, the default display range
is [0 1]. If your image’s data range is much larger or smaller than
the default display range, you may need to experiment with setting the
display range to see features in the image that would not be visible
using the default display range. For all grayscale images having
integer types, the default display range is [intmin(class(I))
intmax(class(I))].
搞了半天原来是imshow搞鬼
plt.imshow(data[0,:,:,:].astype('uint8'))
完美解决
相关文章推荐
- ITK+VTK+QT 读取DICOM序列图像遇到的问题(1)
- python读取excel文件遇到的问题
- python使用过程中遇到的各种奇怪的问题
- rood-Python 3读取.CSV文件遇到的编码问题
- python 调用图像处理类库PIL 时遇到的问题
- 解决Python2.7画三维图像遇到的编码问题
- Python读取Excel文件遇到的编码问题(pycharm)
- PHP file函数读取文件遇到<***>时的奇怪问题
- python读取dat文件时遇到16进制转化成10进制问题
- python读取csv中所遇到的中文编码问题
- /python课程设计/读取文件遇到的问题
- Python3.5+OpenCV3.2读取图像问题
- python使用变量作为默认参数时所遇到的奇怪问题
- python file.write()遇到奇怪问题
- python读取文本文件URL列表遇到的问题和加载中数据获取问题
- PHP file函数读取文件遇到<***>时的奇怪问题
- python读取excel数据,遇到路径问题解决方案
- 今天遇到了一个奇怪问题
- 日期格式化的时候遇到的奇怪的问题
- MOSS2007使用中遇到的奇怪问题