|
| 1 | +__kernel void processNineCellWindow( __global float *scanLine1, |
| 2 | + __global float *scanLine2, |
| 3 | + __global float *scanLine3, |
| 4 | + __global float *resultLine, |
| 5 | + __global float *rasterParams ) |
| 6 | +{ |
| 7 | + |
| 8 | + // Get the index of the current element |
| 9 | + const int i = get_global_id(0); |
| 10 | + |
| 11 | + float x11 = scanLine1[i]; |
| 12 | + float x12 = scanLine1[i+1]; |
| 13 | + float x13 = scanLine1[i+2]; |
| 14 | + float x21 = scanLine2[i]; |
| 15 | + float x22 = scanLine2[i+1]; |
| 16 | + float x23 = scanLine2[i+2]; |
| 17 | + float x31 = scanLine3[i]; |
| 18 | + float x32 = scanLine3[i+1]; |
| 19 | + float x33 = scanLine3[i+2]; |
| 20 | + |
| 21 | + if ( x22 == rasterParams[0] ) |
| 22 | + { |
| 23 | + resultLine[i] = rasterParams[1]; |
| 24 | + } |
| 25 | + else |
| 26 | + { |
| 27 | + // Nodata handling |
| 28 | + if ( x11 == rasterParams[0] ) x11 = x22; |
| 29 | + if ( x12 == rasterParams[0] ) x12 = x22; |
| 30 | + if ( x13 == rasterParams[0] ) x13 = x22; |
| 31 | + if ( x21 == rasterParams[0] ) x21 = x22; |
| 32 | + if ( x23 == rasterParams[0] ) x23 = x22; |
| 33 | + if ( x31 == rasterParams[0] ) x31 = x22; |
| 34 | + if ( x32 == rasterParams[0] ) x32 = x22; |
| 35 | + if ( x33 == rasterParams[0] ) x33 = x22; |
| 36 | + |
| 37 | + float diff1 = x11 - x22; |
| 38 | + float diff2 = x21 - x22; |
| 39 | + float diff3 = x31 - x22; |
| 40 | + float diff4 = x12 - x22; |
| 41 | + float diff5 = x32 - x22; |
| 42 | + float diff6 = x13 - x22; |
| 43 | + float diff7 = x23 - x22; |
| 44 | + float diff8 = x33 - x22; |
| 45 | + |
| 46 | + resultLine[i] = sqrt(diff1 * diff1 + diff2 * diff2 + |
| 47 | + diff3 * diff3 + diff4 * diff4 + |
| 48 | + diff5 * diff5 + diff6 * diff6 + |
| 49 | + diff7 * diff7 + diff8 * diff8); |
| 50 | + } |
| 51 | +} |
0 commit comments