I’m no math expert, and not native English, so I’m bound to use some terms wrong. Sorry in advance :).
But I’m dipping in g’mic command-line things again, to see if I can convert some imagemagick + vips pipeline to g’mic. Maybe to see how it performs, maybe just to learn g’mic more to add it as a tool in my arsenal.
What I’m looking for is sort of what Photoshop and other tools do with ‘auto levels’. You set a percentage on the lower side and on the upper side.
Let’s assume a 16-bit (0 to 65535) range of a single (grayscale) channel.
What I think I want, is to get a histogram with 65535 bins, so one bin for each possible value.
If I want to know the ‘threshold of 20%’, I mean I want to know the value at which point 20% of the pixels in the image are at or below that value.
So, let’s say I have a 200x200 image, that is 40000 pixels. 20% of that is 8000.
So if I take a histogram with 65535 bins, I want to start at the left and go summing bin by bin until I’ve reached 8000. If that’s bin 13124 as an example, that means that 20% (8000) of the pixels have a value of 13124 or less.
I think tools like Photoshop use this for ‘auto levels’. For example, use 0.1% as percentage for the shadow side, then use 99.9% for the percentage at the highlight side, and then you have two values you can use to scale the image in between (a normal levels adjustment in gfx tools).
Is there a command in g’mic to give me those values, or how would I go about doing it otherwise?