help needed for a script creation - can I provide specific values in the console?

Hello,

I would like to create a script in Siril to automatically extract the sky background value of R,G,B to its respective channels.
As a disclaimer, I have no prior experience in script creation, that would be my first time.

I’ve found 2 ways to accomplish this:

  1. Splitting the RGB Channels and doing the subtraction in pixelmath
  2. Using the function LINSTRETCH

For the the script, I was planning to:

  • run 3 LINSTRETCH, one per channel,
  • eventually apply an offset,
  • save the final image under a new name.

The point where I am stuck is that I need to provide the amount to subtract for each channel.

  • Is there a way to tell the script to subtract every time one of the values from the image statistics? (I was thinking either the min, the average, or the median value)

  • Alternatively, Is there a way to have the script pause and request an input value in the console before proceeding?

Bonus question:
The command BG seems to return the median value of a selection or the whole image.

What is the rationale for using the median instead of the average, or the min value to estimate the sky background?

Many thanks!

I’m not sure to understand what you want.It looks like you want to clip the image from the sky background. Probably to make a mask? If so, I’d advise you to take a look at pixelmath. You have an example of a formula here: Pixel Math — Siril 1.2.0 documentation

Definitely using the pixelmath command in your script would be better. Because you can use the median value of the image.

No.

The mean is absolutely not a robust estimator of the background, while the median is a good one. This is why we chose it. It represents the center of the main peak in the histogram.
More information here: Statistics — Siril 1.2.0 documentation

Many thanks for the quick reply!
what I want to do, is selecting a correct black point for the image, so that I can further stretch without the risk of having altered white balance with scene intensity, as discussed here

so far, my manual processing was the following:

  1. check the minimum value for RGB of the image from the statistics (or the average/median in a small dark area)
  2. split the image in 3 channels;
  3. use pixelmath to subtract the minimum to each channel (minus an offset), so that each starts at the same value (i.e. 50)

A few questions for the Pixelmath entries:

  • Generally speaking, does the script works with normalized values (0,1) or the 0-65535 values?
  • I just saw from the documentation that PM can retrieve statistics functions (yay!) the question is: do the values returned always refer to the whole image, or do they change if I have an active selection?

many thanks!

It works in the [0,1] range yes.

This is for the whole image.