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.

SHAPEMORPH2


Creates a shape morphing animation sequence between two images.

Download Script

last modified: December 15, 2018



# USAGE: shapemorph2 -c1 cpts1 -c2 cpts2 [-f frames] [-d delay] [-p pause] [-r] [-b bcolor] infile1 infile2 outfile # shapemorph2 [-h or -help]

# -c1 cpts1 control point x,y coordinates in infile1 # -c2 cpts2 control point x,y coordinates in infile1 # -f frames number of frames in animation; frames>1; default=20 # -d delay delay between frames; delay>0; default=10 # -p pause pause delay for two undistorted input images; # pause>0; default=100 # -r reverse the animation sequence and append it to the end # -b bcolor background color when morph distortion goes off the images; # default=black

PURPOSE: To create a shape morphing animation sequence between two images.

# DESCRIPTION: SHAPEMORPH2 creates a shape morphing animation sequence between # two images using multiple corresponding control point specified from each of # the two input images. The control points along with the four fixed corners # actually form the set of control points that are used to fill out X and Y # displacement maps (images) that are then used to transform the geometry of # each image to the other. The corresponding frames from the transformation # of each image are then blended proportional to the progression of frames.

ARGUMENTS:

# -c1 cpts1 ... CPTS1 is a list of the x,y pairs of control points for infile1. # This argument is mandatory and must have atleast one x,y pair. Points must be # listed in the same order as the corresponding points in infile2.

# -c2 cpts2 ... CPTS2 is a list of the x,y pairs of control points for infile2. # This argument is mandatory and must have atleast one x,y pair. Points must be # listed in the same order as the corresponding points in infile1.

-f frames ... FRAMES is the total number of frames in the animation (including infile1 and infile2 as the start and end frames. Values are integers > 1. The default is 20.

-d delay ... DELAY between frames. Values are integers>0. The default=10

-p pause ... PAUSE is the delay to use for the first and last frame of the animation, i.e. the delay for each of the input images. The default=100

-r ... If supplied, then reverse the animation sequence, remove the first and last frames of the reversed sequence and append these reversed frames to the end of the animation.

# -b bgcolor ... BGCOLOR is the background color to use when the morph # distortion goes off either image. The default=black. A value of none # can be used for transparency for the background.

# REQUIREMENTS: IM 6.4.2-4 or higher due to the use of -distort shepards.

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


1 Control Point Morphing

Image 1

Image 2

Arguments:
-c1 "73,56" -c2 "57,68" -r
(control point at the
noses on the faces)



5 Control Points Morphing

Image 1

Image 2

Arguments:
-c1 "73,56 53,38 65,80 63,4 94,38"
-c2 "57,68 39,50 52,99 53,13 66,52"
-r
(control points at the noses,
eyes on left side of image, chins,
top of foreheads,
opposite side of face from eye)



What the script does is as follows:

  • Warps each image with progressively interpolated control points
    using Shepard's method of inverse weighted averaging (-distort shepards)
  • Progressively blends each pair of transformed images to form a
    frame of the output animation