Return values for overall image brightness, contrast and saturation

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
TheWox
Posts: 1
Joined: 2019-04-16T07:30:56-07:00
Authentication code: 1152

Return values for overall image brightness, contrast and saturation

Post by TheWox »

Hi all.

I am looking to generate point values that would represent an image's overall brightness, contrast and degree of colour saturation.

I see the verbose identify command doesn't show these, and I haven't been able to find a definitive set of command line arguments that produce a predictable result. Can anyone advise?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Return values for overall image brightness, contrast and saturation

Post by snibgo »

There are different definitions for "saturation". Personally, I use the C channel of HCL. You might prefer S of HSL, or something else.

For example:

Code: Select all

magick toes.png -colorspace HCL -format "light=%[fx:mean.b]\ncont=%[fx:standard_deviation.b]\nsat=%[fx:mean.g]" info:

light=0.495456
cont=0.146745
sat=0.114103
These are on a scale of 0.0 to 1.0, although the maximum standard_deviation for small images, in recent IM, is sqrt(1/2) = 0.707107.
snibgo's IM pages: im.snibgo.com
Post Reply