CS 432 Project 2: Geometric Warping *

In this project you will create a Khoros kroutine which performs a control grid warping operation [See 8.3.5 of Castleman]. The user specifies the position of four control points. These define the central quadrilateral of an irregular 3 x 3 grid. The geometric warping operation maps the irregular 3 x 3 grid to a regular 3 x 3 grid, i.e., it maps each of the nine quadrilateral shaped regions in the source image to a corresponding rectangular shaped region in the target image (see Figure 1 below).


To accomplish this, you will use a target-to-source mapping strategy. This is facilitated by the fact that the regions of the target grid are rectangular and aligned with the rows and columns of the image as it is stored in memory. You will use bilinear interpolation to compute the displacements (dx and dy) which map a pixel in the target image to a point in the source image. Since you know 1) the values of dx and dy at the four corners of the rectangle; and 2) the width and height (X and Y) of the rectangle (see Figure 2 below), the following equations allow you to compute dx and dy at location (x,y) inside the rectangle:


Given the displacements, dx and dy, and the indices of the pixel in the target image, i and j, the location in the source image is simply (i-dx,j-dy). You will then need to use bilinear interpolation a third time to compute the value of the intensity of the pixel in the target image given the values of the intensities of the four pixels which straddle location (i-dx,j-dy) in the source image:

where I(0,0) is I(floor(i-dx),floor(j-dy)), I(0,1) is I(floor(i-dx),ceil(j-dy)), etc. Note also that x and y are now the differences between (i-dx,j-dy) and (floor(i-dx),floor(j-dy)) and that X=Y=1.

Project Outline

  1. Using Craftsman, create a toolbox.
  2. Using Craftsman, create a kroutine and call it kgridwarp.
  3. Create the GUI using Guise. Make eight input parameters of type FLOAT to represent the coordinates of the corners of the central quadrilateral of the source grid.
  4. After saving the .pane file and exiting Guise, open the Command submenu of Composer and generate kgridwarp.c and associated files.
  5. Using cut and paste, edit kgridwarp.c so that it resembles the template provided below.**
  6. Add your own code.
  7. Select Make Install in the Command submenu of Composer to make and install the kroutine.
  8. Test it in Cantata.

Code Template

You can download a template of the kroutine by clicking here. This template includes all Khoros system calls, helpful macros to access pixels, variables to hold the dimensions of the value segment, and pointers to the input and output data. Places where you can define additional variables, add your own code and define additional procedures are indicated by comments.

Hints

What It Should Look Like


An oblique aerial image of a church.


Same image after geometric warping operation.

What You Should Hand In ***

  1. A well documented listing of kgridwarp.c
  2. Hardcopy of an input image of your choice.
  3. Hardcopy of the same image after geometric warping.
  4. A screen dump of the GUI for your kroutine showing its layout and the values of the input parameters used to create the output image.

When You Should Hand It In

The above items should be handed in at the beginning of class on Wed. Mar. 1, 2000.

* This webpage is located at http://cs.unm.edu/~williams/cs432/project2s00.html
** Alternatively, you can find kgridwarp.c under the toolboox directory hierarchy and replace it with the template.
*** Curtis Sirl-Moore and James Corey didn't find the above project challenging enough (and obviously have way too much free time on their hands). Click here to see one of their more advanced experiments with geometric warping.