fitswrite
将图像写入 FITS 文件
说明
示例
创建 FITS 文件
创建包含 RGB 图像红色通道的 FITS 文件。红色通道在最终图像中以灰度表示。
读取一个示例图像并隔离其红色通道。
X = imread('ngc6543a.jpg');
R = X(:,:,1);
将红色通道数据写入一个 FITS 文件。
fitswrite(R,'myfile.fits');
显示 FITS 元数据。
fitsdisp('myfile.fits');
HDU: 1 (Primary HDU) SIMPLE = T / file does conform to FITS standard BITPIX = 8 / number of bits per data pixel NAXIS = 2 / number of data axes NAXIS1 = 600 / length of data axis 1 NAXIS2 = 650 / length of data axis 2 EXTEND = T / FITS dataset may contain extensions COMMENT FITS (Flexible Image Transport System) format is defined in 'Astronomy COMMENT and Astrophysics', volume 376, page 359; bibcode: 2001A&A...376..359H
创建和追加压缩的 FITS 文件
创建一个带有三个从 RGB 图像通道构建的图像的压缩 FITS 文件。首先用一个通道创建文件,然后向该文件追加另外两个通道。
读取一个示例图像,并隔离其红色、绿色和蓝色通道。
X = imread('ngc6543a.jpg');
R = X(:,:,1);
G = X(:,:,2);
B = X(:,:,3);
使用 Rice 压缩将红色通道数据写入一个 FITS 文件。
fitswrite(R,'myfile.fits','Compression','rice');
使用 Rice 压缩将绿色和蓝色通道数据追加到 FITS 文件中。
fitswrite(G,'myfile.fits','WriteMode','append','Compression','rice'); fitswrite(B,'myfile.fits','WriteMode','append','Compression','rice');
显示该 FITS 文件。
fitsdisp('myfile.fits');
HDU: 1 (Primary HDU) SIMPLE = T / file does conform to FITS standard BITPIX = 16 / number of bits per data pixel NAXIS = 0 / number of data axes EXTEND = T / FITS dataset may contain extensions COMMENT FITS (Flexible Image Transport System) format is defined in 'Astronomy COMMENT and Astrophysics', volume 376, page 359; bibcode: 2001A&A...376..359H HDU: 2 XTENSION= 'BINTABLE' / binary table extension BITPIX = 8 / 8-bit bytes NAXIS = 2 / 2-dimensional binary table NAXIS1 = 8 / width of table in bytes NAXIS2 = 650 / number of rows in table PCOUNT = 101902 / size of special data area GCOUNT = 1 / one data group (required keyword) TFIELDS = 1 / number of fields in each row TTYPE1 = 'COMPRESSED_DATA' / label for field 1 TFORM1 = '1PB(470)' / data format of field: variable length array HDU: 3 XTENSION= 'BINTABLE' / binary table extension BITPIX = 8 / 8-bit bytes NAXIS = 2 / 2-dimensional binary table NAXIS1 = 8 / width of table in bytes NAXIS2 = 650 / number of rows in table PCOUNT = 95976 / size of special data area GCOUNT = 1 / one data group (required keyword) TFIELDS = 1 / number of fields in each row TTYPE1 = 'COMPRESSED_DATA' / label for field 1 TFORM1 = '1PB(470)' / data format of field: variable length array HDU: 4 XTENSION= 'BINTABLE' / binary table extension BITPIX = 8 / 8-bit bytes NAXIS = 2 / 2-dimensional binary table NAXIS1 = 8 / width of table in bytes NAXIS2 = 650 / number of rows in table PCOUNT = 96255 / size of special data area GCOUNT = 1 / one data group (required keyword) TFIELDS = 1 / number of fields in each row TTYPE1 = 'COMPRESSED_DATA' / label for field 1 TFORM1 = '1PB(470)' / data format of field: variable length array
输入参数
imagedata
— 输入图像数据
一维数组 | 多维数组
输入图像数据,指定为一维或多维数组。
filename
— 文件名
字符向量 | 字符串标量
文件名,指定为字符向量或字符串标量。
名称-值参数
将可选的参数对组指定为 Name1=Value1,...,NameN=ValueN
,其中 Name
是参数名称,Value
是对应的值。名称-值参数必须出现在其他参数之后,但参数对组的顺序无关紧要。
在 R2021a 之前,使用逗号分隔每个名称和值,并用引号将 Name
引起来。
示例: fitswrite(R,'myfile.fits','WriteMode','append')
WriteMode
— 写入模式
'overwrite'
(默认值) | 'append'
写入模式,指定为字符向量或字符串标量。如果指定的文件已存在,写入模式将确定 fitswrite
的行为。
写入模式 | 描述 |
---|---|
| 覆盖现有文件。这是默认行为。 |
| 将图像数据追加到现有文件。 |
如果文件不存在,则无论使用哪种写入模式,fitswrite
都会创建一个新文件。
Compression
— 压缩算法
'none'
(默认值) | 'gzip'
| 'rice'
| 'hcompress'
| 'plio'
写入 FITS 图像时使用的压缩算法,指定为以下值之一。
值 | 描述 |
---|---|
| 无压缩。这是默认行为。 |
| 将图像数据压缩为 GNU ZIP 文件。 |
| 使用 Rice 算法压缩图像数据。 |
| 使用 HCOMPRESS 算法压缩图像数据。 |
'plio' | 使用 PLIO 算法压缩图像数据。 |
版本历史记录
在 R2012a 中推出
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)