For the poor, blighted souls who once pranced, care-free, through the flowered vales of Gimp-G'MIC, spreading Pixel Dust and making fine digital art, but who ― in moments of unguarded curiosity ― tried one or another of those mysterious “underlying commands” lurking in the “custom code” section of the Gimp-G'MIC plugin, fell into the G'MIC Rabbit Hole and from then on couldn't produce an image that was otherwise all black, or all white, or posterized, or inverted, or in Strange Colors, there are two commands which can lead them back to the Lands of Fairness and Light:
-cut, which sounds dreadful, and is dealt with elsewhere
-normalize, which is probably the command you are looking for.
-normalize performs H-L Normalization. Raw image data, i, ranging between a maximum value iM and a minimum value im, can be shifted and scaled to fall between a new maximum, H, and minimum L by the formula:
where the rescaled image data i' fall within the boundaries H and L.
The format of the command is one of:
-normalize {value0[%] | [image0]},
{value1[%] | [image1]}
-normalize [image]
Normalization is typically the penultimate G'MIC command before -output, where it shifts the minimum and maximum boundaries of an image to the prescribed minimum and maximum values required by the output format, scaling intermediary values in the process. For example, the eight-bit Portable Network Graphics file format expects image data to fall within the range of 0 – 255, in terms of the normalization relation, this calls for H = 255 and L = 0.
If one plans on using a paint program on images processed in a G'MIC pipeline, or – in the case of the Gimp-G'MIC custom coding – return the image to a Gimp layer, use of the -normalize 0,255 is almost mandatory, because the G'MIC layer stack can be in one of a variety of numeric formats and is not likely to be directly compatible with the paint program or the Gimp layer stack. See “Images as Datasets” for further details.
Normalization generally affects the magnitude of difference between pixels, and if particular differences between pixels matter, then -normalize probably is not what you want. -cut, in contrast to -normalize, leaves relative differences among pixel values undisturbed, simply setting out-of-bound values to that of the nearest boundary. One does have to ensure that the differences of interest fall within the boundaries given to -cut.
Garry Osgood