Page 1 of 1

Hopefully simple question

Posted: 2016-01-25T19:26:12-07:00
by spokeshave
I just came across ImageMagick as I was looking for a simple way to convert FITS files to something more readable by other software like TIFF of JPEG. I do astrophotography and my color camera produces monochrome (undebayered) FITS files. I want to be able to debayer those files and then convert to either TIFF of JPEG. I can do that from the command line but I only get a grayscale image. I tried the -interpolate option and still got grayscale. Can someone please tell me how to make this conversion work? Many thinks in advance.

Incredible software, by the way. I'm astonished that I have not seen it before now.

Tim

Re: Hopefully simple question

Posted: 2016-01-25T19:32:16-07:00
by snibgo
IM doesn't contain code for de-bayering. I show some methods using IM on my page http://im.snibgo.com/demosaic.htm

Re: Hopefully simple question

Posted: 2016-01-25T19:38:59-07:00
by spokeshave
Ah. Thanks. I was hoping for one-stop shopping with ImageMagick. I am familiar with dcraw and use it to demosaic raw files from my DLSR. However dcraw cannot decode FITS files. Hence my dilemma. Is there a way to use ImageMagick to convert the FITS to something that dcraw can then decode?

Thanks.

Tim

Re: Hopefully simple question

Posted: 2016-01-25T19:44:35-07:00
by snibgo
Can you put up an example FITS file? You can upload to somewhere like dropbox.com and paste the URL here.

Re: Hopefully simple question

Posted: 2016-01-25T22:06:54-07:00
by PandoraBox
@snibgo

Ironically I had this in my bookmarks might be able to help out on this case.

http://fits.gsfc.nasa.gov/fits_samples.html

has some sample images they read like text so I'm assuming conversion might not be that bad to do... as for actual converters this site also has some.

PandoraBox

Re: Hopefully simple question

Posted: 2016-01-25T22:45:09-07:00
by snibgo
Thanks for the link. I can't see any mention of Bayer arrays. The first three aren't Bayer. On the contrary, some mention "the 4 individual CCD chips", which isn't Bayer. IM Q32 HDRI can read these files, and make decent images from them. It reports that the third file, "HST FOC", is grayscale 32-bit/channel, with the maximum value of 2.08e-8 (on a scale of 0 to 1). With "-auto-level" it becomes visible.

When an image is made from three individual CCD chips, assuming they line up exactly and they record red, green and blue, a colour image can be made with "-combine". Very easy.

Digital cameras often have only one CCD chip, where each receptor has a colour filter so it captures only red or green or blue. This creates a gray (one channel) mosaic image that looks like a chequer-board when we zoom in. Each pixel represents only one channel. Converting these to colour is much more difficult. By de-Bayering (de-mosaicing), we interpolate the missing two-thirds of the data.

Re: Hopefully simple question

Posted: 2016-01-26T03:03:16-07:00
by spokeshave
snibgo wrote:Can you put up an example FITS file? You can upload to somewhere like dropbox.com and paste the URL here.
Sure. Here's one:

https://www.dropbox.com/s/u1m1tgs0nhfdy ... 4.fit?dl=0

Thanks.

Tim

Re: Hopefully simple question

Posted: 2016-01-26T11:01:41-07:00
by snibgo

Code: Select all

convert "Bubble Nebula_480sec_1x1__frame14.fit" b.png

set sCROP=-crop 40x80+775+1561

%IM%convert b.png %sCROP% -scale 400%% b_sc.png
Image
Yes, that looks like Bayer. Enlarging one of the white blobs, I can see the typical mosaic pattern.

Assuming the pattern is RGGB, and the colour multipliers are all 1.0, we can use my demos.bat script to de-Bayer it:

Code: Select all

call %PICTBAT%demos b.png
%IM%convert b_dm.png %sCROP% -scale 400%% b_dm_sc.png
Image
The result seems plausible.

The colour multipliers probably should not all be 1.0. Ordinary camera files normally contain this metadata, but your FITS file doesn't.

Re: Hopefully simple question

Posted: 2016-01-26T11:05:42-07:00
by spokeshave
Yes, the color matrix is RGGB. For one-shot-color astronomical cameras, all color balancing is done in post-processing, so there is no color info in the header.

It looks like your batch file will work well. Thanks for the help.

Tim