opencl初探-sobel检测
sobel检测的C版本,neon和GPU的时间比较。
Platform:
LG G3, Adreno 330 ,img size 3264x2448
sobel:
C code |
neon |
GPU |
73 |
13 |
42+3.7+6.6 |
单位:ms
GPU时间=memory
time+Queued time+Run time
Sobel org |
Sobel vector |
Sobel vector + |
|
Queued time |
4.6 |
7.2 |
2.8 |
Wait time |
0.07 |
0.09 |
0.07 |
Run time |
66.9 |
7.3 |
6.6 |
typedef unsigned char BYTE;
void sobel(BYTE *src,int w,int h,BYTE *Ix,BYTE *Iy)
{
int src_step = w;
int dst_step = w;
int x, height = h - ;
BYTE* dstX = Ix+dst_step;
BYTE* dstY = Iy+dst_step;
for( ; height--; src += src_step, dstX += dst_step, dstY += dst_step )
{
const BYTE* src2 = src + src_step;
const BYTE* src3 = src + src_step*; for( x = ; x < w- ; x++ )
{
short t0 = ;
short t1 = ;
t0 = -src[x-]+src[x+] ;
t1 = src[x-]+(src[x]<<)+src[x+]; t0 += ((-src2[x-]+src2[x+])<<) ; t0 += -src3[x-]+src3[x+] ;
t1 -= ( src3[x-]+(src3[x]<<)+src3[x+] ); dstX[x] = t0>>;
dstY[x] = t1>>;
}
}
} void sobel_neon(BYTE *src,int w,int h,BYTE *Ix,BYTE *Iy)
{
int src_step = w;
int dst_step = w;
int x, height = h - ;
BYTE* dstX = Ix+dst_step;
BYTE* dstY = Iy+dst_step;
for( ; height--; src += src_step, dstX += dst_step, dstY += dst_step )
{
const BYTE* src2 = src + src_step;
const BYTE* src3 = src + src_step*;
x = ;
while((x+) <= w- )
{
uint8x8_t left = vld1_u8(src+x-);
uint8x8_t mid = vld1_u8(src+x) ;
uint8x8_t right = vld1_u8(src+x+) ; int16x8_t t0 = vreinterpretq_s16_u16( vsubl_u8(right,left) ) ;
int16x8_t t1 = vaddq_s16( vreinterpretq_s16_u16( vaddl_u8(left,right) ) ,
vreinterpretq_s16_u16( vshll_n_u8(mid,) ) ); left = vld1_u8(src2+x-);
right = vld1_u8(src2+x+) ;
int16x8_t temp = vreinterpretq_s16_u16( vsubl_u8(right,left) );
t0 = vaddq_s16(t0,vshlq_n_s16(temp,)); left = vld1_u8(src3+x-);
mid = vld1_u8(src3+x) ;
right = vld1_u8(src3+x+) ;
t0 = vaddq_s16(t0,vreinterpretq_s16_u16( vsubl_u8(right,left) ));
temp = vaddq_s16( vreinterpretq_s16_u16( vaddl_u8(left,right) ) ,
vreinterpretq_s16_u16( vshll_n_u8(mid,) ) );
t1 = vsubq_s16(t1,temp); vst1_s8((int8_t*)dstX+x,vshrn_n_s16(t0,));
vst1_s8((int8_t*)dstY+x,vshrn_n_s16(t1,));
x += ;
}
while( (x) < w- )
{
short t0 = ;
short t1 = ;
t0 = -src[x-]+src[x+] ;
t1 = src[x-]+(src[x]<<)+src[x+]; t0 += ((-src2[x-]+src2[x+])<<) ; t0 += -src3[x-]+src3[x+] ;
t1 -= ( src3[x-]+(src3[x]<<)+src3[x+] ); dstX[x] = t0>>;
dstY[x] = t1>>;
x++;
}
}
}
opencl初探-sobel检测的更多相关文章
- 边缘检测之Sobel检测算子
在讨论边缘算子之前,首先给出一些术语的定义: (1)边缘:灰度或结构等信息的突变处,边缘是一个区域的结束,也是另一个区域的开始,利用该特征可以分割图像. (2)边缘点:图像中具有坐标[x,y],且处在 ...
- [Face++]Face初探——人脸检测
经过了强烈的思想斗争才把自己拖到图书馆做毕设T^T anyway, 因为毕设里面有人脸识别的部分,所以就想找个现成的api先玩玩,于是就找到最近很火的face++:http://www.faceplu ...
- Canny算法检测边缘
Canny算法是边缘检测的一个经典算法,比单纯用一些微分算子来检测的效果要好很多,其优势有以下几点: 边缘误检与漏检率低. 边缘定位准确,且边界较细. 自带一定的滤噪功能,或者说,对噪声的敏感度要比单 ...
- 在UnrealEngine中用Custom节点实现描边效果
在<Real Time Rendering, third edition>一书中,作者把描边算法分成了5种类型.1.基于观察角度与表面法线的轮廓渲染.缺点很明显.2.过程式几何轮廓渲染.即 ...
- 安卓平台下ARM Mali OpenCL编程-GPU信息检测(转)
对于ARM Mali GPU,目前是支持OpenCL1.1,所以我们可以利用OpenCL来加速我们的计算. 一直以来,对于Mali GPU的OpenCL编程,一直没有环境来测试.好不容易弄到一个华为M ...
- opencl+opencv实现sobel算法
这几天在看opencl编程指南.照着书中的样例实现了sobel算法: 1.结合opencv读取图像,保存到缓冲区中. 2.编写和编译内核.并保存显示处理后的结果. 内核: const sampler_ ...
- AI安全初探——利用深度学习检测DNS隐蔽通道
AI安全初探——利用深度学习检测DNS隐蔽通道 目录 AI安全初探——利用深度学习检测DNS隐蔽通道 1.DNS 隐蔽通道简介 2. 算法前的准备工作——数据采集 3. 利用深度学习进行DNS隐蔽通道 ...
- 每天进步一点点------Sobel算子(3)基于彩色图像边缘差分的运动目标检测算法
摘 要: 针对目前常用的运动目标提取易受到噪声影响.易出现阴影和误检漏检等情况,提出了一种基于Sobel算子的彩色边缘图像检测和帧差分相结合的检测方法.首先用Sobel算子提取视频流中连续4帧图像的 ...
- 14FPGA综设之图像边沿检测的sobel算法
连续学习FPGA基础课程接近一个月了,迎来第一个有难度的综合设计,图像的边沿检测算法sobel,用verilog代码实现算法功能. 一设计功能 (一设计要求) (二系统框图) 根据上面的系统,Veri ...
随机推荐
- opencv的实用研究--分析轮廓并寻找边界点
opencv的实用研究--分析轮廓并寻找边界点 轮廓是图像处理中非常常见的.对现实中的图像进行采样.色彩变化.灰度变化之后,能够处理得到的是“轮廓”.它直接地反应你了需要分析对象的边界特 ...
- HashMap, HashTable, CurrentHashMap的区别
转载:http://www.jianshu.com/p/c00308c32de4 HashMap vs ConcurrentHashMap 引入ConcurrentHashMap是为了在同步集合Has ...
- zoj Treasure Hunt IV
Treasure Hunt IV Time Limit: 2 Seconds Memory Limit: 65536 KB Alice is exploring the wonderland ...
- EasyUI 格式化DataGrid列
easyui DataGrid中格式化列,如果单价低于20,则使用定义列formatter为红色文本.格式化DataGrid列,我们应该设置formatter属性,这个属性是一个函数.格式化函数包括两 ...
- 解决maven的“Dynamic Web Module 3.0 requires Java 1.6 or newer.”错误
需要添加一个插件,在build标签中添加 <plugins> <plugin> <groupId>org.apache.maven.plugins</grou ...
- font awesome 符号字体
http://www.fontawesome.com.cn/ 引用CSS包之后根据图标库找到所需的图标代码 使用i标签或者a标签皆可,符号为文字性质,可以直接通过修改text颜色从而修改符号颜色
- C++ 去掉字符串首尾的 \x20 \r \n 字符
转载:http://www.sharejs.com/codes/cpp/5780 /* 去掉字符串首尾的 \x20 \r \n 字符 by sincoder */ void clean_string( ...
- ViewController之间的切换动画
一 .API介绍 iOS7开始,苹果推出了自定义转场动画API.从此,任何可以用Core Animation实现的动画,都可以出现在两个ViewController的切换之间 知识点图: 从上图可以看 ...
- BZOJ 1513 [POI2006]Tet-Tetris 3D
题目链接:http://www.lydsy.com:808/JudgeOnline/problem.php?id=1513 题意:三维空间,有一些立方体在垂直下落.立方体的左下角坐标(x,y)以及长宽 ...
- ggplot2 legend图例的修改
ggplot2中的legend包括四个部分: legend.tittle, legend.text, legend.key, legend.backgroud.针对每一部分有四种处理方式: eleme ...