Fred's ImageMagick Scripts



    Licensing:

    Copyright © Fred Weinhaus

    My scripts are available free of charge for non-commercial use, ONLY.

    For use of my scripts in commercial (for-profit) environments or non-free applications, please contact me (Fred Weinhaus) for licensing arrangements. My email address is fmw at alink dot net.

    If you: 1) redistribute, 2) incorporate any of these scripts into other free applications or 3) reprogram them in another scripting language, then you must contact me for permission, especially if the result might be used in a commercial or for-profit environment.

    Usage, whether stated or not in the script, is restricted to the above licensing arrangements. It is also subject, in a subordinate manner, to the ImageMagick license, which can be found at: http://www.imagemagick.org/script/license.php

COLORTEMP


Transforms an image's overall color balance according to a desired color temperature change.

Download Script

last modified: April 25, 2015



USAGE: colortemp [-t temperatures] [infile] outfile
USAGE: colortemp [-h or -help]

-t ... temperture(s) .... t1[,t2]; 1000 to 40000 deg K
......................... t1=desired temperature; t2=current temperature;
......................... t2 default=pure white (near 6500)
-f ... fov .............. fov=field of view for observation;
......................... fov=2 or 10 deg; default=2
infile outfile .......... if no infile and no temperature provided, then
......................... outfile will be a color vs temperature chart;
......................... if no infile but t1 provided, then outfile
......................... will be a color swatch for the provided temperture;
......................... if infile and t1[,t2] provided, then infile will
......................... be color transformed to generate the outfile
......................... according to the temperture(s) provided

PURPOSE: To transform and image's overall color balance according to a desired color temperature change.

DESCRIPTION: COLORTEMP transforms an image's overall color balance according to a desired color temperature change. If no infile and no temperature is provided, the script will generate a color vs temperature chart. If no infile is provided, but a desired temperature is specified, then the script will generate a color swatch for the specified temperature.

ARGUMENTS:

-t temperature(s) ... TEMPERATURE(S) specifies the desired (t1) temperature and the current (t2) temperature. Values range from 1000 to 40,000 deg K. The default for t2 is pure white which is near 6500 deg K.

-f fov ... FOV is the observer's field of view. Allowed values are fov=2 or 10 deg. The default is 2. Differences in color temperature are slight between the two.

infile outfile ... If no infile and no temperature are provided, then outfile will be a color vs temperature chart. If no infile but t1 is provided, then outfile will be a color swatch for the provided temperture. If infile and t1[,t2] provided, then infile will be color transformed to generate the outfile according to temperture(s) provided.

Requires NetPBM (http://netpbm.sourceforge.net/)

CAVEAT: No guarantee that this script will work on all platforms, nor that trapping of inconsistent parameters is complete and foolproof. Use At Your Own Risk.

Some Common Illumination Color Temperatures
See http://www.etconsult.com/papers/whitepoint.pdf

Source Degrees K
Artificial Light 
Candle Flame1850
100-Watt Incandescent Tungsten Lamp2865
3200-Degree Kelvin Tungsten Lamp3200
White Flame Carbon Arc Lamp5000
Xenon Arc Lamp6420
Daylight Light 
Sunlight: Sunrise or Sunset2000
Sunlight: One Hour After Sunrise3500
Sunlight: Early Morning4300
Sunlight: Late Afternoon4300
Average Summer Sunlight at Noon (Washington, D.C.)5400
Direct Mid-Summer Sunlight5800
Overcast Sky6000
Average Summer Sunlight (plus blue skylight)6500
Light Summer Shade7100
Average Summer Shade8000
Summer Skylight Will Vary from 9500 to 30000

EXAMPLES


Color Temperature Transformation Of An Image

Original Image

Arguments:
-t 2000

Arguments:
-t 3000

Arguments:
-t 5000

Arguments:
-t 8000

Arguments:
-t 13000

Arguments:
-t 40000



Color vs Temperature Chart

Arguments:
-f 2

Arguments:
-f 10



Color Swatches

Arguments:
-t 1000

Arguments:
-t 2000

Arguments:
-t 3000

Arguments:
-t 5000

Arguments:
-t 6500

Arguments:
-t 8000

Arguments:
-t 13000

Arguments:
-t 40000



What the script does is as follows:

  • Interpolates a color for a specified temperature from a table
  • Determines the red, green and blue ratios for the desired
    vs current temperatures
  • Determines the recolor transformation matrix entries from
    the color ratios
  • Applies the recolor matrix using -recolor to modify the
    input image's overall color balance

This is equivalent to the following IM commands:

  • convert $infile -recolor "$redfrac 0 0 0 $greenfrac 0 0 0 $bluefrac" $outfile