How do I read an image file in .fits format and convert it to.png or .tiff?

8 ビュー (過去 30 日間)
Vanessa Phung
Vanessa Phung 2018 年 12 月 11 日
コメント済み: Vanessa Phung 2019 年 1 月 7 日
I have images in .fits extension. I'd like to open it in matlab and convert it to other format such as .png or .tiff.
Any suggestion on how should I start?

採用された回答

Mark Sherstan
Mark Sherstan 2018 年 12 月 11 日
Use fitsread() and imwrite() if you need further help please post the file you are working with.
  1 件のコメント
Vanessa Phung
Vanessa Phung 2019 年 1 月 7 日
Thank you for your comment, Mark and Chad.
Initially, I only get all ' solid color' for the image after imwrite.
However, I adjusted the contrast and save the image in .png using the codes as show here.
data = fitsread(filename,'primary');
% --rotate and flip image file--
data2 = imrotate(data,180);
data2= fliplr(data2);
% --for contrast to see image--
factor=0.1;
clow =min(data2(:));
chigh=max(data2(:))*factor;
clims = [clow chigh] ;
A=data2;
A=A-clims(1);
A= A/clims(2)/factor;
imwrite(A,'testinn.png', 'BitDepth', 16);
figure(1); imshow('testinn.png');
% --figure file save
h = figure(2);
set(h,'Visible',vkey);
img1= imagesc(data2, clims);colorbar;title(sprintf('fn:# %d',fnum));colormap(jet);
%---save this figure in directory---%
print(h,'MySavedPlot','-dpng');
testinn.png
If you have any suggestions on getting the good contrast directly, I'd be happy to learn about it.
Using imagesc, I manage to get this. (max. is actually 23000, that's why I get poor contrast
initially)
MySavedPlot.png

サインインしてコメントする。

その他の回答 (1 件)

Chad Greene
Chad Greene 2018 年 12 月 11 日
You should be able to read it with fitsread and then save it to png or tiff with imwrite.

カテゴリ

Help Center および File ExchangeConvert Image Type についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by