mlnoga / nightlight

Nightlight: Astronomic Image Processing
Other
36 stars 3 forks source link

How to debayer a single shot fits file? #24

Closed jkoenig72 closed 3 years ago

jkoenig72 commented 3 years ago

Hi Markus,

very nice project.

One question: I have one shot fits from a color CCD (QHY) and try to convert those fits into best possible jpg or png.

I tried

./nightlight -out out2.fits -jpg -debayer -align 0 stack ../images/ccd_image25.fits

and a few variants of that - but it does not generate any jpg file. What I'm doing wrong?

./nightlight stats ../images/ccd_image25.fits Using location and scale estimator 3 Found 1 frames: 0:../images/ccd_image25.fits

Preprocessing 1 frames with dark=0 flat=0 debayer= cfa=RGGB binning=0 normRange=0 bpSigLow=3.00 bpSigHigh=5.00 starSig=10.00 starBpSig=5.00 starRadius=16 backGrid=0: Warning:Cannot parse 'PIXSIZE1= 2.400000E+00 / Pixel Size 1 (microns) ', ignoring Warning:Cannot parse 'PIXSIZE2= 2.400000E+00 / Pixel Size 2 (microns) ', ignoring Warning:Cannot parse 'XPIXSZ = 2.400000E+00 / X binned pixel size in microns ', ignoring Warning:Cannot parse 'YPIXSZ = 2.400000E+00 / Y binned pixel size in microns ', ignoring Warning:Cannot parse 'GAIN = 0.000E+00 / Gain ', ignoring Warning:Cannot parse 'OFFSET = 0.000E+00 / Offset ', ignoring 0: Removed 50940 bad pixels (0.81%) with sigma low=3.00 high=5.00 0: Stars 0 HFR 0 Min 4 Max 3540 Mean 391.598 StdDev 254.728 Location 376 Scale 204.161 Noise 221.4

Done after 1.101872517s

I generated the fits via indilib and they show up nicely in e.g. KStars FITS Viewer.

Thanks! Joerg

mlnoga commented 3 years ago

Hi Jörg, nightlight is a stacker at heart. So the current process is to 1. extract and stack the R channel, 2. same for G, 3. same for B, and then 4. combine the mono channels into an RGB image.

./nightlight -out outR.fits -debayer R -cfa RGGB -align 0 stack ../images/ccd_image25.fits does the first step. Then ./nightlight -out outG.fits -debayer G -cfa RGGB -align 0 stack ../images/ccd_image25.fits and ./nightlight -out outB.fits -debayer B -cfa RGGB -align 0 stack ../images/ccd_image25.fits.

Where RGGB is the color filter array sequence for your camera. If you're not sure about sequence, look at the debayered green channel first. If it still shows a mosaic, or two background histogram peaks, try another value. Once that works, look at the stacked picture and see if known red stars are indeed red. if they are blue, swap R and B in the cfa. Once you know the value for your camera, you know it for all future runs.

Finally ./nightlight -out out.fits rgb outR.fits outG.fits outB.fits.

If you regularly need this, might want to add a command like rgbsingle. However, most people tend to want to stack multiple exposures for each color channel.

Hope this helps!

jkoenig72 commented 3 years ago

I understand, maybe I should have explained why I'm asking... :-)

There is this nice allsky cam project by Thomas:

https://github.com/thomasjacquin/allsky.git

Sadly this is only for ZWO cams from now, by using their SDK. I would like to replace that with some indilib client. But here you get "only" fits - mostly debayered. So I was trying to get a nice easy way of debayering those fits into good quality jpeg or png. Actually I find it hard to get some good debayering tools / examples, working on command line. Its not only the debayering, its also the histogram stretching.

Just getting an image as a fits, run some python opencv script or your tool convert into a good quality jpg - then all the rest of Thomas scrips etc. can stay same, just replacing image capturing.

So what if I take the same image 3 times? Debayermask is GBRG... would that work? I will give it a try later today.

Thanks!

Very nice project you have here.

mlnoga commented 3 years ago

Closing due to lack of activity.