Parameters in Pixel Math

Is it possible to set parameters using the command PM? I’m trying to set for example S=0.20 and then use S in the PM command the same way it works from the UI.

Parameters are only implemented for the UI.

1 Like

Do you think it’s possible that could be implemented in a future release?

I don’t think that’s the case. I’m not sure there’s any sense in adding that. The advantage of this is when you do several iterative tests with the UI, which is not the case here.

So my use case is when I write a script for others to use. Let’s say I have a parameter called S that’s used in 4 places within the pixel math formula. If I could specify the default value of that S parameter, and use S in pixel math, then I could tell users they only need to change the value in one place vs. 4.

Hello, we tried to keep commands stateless, meaning that they should be independent and their execution order should not matter for them to work. Having variables inside a script, or a commands that sets them for other commands, would break this.

For the record, we already broke the rule a few times:

  • the wavelets commands only work in one order
  • the new live stacking commands are not stateless at all because they work in their own command line mode

Those may be subject to change, but if we can avoid adding more for now, we will.

1 Like

If were just talking about pixel math though, I’m confused to how you allow parameters in the UI, but we can’t have them in PM command?

Tools GUI have their own way of managing data. For Pixel Math, it’s not even the same syntax used to reference images and variables in the GUI or in the command.
We could indeed modify the pm command to define parameters as an option appearing before the expression, that would not be easy to do and to read, but possible. Something like:

pm -var:S=0.2 "$R$*!S! + $Ha$*~!S!"

That would be perfect. To make it easier to read couldn’t we write it like this?

pm -var:S=0.2

pm "$R$*!S! + $Ha$*~!S!"

I don’t think it’s worth the effort.
Updating a constant value in script files is not too hard.
Here the code changes will be big enough.

no because that would make a stateful command, if it has to keep memory between runs

1 Like

Understood. It’s just that type of thing is standard in any language, and I was surprised that it didn’t work that way here.

I’m not a programmer so forgive me, but what if I could write parameters to a text file, and have them imported within the PM command for use? Would that be easier to code and keep it stateless?

yes, the thing is that commands are not an actual language, just a list of predefined operations

having the parameters created as the first option as I showed before, or read from a file whose name would also have to be passed as an option to the command is about the same to us, and they would still be only used for pixel math, not for the rest of the script

I understand your need for simply configurable scripts, it’s still complicated for now. It’s a request we often have, we have a feature request still opened for a pop-up box that will ask a value when running a script for example… Feature : Script parameters (#515) · Issues · FA / Siril · GitLab
It’s the sort of things that would be better done with the python interface, but you really have a case where having script parameters would be useful…
I don’t have a solution for you for the short term unfortunately.

That’s fine. I was unaware of the request, and wasn’t hoping for an immediate change. I know you guys have limited time, especially with the beta release happening. Thanks for the consideration.