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

ippirotate in ipp 9.0

steffenroeber
Beginner
885 Views

Hi,

i'm trying to migrate to 9.0. I found that ippirotate isno longer available and I found an article how to roate using warping functions. But that does not work. I want to rotate around the image center and the destination image resize is enlarged to show the whole rotated image:

IppiSize srcSize = { i_src.getWidth(), i_src.getHeight() };
  IppiRect srcRect = { 0, 0, i_src.getWidth(), i_src.getHeight() };
  float64 coeffs[2][3];
  float64 bound[2][2];
  float64 shiftX;
  float64 shiftY;
  auto status = ippiGetRotateShift(srcSize.width / 2, srcSize.height / 2, degrees, &shiftX, &shiftY);
  status = ippiGetRotateTransform(degrees, -shiftX, shiftY, coeffs);
  status = ippiGetAffineBound(srcRect, bound, coeffs);
  IppiSize dstSize = { bound[1][0] - bound[0][0] + 1, bound[1][1] - bound[0][1] + 1 };
  cImg dstImg(i_src.getImgType().getTypeId(), dstSize.width, dstSize.height);
  sint32 specSize = 0;
  sint32 bufferSize = 0;
  float64 borderValue[] = { 0 };
  status = ippiWarpAffineGetSize(srcSize, dstSize, ipp8u, coeffs, ippLinear, ippWarpForward, ippBorderConst, &specSize, &bufferSize);
  IppiWarpSpec *spec = reinterpret_cast<IppiWarpSpec *>(ippsMalloc_8u(specSize));
  status = ippiWarpAffineLinearInit(srcSize, dstSize, ipp8u, coeffs, ippWarpForward, 1, ippBorderConst, borderValue, 0, spec);
  m_buffer.resize(bufferSize);
  IppiPoint dstOffset = { 0, 0 };
  status = ippiWarpAffineLinear_8u_C1R(i_src.getPixel<uint8>(0, 0), i_src.getYPitch(),
                                       dstImg.getPixel<uint8>(0, 0), dstImg.getYPitch(), dstOffset, dstSize, spec, m_buffer.data());

 

But the resulting image is wlays slightly outside the image boundaries.

0 Kudos
4 Replies
Chao_Y_Intel
Moderator
885 Views

Hello, 

I attached an rotate example with Affine,   could you have have if it works for your? 

Thanks,
Chao

0 Kudos
steffenroeber
Beginner
885 Views

Hi,

your example is very similar to my code. But how do you compute the correct shiftX and shiftY values?

 

0 Kudos
Jonghak_K_Intel
Employee
885 Views

Hi steffenroeber,

Please check here https://software.intel.com/en-us/node/504405 for ippiGetRotateShift that computes shift values for rotation.

Thank you 

0 Kudos
steffenroeber
Beginner
885 Views

The ippiGetRotateShift only helps, if the destination image has same size as sozrce. Finally I found another solution:
 

ippiGetRotateTransform(angle, 0, 0, coeffs);
float64 bound[2][2];
ippiGetAffineBound(srcRect, bound, coeffs);
dstSize.width = bound[1][0] - bound[0][0] + 1;
dstSize.height = bound[1][1] - bound[0][1] + 1;
coeffs[0][2] = -bound[0][0];
coeffs[1][2] = -bound[0][1];

 

0 Kudos
Reply