- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
your example is very similar to my code. But how do you compute the correct shiftX and shiftY values?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi steffenroeber,
Please check here https://software.intel.com/en-us/node/504405 for ippiGetRotateShift that computes shift values for rotation.
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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];
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page