Archive for the ‘ g’mic ’ Category

About the image stack

1.Initial stack

When several images are loaded in G’mic, they are ordered in a stack. It is then possible to refer to them by using either positive (starting from the first image as [0]) or negative numbers (starting from the last image as [-1]).

For example, if 3 images A, B and C are loaded:

gmic A.png B.png C.png

It creates a stack that you can picture like that:

You can refer to A as image [0] or image [-3], B as [1] or [-2] and C as [2] or [-1]. So both commands below do exactly the same thing, they display B:

gmic A.png B.png C.png -display[1]
gmic A.png B.png C.png -display[-2]

2.Command with one dash

If, in your command line, you add an instruction using a single dash, it replaces the images to which the instruction applies by the result. Thus, to split the different channels of B, the 2 commands below could be used is added to our first command:

gmic A.png B.png C.png -split[1] c
gmic A.png B.png C.png -split[-2] c

And they would modified the stack as shown below:

As you can see, the image A is still [0], but not [-3] anymore, it has become [-5].

3.Command with two dashes

To keep the original image, instruction are called using 2 dashes. The original image is indeed kept in place and the result is added at the end of the stack.
So commands below:

gmic A.png B.png C.png --split[1] c
gmic A.png B.png C.png --split[-2] c

would modify the stack as below:

4.Stack order matters, not invoking order

When you apply a command to several images, sometimes, order matters. But be careful, stack order matters, not invoking order.
For example, both commands below have the same result:

gmic A.png B.png -append[0,1] y
gmic A.png B.png -append[1,0] y

If you want to apply your command in another order, you have to play with the image stack, such as:

gmic A.png B.png -reverse[0,1] -append[0,1] y

or

gmic A.png B.png -move[1] 0 -append[1,0] y