当前位置:网站首页>用于图像处理的高性能计算框架
用于图像处理的高性能计算框架
2022-06-12 09:59:00 【zhoukehu91】
| 框架 | 介绍 | |
| GPU | NPP | NVIDIA Performance Primitives,NVIDIA公司针对GPU开发了的GPU加速的图像、视频、信号处理库,在安装完CUDA环境时会自动安装。通过调用NPP函数,可以免去手写CUDA内核函数,快速完成开发。 |
| CUDA | Compute Unified Device Architecture: NVIDIA开发的一种并行计算平台和编程模型。它通过利用图形处理器 (GPU) 的处理能力,可大幅提升计算性能。需要首先了解它的开发语言CUDA C,然后进行开发。 | |
| CPU | IPP | Integrated Performance Primitives,Intel 提供的高性能多媒体函数库,包含许多从底层优化的函数,涵盖包括图像处理在内的多种应用,其接口形式与NPP库类似。对于图像处理,IPP提供的库函数介绍参考博客。 |
| TBB | Threading Building Blocks,Intel开发的用于并行编程的基于C++语言的框架,它是一套C++模板库。它提供了大量特性,具有比线程更高程度的抽象,主要用于多核CPU平台下的多线程处理加速。 | |
总结如下:
1)NPP和IPP都是提供的封装好的库函数,主要提供通用算法。比如说图像处理中的滤波、色彩空间转换等。NPP用于GPU平台的并行加速,IPP用于CPU平台的多线程并行加速。
2)CUDA和TBB分别是GPU和CPU平台下的并行开发框架。典型地,对于图像处理中的for循环(逐像素)处理,CUDA可以通过编写内核函数完成多CUDA核的并行加速,而TBB则可以通过其特定接口完成多CPU的并行处理加速。
3)作者在开发的过程中,首先使用OpenMP进行CPU平台的图像处理加速,但是发现CPU占用率过高,并且处理速度没有提升。后续改用TBB进行开发,实现了预期目标。IPP和TBB都可以从Intel的官网下载,见这里。
最后提供一下作者使用TBB加速的关键代码段,主要完成的是彩色图像的色彩校正,在Xeon E3-1230 v2平台(4核心8线程)上,算法执行速度提升明显。代码如下:
//彩色图像色彩校正
void ColorCorrect8UC3(Mat source, Mat& dst, int nR, int nG, int nB)
{
dst = source.clone();
if ((nR == 100) && (nG == 100) && (nB == 100))
return;
Mat src = source.clone();
if (nR < 0)
nR = 0;
if (nR > 100)
nR = 100;
if (nG < 0)
nG = 0;
if (nG > 100)
nG = 100;
if (nB < 0)
nB = 0;
if (nB > 100)
nB = 100;
int width = src.cols;
int height = src.rows;
unsigned char* pSrc = src.ptr();
unsigned char* pDst = dst.ptr();
//parallel_for配合blocked_range2d会对图像处理有很大的帮助
//blocked_range2d的参数说明:
//(y起始值,y结束值,y步进值,x起始值,x结束值,x步进值)
tbb::parallel_for(tbb::blocked_range2d<int>(0, height, 1, 0, width, 1),
[&](const tbb::blocked_range2d<int>& r)
{
for (int i = r.rows().begin(); i < r.rows().end(); ++i)
{
for (int j = r.cols().begin(); j < r.cols().end(); ++j)
{
pDst[i*width * 3 + j * 3 + 2] = (unsigned char)(pSrc[i*width * 3 + j * 3 + 2] * nR / 100.0);
pDst[i*width * 3 + j * 3 + 1] = (unsigned char)(pSrc[i*width * 3 + j * 3 + 1] * nG / 100.0);
pDst[i*width * 3 + j * 3 + 0] = (unsigned char)(pSrc[i*width * 3 + j * 3 + 0] * nB / 100.0);
}
}
});
}边栏推荐
- 《要领》读书笔记
- Explication du principe d'appariement le plus à gauche de MySQL
- 日本经济泡沫与房价泡沫
- Japanese economic foam and house price foam
- Papaya Mobile has a comprehensive layout of cross-border e-commerce SaaS papaya orange. What are the opportunities for this new track?
- Tap series article 3 | introduction to Tanzu application platform deployment reference architecture
- Implementation of fruit mall wholesale platform based on SSM
- string类对象的访问及遍历操作
- Dragon Boat Festival Ankang - - les Yankees dans mon cœur de plus en plus de zongzi
- UEFI edkii programming learning
猜你喜欢
![[cloud native | kubernetes] kubernetes networkpolicy](/img/8b/9260fc39d3f595cdc2689a3ab26bd7.png)
[cloud native | kubernetes] kubernetes networkpolicy

MySQL优化之慢日志查询

1268_FreeRTOS任务上下文切换的实现

QQ,微信能聊天都靠它(socket)?

Ceph性能优化与增强

软件定义存储概览(一篇就够)

001: what is a data lake?

电脑启动快捷键一览表

使用Visual Studio 2017创建简单的窗口程序

Li Yang, a scientific and technological innovator and CIO of the world's top 500 group: the success of digital transformation depends on people. Decision makers should always focus on "firewood"
随机推荐
总有一根阴线(上影线)会阻止多军前进的脚步,总有一个阳线(下影线)会阻挡空军肆虐的轰炸
Overview of software definition storage (one article is enough)
Research progress of DNA digital information storage
markdown_ Picture side by side scheme
2021-02-21
7-13 地下迷宫探索(邻接表)
优质好书助成长 猿辅导携四大出版社推荐“暑期好书”
哈希表的线性探测法代码实现
电脑启动快捷键一览表
1268_FreeRTOS任务上下文切换的实现
[cloud native | kubernetes] kubernetes networkpolicy
FPGA基于DE2-115平台的VGA显示
[cloud native] establishment of Eureka service registration
PandoraBox 使用防火墙规则定义非上网时间
[cloud native] what exactly does it mean? This article shares the answer with you
Crazy temporary products: super low price, big scuffle and new hope
005:数据湖与数据仓库的区别
C# break continue return 三者区别
002:数据湖有哪些特征
Mysql5.7 partition table