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 ...
随机推荐
- Poj(1797) Dijkstra对松弛条件的变形
题目链接:http://poj.org/problem?id=1797 题意:从路口1运货到路口n,最大的运货重量是多少?题目给出两路口间的最大载重. 思路:j加到s还是接到K下面,取两者的较大者,而 ...
- ubuntu下环境变量
01:/etc/environment:是设置整个系统的环境: 02:/etc/profile:是设置所有用户的环境: 03:.bashrc :本地用户:
- Codeforces Round #373 (Div. 2) B
Description Anatoly lives in the university dorm as many other students do. As you know, cockroaches ...
- sqlitehelper封装
appsettings <configuration> <appSettings> <add key="ConnectionString&q ...
- 快速编译system.img、userdata.img、boot.img的方法
快速编译system.img和boot.img的方法 快速编译system.img,可以使用这个命令: #make systemimage 快速编译boot.img,可以使用以下命令: #make b ...
- mongodb数据库设计原则
1.一对很少 one-to-few 可以采用内嵌文档 person集合中 { name:'张三', age:20, address:[ {country:"中国",provin ...
- UVA 11552 四 Fewest Flops
Fewest Flops Time Limit:2000MS Memory Limit:0KB 64bit IO Format:%lld & %llu Submit Statu ...
- SQL查看一张表中是否存在记录
今天在QQ群众讨论到一个问题,记录下下来,一边以后用的时候可以翻阅 总结除了三种方法 --方法1,,这一种方法不行,,错误的认识了,@@ROWCOUNT,,,唉,,学艺不精,,丢人啊 SELECT T ...
- Plotting means and error bars (ggplot2)
library(ggplot2) ############################################# # summarySE ######################### ...
- Web开发, 跳转时出现java.lang.ClassNotFoundException
发生这种状况一般都是由于类找不到,要么是web.xml没有配对位置,要么是类没有放好