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.

RGBDOTS


Transforms an image into dots in primary and secondary colors.

Download Script

last modified: May 25, 2018



USAGE: rgbdots [-c color] [-t threshold] infile outfile
USAGE: rgbdots [-h or -help]

-c ... color ....... color to use to fill spaces; any opaque IM color is allowed;
.................... default=white
-t ... threshold ... threshold value in percent; 0<=integer<=100; default=50

PURPOSE: To transform an image into dots in primary and secondary colors.

DESCRIPTION: RGBDOTS transforms an image into dots in primary and secondary colors. The process uses a tiling of red, green1, blue pixels and thresholds the logical AND combination of the tiled image with the original channel-by-channel.

ARGUMENTS:

-c color ... COLOR to use to fill spaces. Any opaque IM color is allowed. The default=white

-t threshold ... THRESHOLD value in percent; 0<=integer<=100; default=50

CREDITS: Logical AND concept credited to Alan Gibson

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


Example 1

Original Image

Arguments:
-c white -t 50
(defaults)
Arguments:
-c white -t 25
Arguments:
-c white -t 75
Arguments:
-c red -t 50


Example 2

Original Image

Arguments:
-c white -t 50
(defaults)


Example 3

Original Image

Arguments:
-c white -t 50
(defaults)


Example 4

Original Image

Arguments:
-c white -t 50
(defaults)


What the script does is as follows:

  • read the input image
  • creates a tiled image from 1 pixel each of red, green, blue
  • does an evaluate-sequence and between the tiled image and the original
  • thresholds each channel separate
  • writes the result as output

This is equivalent to the following IM commands

  • convert "$infile" \
    \( \( -size 1x1 xc:red xc:green1 xc:blue -append \) \
    \( -size 3x1 xc:$color \) \
    -background white +append +write mpr:colors +delete \) \
    \( -clone 0 -tile mpr:colors -draw "color 0,0 reset" \) \
    -evaluate-sequence And \
    -channel RGB -threshold $threshold% +channel \
    "$outfile"