You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.03 05:15:26