Hopefully simple question

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
spokeshave
Posts: 4
Joined: 2016-01-25T19:16:56-07:00
Authentication code: 1151

Hopefully simple question

Post 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
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Hopefully simple question

Post 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
snibgo's IM pages: im.snibgo.com
spokeshave
Posts: 4
Joined: 2016-01-25T19:16:56-07:00
Authentication code: 1151

Re: Hopefully simple question

Post 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
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Hopefully simple question

Post by snibgo »

Can you put up an example FITS file? You can upload to somewhere like dropbox.com and paste the URL here.
snibgo's IM pages: im.snibgo.com
PandoraBox
Posts: 23
Joined: 2011-04-10T14:08:11-07:00
Authentication code: 8675308

Re: Hopefully simple question

Post 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
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Hopefully simple question

Post 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.
snibgo's IM pages: im.snibgo.com
spokeshave
Posts: 4
Joined: 2016-01-25T19:16:56-07:00
Authentication code: 1151

Re: Hopefully simple question

Post 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
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Hopefully simple question

Post 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.
snibgo's IM pages: im.snibgo.com
spokeshave
Posts: 4
Joined: 2016-01-25T19:16:56-07:00
Authentication code: 1151

Re: Hopefully simple question

Post 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
Post Reply