Instagram added a Lux button recently, which allows auto-contrasting / leveling for the pictures you take.
I have a bunch of pictures that I need to autolevel in a similar manner, making those pics better looking. If I would want to use a batch command with Imagemagick, what would be the "secret ingredients" to use? Should I just stick to the contrast setting, or play around with levels, etc.?
As I do not know if the original picture will be dark, bright, already contrasted, I will need to analyse the pic before processing it.
Therefore 2 questions:
What are the settings I should look at in creating my batch command for Imagemagick that will consistently output better looking pics?
Does it make sense to run the batch and revert the "false positives" by hand later (I have around 50,000 pics to process)?
A simple linear way of performing "auto-contrast" is to linearly stretch and offset the image intensities.
The idea is to find the stretch (contrast) and offset (intensity) correction parameters such that in the corrected image the 5th percentile will be mapped to 0, and the 95th percentile will be mapped to 255.
My example is for a grayscale image. For color images you can convert to any color space that has a single intensity channel and 2 color channels (e.g. Lab, HSV, YUV etc.) and perform this only on the intensity channel.
a
and b
in these 2 simple linear equations:a*p5+b=0
and a*p95+b=255
, where p5
and p95
are the 5th and 95 grey-value percentiles respectively.a
is the contrast, and b
is the intensity corrections.g'=a*g+b
for all g
=0..255. Of course, you might want to use different values for the percentile and the actual mappings. See what works for you.
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