Message Boards Message Boards

Gradient Wipes

GROUPS:

Some video editing and rapid development tools contain a transition called “gradient wipe.” A gradient wipe animates image A changing into image B based on a mask. Where the mask has high values, the transition is rapid. Where the mask has low values, the transition is slow. A typical gradient wipe uses a linear gradient as a mask, causing a wiping effect across the images as they change, or a radial gradient, causing image B to reveal from the center of image A.

There’s a lot of room for creativity in this arrangement, particularly in what image is used for the mask. For instance, if you use image A for the mask, the transition occurs first in the dark (or light) portions of image A. The mask can be a swirl or a zigzag pattern. Image A and image B can be negative versions of each other. The mask can be one channel of image B.

In this first example, I used text of varying values in the mask to reveal the letters one at a time.

Animated .gif of the first gradient wipe

Here I use a tri-layered cityscape to reveal the underimage.

animated .gif of the second gradient wipe

This last example causes the circular features of image B to appear first, followed by the background features.

animated .gif of the third gradient wipe

The Wolfram Language code below creates a gradient wipe. Load whatever .jpg images you want into overImg, maskImg, and underImg. Here’s what the code does:

  • Resizes all three images to 400 × 300 (change for your needs)
  • Pulls the lightness channel from the mask image
  • Makes a series of frames from white to black based on the mask
  • Replaces the alpha data in the top image with each of the frames
  • Composes the series of top images (now with alpha) to the bottom image
  • Outputs an animation (change for your needs)

    overImg = Image[, ImageSize -> {400, 300}];
    underImg = Image[, ImageSize -> {400, 300}];
    maskImg = Image[, ImageSize -> {400, 300}];
    mask = Image[ColorSeparate[maskImg, "L"]];
    frames = Table[ImageAdjust[mask, {.35, 0, b}], {b, Table[10^n, {n, -1.5, 1.5, .15}]}];
    picData = ImageData[overImg];
    outData = (MapThread[({#1[[1]], #1[[2]], #1[[3]], #2}) &, {picData, ImageData[#]}, 2]) & /@ frames;
    picOut = Flatten[Append[Prepend[ImageCompose[underImg,Image[#, ColorSpace -> "RGB", ImageSize -> 400]] & /@ outData, Table[overImg, 3]], Table[underImg, 3]]];
    ListAnimate[picOut]
    

Enjoy,

Mark Greenberg

POSTED BY: Mark Greenberg
Answer
4 months ago

Cool!

POSTED BY: l van Veen
Answer
4 months ago

enter image description here - Congratulations! This post is now a Staff Pick as distinguished on your profile! Thank you, keep it coming!

POSTED BY: Moderation Team
Answer
3 months ago

Group Abstract Group Abstract