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

WATERCOLOR


Applies a watercolor effect to an image.

Download Script

last modified: September 26, 2017



USAGE: watercolor [-s smoothing] [-e edge] [-m mixing] [-c contrast] infile outfile
USAGE: watercolor [-h|-help]

-s ... smoothing ... smoothing of image texture; integer>=0; default=0 (no smoothing)
-e ... edge ........ edge gain; float>=1; default=5
-m ... mixing ...... mixing of edge content with smoothed image; 0<=integer<=100;
.................... larger is more edge content; default=33
-c ... contrast .... contrast increase factor; float>=0; default=0 (no change)

PURPOSE: To apply a watercolor effect to an image.

DESCRIPTION: WATERCOLOR applies a watercolor effect to an image.

ARGUMENTS:

-s smoothing ... SMOOTHING of image texture. Values are integers>=0. The default=0 (no smoothing). IMPORTANT: use odd integers to avoid image shift by half pixel.

-e edge ... EDGE gain. Values are floats>=1. The default=5.

-m mixing ... MIXINT of edge content with smoothed image. Values are 0<=integer<=100. Larger is more edge content. The default=33.

-c contrast ... CONTRAST increase factor. Values are floats>>=0. The default=0 (no change).

REFERENCE: http://www.photoshopessentials.com/photo-effects/watercolor-painting-photoshop-cs6/

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 - Variation in Mixing

Original
(original)

From Shutterstock
(source)

Arguments:
-s 0 -e 5 -m 33 -c 0

Arguments:
-s 0 -e 5 -m 50 -c 0



Example 2 - Variation in Smoothing

Original
(original)

From Shutterstock
(source)

Arguments:
-s 0 -e 5 -m 33 -c 0

Arguments:
-s 10 -e 5 -m 33 -c 0



Example 3 - Variation in Contrast

Original
(original)

From Shutterstock
(source)

Arguments:
-s 10 -e 5 -m 33 -c 0

Arguments:
-s 10 -e 5 -m 33 -c 10



Example 4

Original
(original)

Arguments:
-s 0 -e 5 -m 33 -c 0

Arguments:
-s 0 -e 5 -m 50 -c 0

Arguments:
-s 0 -e 5 -m 33 -c 5

Arguments:
-s 5 -e 5 -m 50 -c 5



Example 5

Original
(original)

Arguments:
-s 0 -e 5 -m 33 -c 0

Arguments:
-s 0 -e 5 -m 50 -c 0

Arguments:
-s 10 -e 5 -m 33 -c 0

Arguments:
-s 10 -e 5 -m 33 -c 10



Example 6

Original
(original)

Arguments:
-s 0 -e 5 -m 33 -c 0

Arguments:
-s 5 -e 5 -m 33 -c 5



Example 7

Original
(original)

Arguments:
-s 5 -e 5 -m 33 -c 5

Arguments:
-s 5 -e 10 -m 33 -c 5

Arguments:
-s 15 -e 5 -m 33 -c 5

Arguments:
-s 10 -e 10 -m 33 -c 5



What the script does is as follows:

  • Reads the input image
  • Increase contrast using -sigmoidal-contrast and
    smoothes using -mean-shif
  • Clones the result and applies sobel edge extraction
  • Luminize composites the two images
  • Blends the input and composite image to form the output

This is equivalent to the following IM commands

  • if [ $smoothing -ne 0 ]; then
    sproc="-mean-shift ${smoothing}x${smoothing}+10%"
    else
    sproc=""
    fi
  • if [ "$contrast" != 0 ]; then
    cproc="-sigmoidal-contrast ${contrast}x50%"
    else
    cproc=""
    fi
  • convert $tmpA1 $cproc $sproc \
    \( -clone 0 -define convolve:scale='!' \
    -define morphology:compose=Lighten \
    -morphology Convolve 'Sobel:>' \
    -negate -evaluate pow $edge \) \
    \( -clone 0 -clone 1 -compose luminize -composite \) \
    -delete 1 -define compose:args=$mixing -compose blend -composite \
    "$outfile"