Copyright © Fred Weinhaus My scripts are available free of charge for non-commercial (non-profit) 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 Please read the Pointers For Use on my home page to properly install and customize my scripts. |
Transfers the coloring from one image to another image. |
last modified: December 16, 2018
USAGE: transfercolor [-c colormode] [-p printcoefs] infile1 infile2 outfile
-c ... colormode ... colorspace mode of processing; options are: rgb, PURPOSE: To transfer the coloring of one image to another image. DESCRIPTION: TRANSFERCOLOR transfers the coloring from one image to another image. Specifically, the coloring of infile2 will be transfered to that of infile1. (infile1 will be colormatched to infile2). This is done via a linear transformation of each channel of the image after changing colorspace. The matching uses the mean and standard deviations from each channel according to the equation: (I2-Mean2)/Std2 = (I1-Mean1)/Std1. This equation represents an normalized intensity such that it has zero mean and approximately the same range of values due to the division by the standard deviations. We solve this equation to form a linear transformation between I1 and I2 according to I2=A*I1+B, where A=(Std2/Std1) is the slope or gain and B=(Mean2-A*Mean1) is the intercept of bias. ARGUMENTS: -c colormode ... COLORMODE is the colorspace mode of processing. The options are: rgb, lab or ycbcr. The default=lab. -p printcoefs ... PRINTCOEFS prints the linear coefficients to the terminal; options are yes or no. The default=no. CAUTION: This script may not be backward compatible prior to IM 6.8.6.0, when IM colorspace and grayscale changed. I have not tested it for earlier releases. Let me know if anyone tries and it fails. See http://www.imagemagick.org/discourse-server/viewtopic.php?f=4&t=21269
REFERENCES: 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. |
Example 1 |
Image 1 |
Image 2 |
Arguments: |
Arguments: |
Arguments: |
Example 2 |
Image 1 |
Image 2 |
Arguments: |
What the script does is as follows:
This is equivalent to the following IM commands
|