In Adobe photoshop, I used the "Levels" feature to adjust Shadows, Midtones and Highlights of an image. I need an elegant solution using ffmpeg to implement the same effect. A ffmpeg implementation will help me perform the operation programmatically.
I've tried using the colorbalance filter available on ffmpeg.
ffplay -i input -vf colorbalance=rs=-0.75:gs=-0.75:bs=-0.75:rm=-0.875:gm=-0.875:bm=-0.875:rh=-1:gh=-1:bh=-1
In photoshop I'm able to achieve the expected results with the following settings,
Shadows - 199
Midtones - midpoint
Highlights - 255
Use the colorlevels filter and interpolate the values to match Photoshop:
ffmpeg -i input.jpg -vf "colorlevels=rimin=199/255:gimin=199/255:bimin=199/255" -frames:v 1 output.jpg
Since you're only directly adjusting the input black points you only need to adjust *min
options as shown in the example.
If you're familiar with Curves in Photoshop you can save the preset and load the ACV file with the curves filter:
ffmpeg -i input.jpg -vf "curves=psfile=file.acv" -frames:v 1 output.jpg