source: OpenCLIterative3DDeconvolution/src/publication/sobel.cl @ 6962

Revision 6962, 810 bytes checked in by rlentz, 9 years ago (diff)

latest

Line 
1__kernel void sobel( __global float* input,
2        __global float* output,
3     int width,
4     int height )
5
6    int x = get_global_id(0);
7    int y = get_global_id(1);
8    float p0, p1, p2, p3, p4, p5, p6, p7, p8 = 0;
9    int offset = y * width + x;
10if( x < 1 || y < 1 || x > width - 2 || y > height - 2 )
11{
12  output[offset] = 0;
13}
14else
15{
16    p0 = input[offset - width - 1] ;
17    p1 = input[offset - width] ;
18    p2 = input[offset - width + 1] ;
19    p3 = input[offset - 1] ;
20    p4 = input[offset] ;
21    p5 = input[offset + 1] ;
22    p6 = input[offset + width - 1] ;
23    p7 = input[offset + width] ;
24    p8 = input[offset + width + 1] ;
25
26    float sum1 = p0 + 2*p1 + p2 - p6 - 2*p7 - p8;  //GY
27    float sum2 = p0 + 2*p3 + p6 - p2 - 2*p5 - p8;  //GX
28   
29    output[offset] = sqrt(  sum1*sum1 + sum2*sum2 );
30}
31}
Note: See TracBrowser for help on using the repository browser.