Fred's ImageMagick Scripts



    Licensing:

    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.

MODE


Computes the mode value of an image.

Download Script

last modified: December 15, 2018



USAGE: mode [-p processing] [-d depth] infile
USAGE: mode [-h or -help]

-p ... processing ... processing of images; choices are: gray (convert
..................... to grayscale first), global (append all channels
..................... into one grayscale image), all (process each
..................... channel separately) and color (find an rgb triplet);
..................... default=color
-d ... depth ........ preprocessing depth; 1<=integer<=8; default=8

PURPOSE: To compute the mode value of an image.

DESCRIPTION: MODE computes the mode value of an image. The mode is the most frequent color or graylevel in the image. In other words, it is that color or graylevel that has the largest count in the histogram. The user may choose either to process the image to grayscale, to append all the channels into one

ARGUMENTS:

-p processing ... PROCESSING of the images. The choices are: gray (convert to grayscale first), global (append all channels into one grayscale image), all (process each channel separately) and color (find an rgb triplet). The default=color

-d depth DEPTH is the preprocessing image depth. Values are integers between 1 and 8, inclusive. The default=8.

NOTE: This script will process only the first frame/page of a multiframe or multipage 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.


EXAMPLES


Input Image

Arguments:

Mode

-p color

color: srgb(158,139,131)

-p global

global: 139

-p gray

gray: 139

-p all

red: 158
green: 139
blue: 131

-p color -d 4

color: srgb(153,136,119)



What the script does is as follows:

  • Generates the textual histogram
  • Finds the most frequent bin of the histogram

See the script for actual code details.