This command uses image channels as operands in an arithmetic or logical operation. The command's parameter specifies the particular operator which defaults to 'add'.
For example the underlined snippet in this pipeline:
gmic 16,16,1,2,'if(c==0,x,y)' -compose_channels and
Is equivalent to:
gmic 16,16,1,2,'if(c==0,x,y)' -split c -and[-2,-1]
We made the graphic on the left with this somewhat more complete example:
-append c -resize2dx 256,1
-normalize 0,255 -o[-1] testpattern.png
In this example, we find the dot products between elements of two vector fields, one in a.cimg, the other in b.cimg:
gmic a.cimg b.cimg -mul[-2,-1] -compose_channels[-1] add
The format of the command is:
One writes the operator without any leading hyphens as it is being passed as a parameter rather than being immediately invoked. Figuratively, the command inserts N − 1 copies of the operator between the N channels of an image, and then reduces the result pairwise from channel zero, accumulating the result in channel zero.
It is a harmless yet pointless exercise to employ a single channel image with -compose_channels, a bit like the sound of one hand clapping. In this case, such an image is left unchanged by the command. On the other hand, the G'MIC command passed to -compose_channels really must be a pairwise image operator that reduces a multi-spectral operand image to a single channel result. Unpredictable behavior can arise, though an inappropriate command usually results in a error.