Batch extract green channel / convert to grayscale (color fits)

Hello,

I have a number of color fits files, but the software I need to process them with only wants single channel file.

Is there a way to batch process my files (around 200) to, at best, transform them into grayscale, and if not possible, to extract the green channel?

Thanks,
Cyrille

Hello,

seqextract_Green is probably a function you want to use.

Hello,

Sorry, I have never done any scripting on Siril…

Let us say I have a list of 20 file names (I can easely get it in a command line interface doing a dir /b or similar, and even copy them in a file)…

What would be the sequences of siril script command to:
1 open a file
extract the green channel
save the file back (using either the same file name, or a modified file name with a green_ at the start or the end)?

once I have that, I should be able to generate the script.

Thanks,
Cyrille

If you don’t want to do it with script, you can use GUI too: Extraction — Siril 1.2.0 documentation

Hello,

ho, no, I am ok with scripts! it’s just that I don’t know how to use them (yet)…

Having a number of randomly names files, I DEFINITELY want to use scripts as I caneasely generate a text file with all the script lines needed…

I am just not sure of what these lines will be :slight_smile:

Will a set of these work?
LOAD file_name
EXTRACT_GREEN
SAVE file

cyrille

Not at all, cause the command I sent you can work on sequence. For a better understanding of the script use, you can refer to this page of the documentation.

Hello,

Except that I do NOT have a sequence.
Each file has an individual name (not part of a sequence), and they are not all of the same object…

See bellow the first couple of lines .ssf file…

However, it does NOT work :frowning:

I am getting the following error:
13:54:50: Running command: EXTRACT_GREEN
13:54:50: No Bayer pattern found in the header file.

My files ARE RGB (3 channels)… but not bayer encoded…
Is there a way to extract the Green (or transform to single channel grayscale) my files?

Thanks,
Cyrille

requires 1.0.0
LOAD “1998KV2 (85628) 2024-05-09 21_36_01.fits”
EXTRACT_GREEN
SAVE “g_1998KV2 (85628) 2024-05-09 21_36_01.fits”
LOAD “1998KV2 (85628) 2024-05-09 23_31_01.fits”
EXTRACT_GREEN
SAVE “g_1998KV2 (85628) 2024-05-09 23_31_01.fits”
LOAD “1998KV2 (85628) 2024-05-10 01_02_13.fits”
EXTRACT_GREEN
SAVE “g_1998KV2 (85628) 2024-05-10 01_02_13.fits”

OK. Extract Green works only on CFA images.
Here you will need to use the split function. However, this function does not exist for sequence so you will need to combine either with python, bash or PowerShell script.
An example is given in this tutorial: Siril - Advanced Siril scripting with bash or DOS

Hello,

I was able to use split to generate images…
BUT!!! I ran into another issue :frowning:

Siril saves my split images into 32 bit fits…
BUT, astrometrica (which I need to use after) requires 16 bit fits!

I tried changing the default fits format in siril, but split seems to still save as 32 bits…
How can I specify that I want to split/save my files into 16 bits?

I tried changing my script to this also:requires 1.0.0
LOAD “1998KV2 (85628) 2024-05-09 21_36_01.fits”
SPLIT r g b
LOAD g.fits
SAVE “g_1998KV2 (85628) 2024-05-09 21_36_01.fits”
LOAD “1998KV2 (85628) 2024-05-09 23_31_01.fits”
SPLIT r g b
LOAD g.fits
SAVE “g_1998KV2 (85628) 2024-05-09 23_31_01.fits”

Hopping that the relaod/save would force the 16 bit, but nope…

Thanks again for your help and the quick replies!
Cyrille

If you give 16bit files as input, Siril must save the output file in 16bit as well.

Hello,

Problem is that my input files are 32 bits (because they have been pre-processed)…
But how do I save back into 16 bits?

Cyrille

Then preprocess them with Siril preferences set on 16bit.

Hello,

I spent around 8 hours pre-processing them… I don’t really want to redo it :frowning:

Is there really no way to programatically/scriptingly load a 32 bit file and save it in 16 bits (I know that information will be lost, but I am ok with that)?

I found that I can open the file, and do a save as and then, I will be able to select 16 bits… I would rather not have to do it by hand for my 200 files:-)

Cyrille

No, sorry. Maybe save in TIFF with savetif.

Siril shouldn’t take that long to process 200 images. You probably didn’t use an SSD. If you have one, I’d advise you to use it: pre-processing would only take a few minutes…

Hello,

Siril shouldn’t take that long to process 200 images.

What I mean is that I have 200 batch of 10 tifs, each a different object, which will produce 200 final images…
So, by the time you change the “home”, run the preprocessing (which is fast), do some basic historgram corrections and the like (which represents a lot of click other manual operations), it takes around 8 hours for a beginer like me…

Anyhow, using a screen recorder, I was able to semi-automate the open of the 200 images and save back into 16 bit fits…

I will just have to find a way to ensure that my files are only 16 bits in the future to avoid having to do it again.

Thanks again for your help.
Cyrille