Can I automatically adjust a histogram?

I’ve noticed that 99% of my exposure adjustments simply involve bringing the edge of my histrogram to the edge of the box, both left and right side. Usually I’m pulling the right side inward.

Since this exposure adjustment is something I’m doing so frequently, is there anyway to automate this and apply a formula to all photos in a folder?

I’m rather agnostic on software as long as I can run it on linux…

RawTherapee’s auto exposure should work decently. Or auto levels in GIMP.

when I use Auto Levels in RT things get adjusted, but the histogram doesn’t move where it needs to go. I still have to tinker manually.

Update: actually, maybe not. Auto-level seems to get me most of the way there. Adding a bit of manual adjustment then saving that to a profile works pretty good.

Some need more work but I think I want to try luminosity masking for that…

Yes, if you can work out what the formula is. I guess you are moving the end-stops inwards a bit beyond the current min and max values, so you get some clipping at both ends.

For example, with ImageMagick:

magick in.tiff -contrast-stretch 2x3% out.tiff

This clips 2% of pixels values at black and 3% at white.

magick in.tiff -level 2x97% out.tiff

This increases contrast so what was 2% becomes 0%, and what was 97% becomes 100%.

magick in.tiff -level %[fx:minima*100+2]x%[fx:maxima*100-3]% out.tiff

This increases contrast so what was 2% above the minimum becomes 0%, and what was 3% below the maximum becomes 100%.

If your formula creates values less the 0% or more then 100%, there are methods to bring them back into range, while keeping some detail at both ends.

Once you have a formula you are happy with, a shell loop can do all the images in a folder.

5 Likes

You can do that in darktable as well, with the levels module or the exposure one.