You are here

Geometric Photo Manipulation - The Algorithm Explained

Author(s): 
Tom Farmer

The MATLAB programs perspective.m and orthographic.m are designed to produce the cube pictures of Figure 3, but the programs can be altered to generate an unlimited number of constructions, for example, the one in Figure 1 and those to appear in the next section. Here is an outline for such programs:

  • The beginning:

  1. Read the input image data into memory as an array. Let's call it inpic.

  2. Assign values to the parameters required by the perspective projection method. (We limit this outline to the perspective case, but the orthographic method has a very similar outline.) It's a good idea to express these values in terms of the dimensions of the input image so that one can experiment first with a very small input image and easily switch later to a larger image. This is important because programs can take a long time to run if the input image is large.

  3. Assign values to the estimated bounds on the calculated projection points, and initialize the output array called outpic by assigning the value "white" to each pixel. Also initialize the values of the z-buffer array.
  • The middle:

  1. Loop just once through the pixels of the input image. For each pixel , enter formulas for the desired positions of the envisioned object
    -- there will be one set of formulas for each copy of the image that is to be included in the object (e.g., the three visible faces of the cube in Figure 3). This is the primary way in which one construction differs from another. For each point , do the following:
  1. Calculate the projected point and the corresponding output array address;

  2. Compute the distance from to the point , and proceed to (c) only if the distance is smaller than the one held in the z-buffer for that output array address;

  3. Change the corresponding output array value (all three RGB levels) to inpic(i,j), and update the z-buffer value by assigning as the new value the distance computed in step b.
  • The ending:
  1. Save and/or print the output array as an image.

JOMA

Journal of Online Mathematics and its Applications

Dummy View - NOT TO BE DELETED