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

Question about ippiGetAffineQuad

gast128
Beginner
502 Views

This is a bit of an XY problem. As a a start ippiGetAffineQuad seems to give a strange answer. In the following code an identity matrix (see coeffs2) is applied to a rect2:

void TestGetAffineQuad()
{
   constexpr IppiRect rect2 = {0,0,3,3};
   double quad[4][2] = {};
   constexpr double coeffs2[2][3]={{1,0,0},{0,1,0}};

   IppStatus st = ippiGetAffineQuad(rect2, quad, coeffs2);
}

The quad answer is {(0, 0), (2,0), (2,2), (0,2)} but I expected to be with coordinates 3 (i.e. {(0,0), (3,0), (3,3), (0,3)}) since width and height is 3. If the rect has dimension 5 it comes back with 4 in the quad. We use IPP 2022.3.0 which is part of the latest oneAPI 2025.3 download. 

 

Can anyone help? 

0 Kudos
1 Solution
James271Rivera
Beginner
485 Views

Hello

The behavior you’re seeing is due to how IppiRect defines width and height. In IPP, IppiRect uses exclusive coordinates: the rectangle spans from (x, y) up to but not including (x+width, y+height). So a rect {0,0,3,3} actually covers pixels (0,0) through (2,2), giving you a 3×3 region but with maximum coordinates at 2. That’s why ippiGetAffineQuad returns (0,0), (2,0), (2,2), (0,2) instead of (3,3).
If you want the quad to reach (3,3), you’d need to define the rect as {0,0,4,4}. In short: IPP rectangles are half-open intervals, so the “width” and “height” are counts, not max coordinates. 

View solution in original post

0 Kudos
4 Replies
James271Rivera
Beginner
486 Views

Hello

The behavior you’re seeing is due to how IppiRect defines width and height. In IPP, IppiRect uses exclusive coordinates: the rectangle spans from (x, y) up to but not including (x+width, y+height). So a rect {0,0,3,3} actually covers pixels (0,0) through (2,2), giving you a 3×3 region but with maximum coordinates at 2. That’s why ippiGetAffineQuad returns (0,0), (2,0), (2,2), (0,2) instead of (3,3).
If you want the quad to reach (3,3), you’d need to define the rect as {0,0,4,4}. In short: IPP rectangles are half-open intervals, so the “width” and “height” are counts, not max coordinates. 

0 Kudos
gast128
Beginner
475 Views

Thx, I never thought of that myself. The quad and coeffs are in double coordinates so that put me on the wrong track assuming the same behavior for a rectangle.

0 Kudos
gast128
Beginner
466 Views

...not sure if it is solved btw since it seems that ippiGetAffineTransform does include the border. Consider the following example:

void f()
{
    static constexpr IppiRect rect2 = { 1, 1, 5, 5 };
    static constexpr double dstQuad2[4][2] =
            {{1.0, 1.0}, 
             {5.0, 1.0}, 
             {5.0, 5.0}, 
             {1.0, 5.0}};

    double coeffs[2][3] = {};
    IppStatus st = ippiGetAffineTransform(rect2, dstQuad2, coeffs);
}

This gives the identity matrix which suggest that here the borders are inclusive.

 

0 Kudos
gast128
Beginner
463 Views

N.v.m.; can't edit / delete my own post. In my last example it's also exclusive border; 1 + width = 1 + 4 = 5 coordinate.

0 Kudos
Reply