Is it possible to estimate optimal gamma parameter for gamma correction by algorithm using some image statistics? By 'optimal' I mean that image should 'look good' for human on average after correction.
If your image pixels are scaled on the range 0..255, you could use:
gamma = log(mean)/log(128)
where mean
is the mean of your image pixels. If they are scaled on the range 0..1:
gamma = log(mean)/log(0.5)
Note that this is the technique that ImageMagick uses, documentation here, and you can test it yourself on the command line with:
magick input.jpg -auto-gamma result.jpg
Nothing is perfect though and that may not look good if there are heavy shadows or bright areas in your images.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With