Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.

help with GetAffineTransform

Hi all,
Please help me debug the following:

I have a pair of lines sampled from 2 images, along the x-axis at coordinates Level1 and Level2, and along the y-axis at coordinates Level3 and Level4. This defines a quadilateral, which i define as

IppiRect roi;
roi.x = Level1;
roi.y = Level3;
roi.width = Level2 - Level1 + 1;
roi.height = Level4 - Level3 + 1;

// Then I calculate lags for maximum cross-correlation for each pair:
LagLevel3 = Xcorr(frame1, frame2, Level3,0);
LagLevel4 = Xcorr(frame1, frame2, Level4,0);
LagLevel1 = Xcorr(frame1, frame2, Level1, 1);
LagLevel2 = Xcorr(frame1, frame2, Level2, 1);
//where Xcorr is the function, and frame1 and fram2 2 are the images. 0 and 1 denote the column or row //sampling flag. Things are fine till this stage.
// I then create the deformed quadilateral based on this lag value for each pair, for each direction:
quad[0][0] = Level1 -LagLevel1;
quad[0][1] = Level3 - LagLevel3;

quad[1][0] = Level2 - LagLevel2;
quad[1][1] = Level3 - LagLevel3;

quad[3][0] = Level1 - LagLevel1;
quad[3][1] = Level4 - LagLevel4;

quad[2][0] = Level2 - LagLevel2;
quad[2][1] = Level4 - LagLevel4;

// where the subtraction has been used because of the "sense" in which Xcorr returns the values.
// this is followd by the usual:
st = ippiGetAffineTransform(roi, quad, coeffs);
// and the WarpAffine routine.

If everything works out fine, I would get an affine transform that would coarsly register the 2 frames. However, The registration works only when I do

quad[0][0] = Level1;
quad[0][1] = Level3 - LagLevel3;

quad[1][0] = Level2 ;
quad[1][1] = Level3 - LagLevel3;

quad[3][0] = Level1 ;
quad[3][1] = Level4 - LagLevel4;

quad[2][0] = Level2;
quad[2][1] = Level4 - LagLevel4;

The moment I change the values of Level1 and Level2 based on the lag, the registration goes off track, I am guessing this is beacuse the coeffs that are being generated are not correct.

Am I messing up the initial setting up of the roi and/or the quad? Is the logic of displacing the levels based on the corresponding lag correct, as given above?

Thanks for the help,
( o |
0 Kudos
3 Replies
Valued Contributor II
Quoting siddy
The moment I change the values of Level1 and Level2 based on the lag, the registration goes off track

Regarding'...registration goes off track...'. What about an error code? Did you check it?

0 Kudos
Yes, I do check for the status, and it says "No error, its OK" .
0 Kudos
New Contributor II
Hi, take a look at the note in the IPP manual:

ROI Processing in Geometric Transforms

All the transform functions described in this chapter operate in rectangular regions of interest (ROIs) that are

defined in both the source and destination images. The procedures for handling ROIs in geometric transform

functions differ from those used in other functions (see Regions of Interest in Intel IPP in chapter 2). The main

difference is that operations take place in the intersection of the transformed source ROI and the destination

ROI. More specifically, all geometric transform functions (except those which perform inverse warping operations)

handle ROIs with the following sequence of operations:

transform the rectangular ROI of the source image to quadrangle in the destination image;

find the intersection of this quadrangle and the rectangular ROI of the destination image;

update the destination image in the intersection area.

The coordinates in the source and destination images must have the same origin.

To fully describe a rectangular ROI, both its origin (coordinates of top left corner) and size must be referenced.

For geometrical transform functions, the source image ROI is specified by srcRoi parameter of IppiRect type,

meaning that all four values describing the rectangular ROI are given explicitly.

On the other hand, the destination image ROI for different functions can be specified either by dstRoi parameter

of IppiRect type, or dstRoiSize parameter of IppiSize type. In the latter case, only the destination ROI

size is passed, while its origin is referenced by pDst pointer.

(page 691)


0 Kudos