使用PIL可视化WISE数据库M1星云FITS文件异常求助
问题:WISE数据库M1星云FITS文件PIL可视化异常
本人具备基础编程能力,但尚未精通。现需使用PIL可视化一系列来自WISE数据库的M1星云.fits文件,尝试以下方法均未得到正确图像:
尝试的方法及结果
方法1:直接使用PIL打开文件
得到颗粒感图像,代码如下:
from PIL import Image fits_file = Image.open('image.fits') fits_file.show()
结果:
方法2:通过Astropy读取数据后转换为PIL图像
- 未添加
mode参数:有时显示正确图像,有时显示空白图(推测因极值超出255范围),代码如下:
from astropy.io import fits from PIL import Image fits_file = fits.open('image.fits') fits_img = fits_file[0].data pil_img = Image.fromarray(fits_img) pil_img.show()
结果:
- 添加
mode="F"参数:结果与方法1一致,代码如下:
from astropy.io import fits from PIL import Image fits_file = fits.open('image.fits') fits_img = fits_file[0].data pil_img = Image.fromarray(fits_img, mode="F") pil_img.show()
参考正确可视化结果(Astropy+matplotlib)

恳请告知无法正确可视化所有图像的原因及解决方法。
内容的提问来源于stack exchange,提问作者juno
相关产品推荐
相关产品推荐

