CS1315: Introduction to Media Computation Feature Based Image Morphing Image Morphing Examples Technique This technique is based Beier-Neely feature-based image metamorphosis paper http://www.hammerhead.com/thad/morph.html Feature Based Morphing The idea of feature based morphing is that lines are drawn over prominent features in each image, e.g. eyes, nose, mouth, etc. Over time the lines in the source image are moved towards the lines in the destination image, which creates the warping effect on the image While the lines are moving, the surrounding pixels are transformed based on the movement A cross-dissolve, or a type of blending, is performed to transform the colors of the source image to the colors of the destination image Single Line Transformation We define a line from point P’ to point Q’ in the source image We define another line from point P to point Q in the destination image Single Line Transformation For each pixel in the destination image, we calculate three values to remap the current pixel in the source image caused by the line warping u is the position along the from P to Q v is the perpendicular distance from the line from P to Q X’ is the re-mapped pixel value u = (X-P)*(Q-P) ||Q-P||^2 v = (X-P)*Perp(Q-P) ||Q-P|| X’ = P’ + u*(Q’-P’) + v*Perp(Q’-P’) ||Q’-P’|| Note: * is the dot product Single Line Transformation Example: The destination image pixel at (50, 35) is replaced with the source image pixel at (80, 56) Multiple Line Transformations Generating the warping effect with multiple lines is basically the same as with a single line, but the u, v, and X’ calculations are performed by comparing each pixel to each line in the list of lines Because different lines should effect pixels more or less, depending on relative location and line length, three new constants are introduced a = line strength by proximity b = line strength by relative distance If a is barely > 0, if line is very close to the pixel, the strength is nearly infinite. Larger values provide smoother warping, but less preciseness. Typical Range: [0.5, 2] If b is 0, all lines contribute equally regardless of distance p = line strength by weight Typical Range: [0, 1] If p is 0, all lines have same weight, if p is 1 longer lines have greater weight than shorter lines Multiple Line Transformations These new constants a, b, and p are used to calculate a weight that is added to the X’ pixel value to adjust the value according to relative line strength weight = ( length^p / (a + distance) )^b Add more details here Morphing Two Images The source image lines and destination image lines are interpolated over time. This provides a gradual transition from the source image to the destination image To provide the best looking morph, the source lines and the destination lines are is warped towards the interpolated lines. This allows the features to line up for each frame and generates a more smooth and gradual morph As the lines are warped, the images are cross-dissolved to enhance the transition Cross-Dissolve Add code here Morphing Movie Once all the morphing frames are created and saved to a new image, the frames can be turned into a movie Add movie code calls here