【发布时间】:2017-07-31 21:58:06
【问题描述】:
我编写了以下代码让 IPP 调整我的矩阵大小:
#include "ipp_mx.h"
#include "ipp.h"
#include "stdafx.h"
#define IPPCALL(name) name
int main()
{
IppiSize srcSize = { 3,3 };
float srcImage[9] =
{ 20, 40, 30,
35, 55, 70,
100, 30, 20 };
float* src = new float[srcSize.width*srcSize.height];
for (int i = 0; i < srcSize.width*srcSize.height; i++) {
src[i] = srcImage[i];
}
double xFactor = 10; double yFactor = 10;
int numChannels = 1;
int bytesPerPixel = 4;
int srcStep = srcSize.width*bytesPerPixel*numChannels;
IppiRect srcRoi = { 0, 0, srcSize.width, srcSize.width };
float* dest = new float[srcSize.width*srcSize.height*xFactor*yFactor];
IppiSize destSize = { srcSize.width*xFactor, srcSize.height*yFactor };
int destStep = destSize.width*bytesPerPixel*numChannels;
IppiRect destRoi = { 0, 0, destSize.width, destSize.width };
double xShift = 0; double yShift = 0;
int interpolation = 1; //nearest neighbour
int bufSize;
IPPCALL(ippiResizeGetBufSize)(srcRoi, destRoi, 1, interpolation, &bufSize);
unsigned char* buffer = new unsigned char[bufSize];
IPPCALL(ippiResizeSqrPixel_32f_C1R)(src, srcSize, srcStep, srcRoi, dest, destStep, destRoi, xFactor, yFactor, xShift, yShift, interpolation, buffer);
return 0;
}
在给定颜色图的情况下,我现在可以使用一个 IPP 函数将这个浮点矩阵 dest 转换为 RGB24 格式吗?
我知道我可以在 for 循环中手动完成,但我想要处理的原始矩阵要大得多,for 循环可能无法解决它。
【问题讨论】:
标签: c++ image matrix intel-ipp