Community
cancel
Showing results for 
Search instead for 
Did you mean: 
reportbase
Beginner
54 Views

Rotating a buffer with ippiRotate_

Jump to solution
I want to flip the following buffer upside down. See example source and destination.

source (src):

01 02 03
04 05 06
07 08 09

destination (dst - correct):

07 08 09
04 05 06
01 02 03

The following sample does not rotate the buffer correctly. What am I doing wrong?

unsigned char src [9] = {1,2,3,4,5,6,7,8,9};
IppiSize size = {3,3};
IppiRect roi = {0,0,3,3};
unsigned char dst [9];
int step = 3;

IppStatus status = ippiRotate_8u_C1R(src, size, step, roi, dst, step, roi, 90, 0, 0, IPPI_INTER_LINEAR);

destination (dst - wrong):

01 04 07
00 00 00
00 58 C3
0 Kudos

Accepted Solutions
matthieu_darbois
New Contributor III
54 Views
Hi,

What you want to do is not a rotation. As you said, it's a flip. For this, use the ippiMirror function.

Best Regards,
Matthieu

View solution in original post

3 Replies
matthieu_darbois
New Contributor III
55 Views
Hi,

What you want to do is not a rotation. As you said, it's a flip. For this, use the ippiMirror function.

Best Regards,
Matthieu

View solution in original post

Gennady_F_Intel
Moderator
54 Views
Hi,

What you want to do is not a rotation. As you said, it's a flip. For this, use the ippiMirror function.

Best Regards,
Matthieu,
For this partically case ( angle == 90) - yes, the Mirror function is the best choise,
but for arbitrary cases - first of all call ippiAddRotateShift(,,,,,) for computing shift values of an images... .
The function helps compute shift values xShift, yShift that should be passed to ippiRotate function for the rotation around (xCenter, yCenter) to take place.
For your cases, it seems to me that shiftY == 2 ...
--Gennady



oxydius
New Contributor I
54 Views
Instead of flipping your buffer, you should just process it backwards (in-place) for better performance.

Suppose you have 500x400 with step/pitch of 512, you should call IPP functions with the following :

pSrc = pBuffer + (height - 1) * step = pBuffer + 399 * 512;
srcRoi = { 500, 400 };
srcStep = -step = -512;

IPP will view the last row as the first, and jump by -512 pixels after every row.