From FIT of Siril to TIFF with Imagemagick

I’ve already asked here about the conversion in question, but we’ve come to a dead end for now.
I see that a similar but opposite problem has already been addressed https://discuss.pixls.us/t/unable-to-view-fit-output-from-imagemagick-in-siril/26380 on pixls.
The only command that produces anything seems to be the one suggested by the Imagemagick community:
magick r_r_pp_light_00039.fit -combine -channel rgb -auto-level x.tiff
However the result is very wrong compared to Gimp (for example), but at least it’s in color.
The premises do not bode well, however I try to ask you if you have any ideas about it, thanks!

Define “wrong”. Without knowing exactly what went “wrong” there’s no way to tell you how to solve it.

I know in the past I have successfully converted FITS output to TIFF, and then tagged as DNG with appropriate metadata. However, in that case I skipped demosaicing.

This is the tif file produced with
magick r_r_pp_light_00039.fit -combine -channel rgb -auto-level x.tiff
and opened with Gimp:


and this is the fit file opened with Gimp:
.
In the first, the blue and green curves are completely wrong.

On Imagemagcick they wrote: “I suspect you need specific stretches for each channel, not just the auto-level of each. I could not figure that out from the meta data. Perhaps the data needs to be treated as linear before the combine and then convert to sRGB afterwards?”

$ magick identify -verbose r_pp_light_00039.fit

is this

Why are you using auto-level? That is completely nondeterministic.

Because I don’t know the command to specify the rules for each channel and more importantly I don’t know how to calculate or extract them from the output of

$ magick identify -verbose r_pp_light_00039.fit

I believe the values ​​min and max in the Channel statistics are useful because they are useful in Gimp, but i don’t know how to use them (if they are really useful).

The maximum value is only really important if you’re doing highlight reconstruction, otherwise you can just do exposure compensation. You can probably find the raw black/white points by using exiftool on one of the input raw files if this came from a mirrorless or SLR.

That said, looking at the discussion over on the iM site, something is weird with the FITS output causing it to have negative values which is extremely unusual, especially since they’re almost universally negative. (Negative values in RGB can sometimes indicate an out-of-gamut color, but something else is going on here.)

BTW, the tiff looking dark is not actually correct, per some of the discussion over at Color management in Siril, need help and refactoring. and Siril needs distortion correction in stacking - #31 by flint - it really should have an ICC attached that indicates linear data.

You can probably find the raw black/white points by using exiftool on one of the input raw files if this came from a mirrorless or SLR.

Here is:

Black Point : 256 256 256 256
White Point : 18496 8192 8192 13856

If I understand correctly, it does not seem to me enough because the curves of blue and green are too strange: they are on the contrary.
The following is the correction of exposure (with curves of GIMP) of the output of
magick r_r_pp_light_00039.fit -combine -auto-level x.tiff

When ending B and G start R.

Trying I found something that, maybe, begins to approach the “correct” version, but I have not yet found a quantitative rule to define the precise parameters…

magick r_r_pp_light_00039.fit -combine -channel gb -level 0%,-20% -channel r -level 0% x-magick.tiff

and I start to assume that the curve R is actually G and vice versa.