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. |
Computes the dominant color in an image. |
last modified: December 18, 2021
USAGE: dominantcolor [-m mode] [-n numcolors] [-e excludecolor]
[-f fuzzval] [-p print] [-s swatches] infile
-m ... mode ........... mode of processing; options are: 1=unrestricted PURPOSE: To find the dominant color in an image. DESCRIPTION: Finds the dominant color or selected number of colors in an image. Modifiers can be used to restrict colors in the image. The alpha channel will be disabled for this script. -m mode ... MODE of processing. The options are: 1=unrestricted colors, 2=exclude black, 3=exclude white, 4=exclude any color, 5=only high saturation colors, 6=only high saturation and brightness colors. The default=1. -n numcolors ... NUMCOLORS is the number of colors to consider during color reduction. Values are integers>1. The default=6. -e excludecolor ... EXCLUDECOLOR is an exclude color to be ignored in getting the dominant color. Any valid opaque IM color. The default=black for -m 4; otherwise, not used. -f fuzzval ... FUZZVAL is the fuzz value for modes 2-6. Smaller values select colors closer to the mode desired, but may lead to less than the selected numcolors. Values are 0<=integers<=100; The default=50. -p print ... PRINT options: all (hexcolors and counts for all numcolors) or dominant (only the hexcolor for the dominant color. The default=dominant. -s swatches ... view or save SWATCHES for option -p print. Choices are: view (v) or save (s). The default is no swatches. If save, then the output will be named with either _dominantcolor or _swatches appended to the input name as a gif image. 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 | ||
Original Image | ||
Arguments |
Swatches |
Counts vs Hexcolor |
-m 1 -n 6 -p all -s save |
1043 #3D3F39 |
|
-m 2 -n 6 -f 50 -p all -s save |
821 #737D91 |
|
-m 6 -n 6 -f 50 -p all -s save |
592 #466C94 |
|
-m 6 -n 6 -f 50 -p dominant -s save |
#466C94 |
Example 2 | ||
Original Image | ||
Arguments |
Swatches |
Counts vs Hexcolor |
-m 1 -n 6 -p all -s save |
2352 #FFFFFF |
|
-m 3 -n 6 -f 50 -p all -s save |
922 #24A1E2 |
|
-m 3 -n 6 -f 50 -p dominant -s save |
#24A1E2 |
Example 3 | ||
Original Image | ||
Arguments |
Swatches |
Counts vs Hexcolor |
-m 1 -n 6 -p all -s save |
622 #1B2505 |
|
-m 2 -n 6 -f 30 -p all -s save |
1009 #556902 |
|
-m 2 -n 6 -f 40 -p all -s save |
667 #E62F0C |
|
-m 3 -n 6 -f 40 -p dominant -s save |
#E62F0C |
What the script does is as follows:
See the script for more details |