Access to the fits file channels

조회 수: 3 (최근 30일)
assia assia
assia assia 2021년 6월 29일
댓글: assia assia 2021년 6월 29일
Hello Folks,
I have this fits file of size(300,300,3) I would like to acces to each channel alone and write it. Using this code I can access only to the first channel but not to the second and third one. Any idea please.
stokes = fitsread('stokes1.fits');
Iu = stokes(:,:,1);
Ip = stokes(:,:,2);
Theta = stokes(:,:,3);
fitswrite([Iu,Ip,Theta],'stokes.fits')

채택된 답변

Walter Roberson
Walter Roberson 2021년 6월 29일
info = fitsinfo('stokes1.fits');
Size = info.PrimaryData.Size;
nchan = Size(3);
parts = cell(1,nchan);
for channel = 1 : nchan
parts{channel} = fitsread(info, 'pixelregion', {[1 Size(1)], [1 Size(2)], [channel channel]})'
end
  댓글 수: 4
Walter Roberson
Walter Roberson 2021년 6월 29일
I had misread about the option to use an info structure instead of a file name.
As usual I recommend making the filename a variable.
fitsfile = 'StokesParameters_Synthetic_Star_Gain_10.fits';
info = fitsinfo(fitsfile);
Size = info.PrimaryData.Size;
nchan = Size(3);
parts = cell(1,nchan);
for channel = 1 : nchan
parts{channel} = fitsread(fitsfile,'PixelRegion', {[1 Size(1)], [1 Size(2)], [channel channel]});
end
outdata = horzcat(parts{:});
fitswrite(outdata, 'stokes5.fits', 'Compression', 'rice');
assia assia
assia assia 2021년 6월 29일
Thank you for your feedback.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Hilbert and Walsh-Hadamard Transforms에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by