Best automatic levels and color correction (preserving human flesh colors)

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
Elapido
Posts: 42
Joined: 2011-06-10T14:27:28-07:00
Authentication code: 8675308

Best automatic levels and color correction (preserving human flesh colors)

Post by Elapido »

I work with hundreds of photos, all of them human portraits and human bodies. Many of them have wrong levels (poor contrast). If you take a look a their histograms you can see that the left end (shadows) is not filled, or maybe the right end (lights) or even both ends. I have made a script with Autohotkey and using Imagemagick to spot those images that do not fill the histogram correctly. It works well. However, I've been trying to automate also the level and color correction of these images and the results are not always good. I've tried with Imagemagick commands, and also with Photoshop automations (auto tone), and also with ACDSee automatic corrections. In most cases, the levels are correctly adjusted. However, the problem is that sometimes the adjustment of shadows adds too much saturation to the images, so the flesh becomes too red. Therefore, I have to manually reduce saturation with Photoshop and sometimes move the tone slider a bit to the right (to add a little of green to the color of the flesh, which sometimes is too pink). I wonder if there are some commands, set of commands or scripts made with Imagemagick to work specifically with portraits, in the sense that the color of the flesh is prioritized, avoiding so some horrible results such as people looking reddish or greenish. Is this possible or should I have to wait for some kind of artificial intelligence program that is able to correct levels and colors like I would do in multiple steps and depending on the problems of each photo?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Best automatic levels and color correction (preserving human flesh colors)

Post by snibgo »

Increasing contrast by spreading levels in red, green and blue channels will have a side-effect of increasing saturation and changing hue. This is especially true when the spreading occurs in the shadows rather than the highlights.

To avoid this, you can convert the image to another colorspace that has a "lightness" channel, then spread the levels in that channel only, then convert back. So the tones are spread, but chromaticity is unchanged. For example (Windows syntax):

Code: Select all

magick ^
  in.png ^
  -colorspace Lab ^
  -channel 0 ^
  -auto-level ^
  +channel ^
  -colorspace sRGB ^
  out.png
If your main concern is with flesh tones, you may find that YCbCr gives better results than Lab.
snibgo's IM pages: im.snibgo.com
Elapido
Posts: 42
Joined: 2011-06-10T14:27:28-07:00
Authentication code: 8675308

Re: Best automatic levels and color correction (preserving human flesh colors)

Post by Elapido »

Excellent! I have tried with some photos and it's true that the colors are preserved. Tonight I will pick some of the photos that had very poor results with Photoshop's autotone and see what happens. Thank you.
Post Reply