Thank you, David & Andy. I am fine. 2016 and the first quarter of 2017 were busy times for me. I’m coming up for air now (I think).
Pertinent to this thread, David & I had correspondence this morning/yesterday evening about the -fill command, which will mirror at gmic.eu in the wholeness of time (say, a day or two). Since it is a command that furnishes an entry point to math expressions, a good bit of the document David spoke about finds it way into that. It is still not Math Expressions 101; it is more of a Whitman sampler of toys, but with a little study it will serve as an informal introduction until something better comes along.
To amplify on McCap’s original post, I’ve bought along my $0.02 USD. With the New And Improved Math Parser, one may write an expression to return either scalar pixel components or the entire pixel as a vector, which can have consequences on how your color computations appear. To follow along, you may want to augment your basic stock gmic installation with an update:
$ gmic -update
so that you get a bunch of toys, including -colorwheel, a utility that paints a colorwheel. If you have a stock installation, and have never invoked an -update, then you won’t have -colorwheel or a few other nice things. So do it. Life will be so much better.
Assuming you’ve done such a thing and have such a toy, then running:
$ gmic -colorwheel 512 -fill 'R’
produces a gray-scale-like image where the red wedge of the colorwheel renders in shades of gray. But if you look at the banner of the display window, gmic will report that you have a three channel image. Why is that?
What this script does is return a scalar, the current contents of the red component of the visited pixel. Since the math expression parser notices that the expression returns a scalar, it will duly run this expression for every pixel component in the image - that is it iterates over the red, green, and blue channels and, for each pixel component, transcribes the value of the red component into the visited component. In effect, this expression transcribes the red channel into the red, green and blue channels, iterating over the image in three passes.
Now let’s write a slightly different math expression.
$ gmic -colorwheel 512 -fill ‘[R,0,0]’
This expression returns a vector, so constructed by the square brackets. This change alters how iteration occurs. The math expression parser iterates over over the entire image just once, and at each column-row location, x,y, writes the entire three channel pixel in one go. So in this variation, you fill the colorwheel image with a bunch of pixel vectors that transcribe only the red channel to the red channel, the G and B channels are set to zero. The colorwheel appears not as gray, but as blood red.
Of course, this template can be extended to any one of a bazillion color remappings, such as:
$ gmic -colorwheel 512 -fill ‘[0.5R+0.2B,B+G/2,R-B]’
These are all in-place approaches where the math parser over-writes pixels of the colorwheel. David and Andy take a non-destructive transcription approach by creating a target image and then writing a transcription expression as a part of the image creation process. The # suffix enables a math expression in the target image to access channels in the source image, which can be any image on G’MIC’s list.