Saving an array to a fits file
Show older comments
I have an array called frames_out. It's a 100x100x3000 array of images (3000 images, each image 100x100 pixels). I want to save this array as a FITS file. I've tried using the fitswrite function:
%%%%%%%%%
A = frames_out(:,:,1);
fitswrite(A,'fitsfile.fits')
for i = 2:size(frames_out,3)
A = frames_out(:,:,i);
fitswrite(A,'fitsfile.fits','writemode','append');
end
%%%%%%%%
But when I use the "fitsread" function on the FITS file I've created, that gives me an array with just one frame (the first frame of the original array), and I want all the images to be there. The weird thing is that if I use the code on just one frame, like this:
%%%%%%%%%
A = frames_out(:,:,1);
fitswrite(A,'fitsfile.fits')
%%%%%%%%
I get a FITS file whose size is a few hundred KB, and with the first code I get a much bigger file. So there's more information on the file from all the frames, but I can't seem to "extract" or see it anywhere.
Thanks a lot for your help,
Yael.
1 Comment
Kelly Miller
on 15 Apr 2016
Did you ever find a way around this issue? I am having the same problem, and can't find anything online. I'm running Matlab R2015a. Thanks!
Answers (1)
Thorsten
on 20 Nov 2014
Reading the ith image: (adapted from the Mathwork's help for fitsread)
info = fitsinfo('fitsfile.fits');
rowend = info.Image.Size(1);
colend = info.Image.Size(2);
frames_in(:,:,i) = fitsread('fitsfile.fits','image',...
'Info', info,...
'PixelRegion',{[1 rowend], [1 colend], i });
1 Comment
Categories
Find more on Image Arithmetic in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!