Tiling Example (continued)

The code below is an example of handling the interfaces of regions. In this example, the function iplWarpAffine() is called to resize two adjacent fragments of the source image with a constant magnification. (Resizing is just a special case of affine transform.) The function iplGetAffineBound() is used for determining the coordinates of pixels in the source image that are mapped to the destination image's ROI.

Note that both source ROIs in this code include the pixels with the coordinate y=half. This is necessary for a seamless transition at the interface of the resized fragments.

To run the example from the applet, choose Affine for zooming.

To run the example from the command line, type:
> tile -ff -h [-e]
Use -e (error) to see the results of this example code called with incorrect bounds of the image fragments.

The source:

double zoomCoeffs[2][3] = {{1,0,0}, {0,3.14159,0}};
double inverseCoeffs[2][3] = {{1,0,0}, {0,1/3.14159,0}};
double bounds[2][2];

int half = dstimg->height/2 | 1;

IplROI srcroi, dstroi;
srcimg->roi = &srcroi;
dstimg->roi = &dstroi;

iplSetROI( &dstroi, 0, 0, half, dstimg->width, dstimg->height-half );
iplGetAffineBound( dstimg, inverseCoeffs, bounds );
int inLeft = (int)(bounds[0][0]);
int inTop = (int)(bounds[0][1]);
int inRight = (int)(bounds[1][0]+0.5);
int inBottom = (int)(bounds[1][1]+0.5);
iplSetROI( &srcroi, 0, inLeft, inTop, inRight-inLeft+1, inBottom-inTop+1 );
iplWarpAffine( srcimg, dstimg, zoomCoeffs, IPL_INTER_CUBIC );

iplSetROI( &dstroi, 0, 0, 0, dstimg->width, half+1 );
iplGetAffineBound( dstimg, inverseCoeffs, bounds );
inLeft = (int)(bounds[0][0]);
inTop = (int)(bounds[0][1]);
inRight = (int)(bounds[1][0]+0.5);
inBottom = (int)(bounds[1][1]+0.5);
iplSetROI( &srcroi, 0, inLeft, inTop, inRight-inLeft+1, inBottom-inTop+1 );
iplWarpAffine( srcimg, dstimg, zoomCoeffs, IPL_INTER_CUBIC );

dstimg->roi = srcimg->roi = NULL;

* Legal Information © 1998-2000, Intel Corporation