简单介绍一下,IPP是一个intel提供高性能计算的平台,尤其针对intel芯片有特殊的优化。不仅包括图像处理,还有很多其他应用场景。
IPP官方链接
官网教程实在是详细,不愧是intel。
下载就完了
他给的平滑和旋转代码链接好像失效了,要的话评论区联系我。
IPP高斯滤波demo
API手册里面有些给了demo。
文档里面的API是不带前缀和后缀的,前缀就是ippi,后缀是_32f_C1R,表示类型和通道数。去对应头文件看看支持哪些通道数。
ippiFilterGaussianBorder_32f_C1R
cv::Mat inputImage = cv::imread(".jpg", cv::IMREAD_GRAYSCALE);
cv::Mat outputImage = cv::Mat(inputImage.size(), inputImage.type());
IppiSize imageSize = { inputImage.cols, inputImage.rows };
IppiSize maskSize = { 43, 43 };
Ipp8u* maskdata = new Ipp8u[maskSize.height * maskSize.width];
for (int i = 0; i < maskSize.height * maskSize.width; i++) {
maskdata[i] = 1;
}
int specSize;
int bufferSize;
clock_t start1, finish;
double total_time;
start1 = clock();
// 获取规范结构和缓冲区大小
ippiMorphologyBorderGetSize_8u_C1R(imageSize, maskSize, &specSize,&bufferSize);
// 分配规范结构和工作缓冲区内存
IppiMorphState* pSpec = (IppiMorphState*)ippMalloc(specSize);
Ipp8u* pBuffer = ippsMalloc_8u(bufferSize);
// 初始化规范结构
ippiMorphologyBorderInit_8u_C1R(imageSize, mask.data, maskSize, pSpec, pBuffer);
start1 = clock();
// 执行腐蚀操作
ippiErodeBorder_8u_C1R(inputImage.data, inputImage.step, outputImage.data, outputImage.step, imageSize, ippBorderRepl, 0, pSpec, pBuffer);
finish = clock();
total_time = (double)(finish - start1) / CLOCKS_PER_SEC;
printf("\nTotal time: %f m seconds. ippiErodeBorder_8u_C1R\n", total_time * 1000);
// 释放内存
ippFree(pSpec);
ippsFree(pBuffer);
//cv::imshow("aa", outputImage);
//cv::waitKey(0);
还有一个L版本,L是低级版本,效率感觉没差。
cv::Mat inputImage = cv::imread("", cv::IMREAD_GRAYSCALE);
cv::Mat outputImage = cv::Mat(inputImage.size(), inputImage.type());
IppiSizeL imageSize = { inputImage.cols, inputImage.rows };
IppiSizeL maskSize = { 43, 43 };
clock_t start, finish;
double total_time;
start = clock();
IppSizeL SpecSize;
ippiErodeGetSpecSize_L(imageSize, maskSize, &SpecSize);
IppiMorphStateL* pState = (IppiMorphStateL*)ippMalloc(SpecSize);
IppStatus status = ippiErodeInit_L(imageSize, mask.data, maskSize, pState);
if (status != ippStsNoErr) {
std::cerr << "腐蚀初始化失败" << std::endl;
return -1;
}
IppSizeL bufferSize = 0;
status = ippiErodeGetBufferSize_L(imageSize, maskSize, IppDataType::ipp8u, inputImage.channels(), &bufferSize);
if (status != ippStsNoErr) {
std::cerr << "计算缓冲区大小失败" << std::endl;
ippiFree(pState);
return -1;
}
// 分配工作缓冲区
Ipp8u* pBuffer = ippsMalloc_8u(bufferSize);;
start = clock();
status = ippiErode_8u_C1R_L(inputImage.data, inputImage.step, outputImage.data, outputImage.step, imageSize, ippBorderRepl, NULL, pState, pBuffer);
finish = clock();
total_time = (double)(finish - start) / CLOCKS_PER_SEC;
printf("\nTotal time: %f m seconds.ippcv_l\n", total_time * 1000);
if (status != ippStsNoErr) {
std::cerr << "腐蚀操作失败" << std::endl;
ippiFree(pState);
ippFree(pBuffer);
return -1;
}
ippFree(pState);
ippFree(pBuffer);
//cv::imshow("aa", outputImage);
//cv::waitKey(0);