Digital image warping

George Wolberg

Mentioned 1

This best-selling, original text focuses on image reconstruction, real-time texture mapping, separable algorithms, two-pass transforms, mesh warping, and special effects. The text, containing all original material, begins with the history of the field and continues with a review of common terminology, mathematical preliminaries, and digital image acquisition. Later chapters discuss equations for spatial information, interpolation kernels, filtering problems, and fast-warping techniques based on scanline algorithms.

More on

Mentioned in questions and answers.

Basically I was trying to achieve this: impose an arbitrary image to a pre-defined uneven surface. (See examples below).

Any image --> enter image description here

I do not have a lot of experience with image processing or 3D algorithms, so here is the best method I can think of so far:

  1. Predefine a set of coordinates (say if we have a 10x10 grid, we have 100 coordinates that starts with (0,0), (0,10), (0,20), ... etc. There will be 9x9 = 81 grids.
  2. Record the transformations for each individual coordinate on the t-shirt image e.g. (0,0) becomes (51,31), (0, 10) becomes (51, 35), etc.
  3. Triangulate the original image into 81x2=162 triangles (with 2 triangles for each grid). Transform each triangle of the image based on the coordinate transformations obtained in Step 2 and draw it on the t-shirt image.

Problems/questions I have:

  1. I don't know how to smooth out each triangle so that the image on t-shirt does not look ragged.
  2. Is there a better way to do it? I want to make sure I'm not reinventing the wheels here before I proceed with an implementation.


This is called digital image warping. There was a popular graphics text on it in the 1990s (probably from somebody's thesis). You can also find an article on it from Dr. Dobb's Journal.

Your process is essentially correct. If you work pixel by pixel, rather than trying to use triangles, you'll avoid some of the problems you're facing. Scan across the pixels in target bitmap, and apply the local transformation based on the cell you're in to determine the coordinate of the corresponding pixel in the source bitmap. Copy that pixel over.

For a smoother result, you do your coordinate transformations in floating point and interpolate the pixel values from the source image using something like bilinear interpolation.