-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathharris_corner_detection_v3.cl
More file actions
executable file
·528 lines (371 loc) · 20.5 KB
/
harris_corner_detection_v3.cl
File metadata and controls
executable file
·528 lines (371 loc) · 20.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
// Zero and First Derivative of Gaussian filter along Y axis (verticle)
// Returns two arrays the size fo the image
__kernel void
gaussian_first_axis(
__global float *in_values,
__global float *out_zero,
__global float *out_first,
__local float *buffer,
int w, int h,
int buf_w, int buf_h,
int halo,
__global float *direct_der,
__global float *zero_kernel
)
{
//////////////////////Define Variables///////////////////////
// halo is the additional number of cells in one direction
// Global position of output pixel
int x = get_global_id(0); // values for the columns
int y = get_global_id(1); // values for the rows
// Local position relative to (0, 0) in workgroup
int lx = get_local_id(0); // these will be values for the columns
int ly = get_local_id(1); // these will be values for the rows
// coordinates of the upper left corner of the buffer in image (global)
// space, including halo
int buf_corner_x = x - lx - halo;
int buf_corner_y = y - ly - halo;
// coordinates of our pixel in the local buffer
// this shifts the buffer reference to the middle of the buffer
// where these pixels actualy exist in the buffer
int buf_x = lx + halo; // buffer position
int buf_y = ly + halo;
// 1D index of thread within our work-group
int idx_1D = ly * get_local_size(0) + lx; //get_local_size = 2
//////////////////////loop to build Buffer///////////////////////
//Iterate down each colum, using a row iterator
// Load the relevant labels to a local buffer with a halo
if (idx_1D < buf_w)
{
for (int row = 0; row < buf_h; row++)
{
int max_x = buf_corner_x + idx_1D; // this is column index, add idx_1D
int max_y = buf_corner_y + row; //stepping by rows adjust y
int new_h = h - 1; // height index
int new_w = w - 1; // width index
// Load the values into the buffer
// This is a read from global memory global read
// Each thread is loading values into the buffer down columns
buffer[row * buf_w + idx_1D] = in_values[min(max(0, max_y), new_h) * w + min(max(0, max_x), new_w)];
}
}
//////////////////////coniditional statement to smooth///////////////////////
// Conditional with in bounds of the entire image
if (x < w && y < h)
{
// Y is in the axis = 1 direction
float yneighbor_0 = buffer[(buf_y - 4) * buf_w + (buf_x - 0)];
float yneighbor_1 = buffer[(buf_y - 3) * buf_w + (buf_x - 0)];
float yneighbor_2 = buffer[(buf_y - 2) * buf_w + (buf_x - 0)];
float yneighbor_3 = buffer[(buf_y - 1) * buf_w + (buf_x - 0)];
float yneighbor_5 = buffer[(buf_y + 1) * buf_w + (buf_x + 0)];
float yneighbor_6 = buffer[(buf_y + 2) * buf_w + (buf_x + 0)];
float yneighbor_7 = buffer[(buf_y + 3) * buf_w + (buf_x + 0)];
float yneighbor_8 = buffer[(buf_y + 4) * buf_w + (buf_x + 0)];
float ypixel = buffer[(buf_y + 0) * buf_w + (buf_x + 0)];
//use a for loop to multiply by
float first = yneighbor_0 * direct_der[0] + yneighbor_1 * direct_der[1] + yneighbor_2 *
direct_der[2] + yneighbor_3 * direct_der[3] + yneighbor_5 * direct_der[5] + yneighbor_6 * direct_der[6] +
yneighbor_7 * direct_der[7] + yneighbor_8 * direct_der[8] + ypixel * direct_der[4];
float zero = yneighbor_0 * zero_kernel[0] + yneighbor_1 * zero_kernel[1] + yneighbor_2 *
zero_kernel[2] + yneighbor_3 * zero_kernel[3] + yneighbor_5 * zero_kernel[5] + yneighbor_6 * zero_kernel[6] +
yneighbor_7 * zero_kernel[7] + yneighbor_8 * zero_kernel[8] + ypixel * zero_kernel[4];
out_zero[y * w + x] = zero;
out_first[y * w + x] = first;
}
}
// Zero and First Derivative of Gaussian filter along X axis (horizontal)
// Returns three arrays the size fo the image, where eached partial is squared
__kernel void
gaussian_second_axis(
__global float *in_zero,
__global float *in_first,
__global float *out_Wxx,
__global float *out_Wyy,
__global float *out_Wxy,
__local float *buffer_order0,
__local float *buffer_order1,
int w, int h,
int buf_w, int buf_h,
int halo,
__global float *direct_der,
__global float *zero_kernel
)
{
//////////////////////Define Variables///////////////////////
// halo is the additional number of cells in one direction
// Global position of output pixel
int x = get_global_id(0); // values for the columns
int y = get_global_id(1); // values for the rows
// Local position relative to (0, 0) in workgroup
int lx = get_local_id(0); // these will be values for the columns
int ly = get_local_id(1); // these will be values for the rows
// coordinates of the upper left corner of the buffer in image (global)
// space, including halo
int buf_corner_x = x - lx - halo;
int buf_corner_y = y - ly - halo;
// coordinates of our pixel in the local buffer
// this shifts the buffer reference to the middle of the buffer
// where these pixels actualy exist in the buffer
int buf_x = lx + halo; // buffer position
int buf_y = ly + halo;
// 1D index of thread within our work-group
int idx_1D = ly * get_local_size(0) + lx; //get_local_size = 2
//////////////////////loop to build Buffer///////////////////////
//Iterate down each colum, using a row iterator
// Load the relevant labels to a local buffer with a halo
if (idx_1D < buf_w)
{
for (int row = 0; row < buf_h; row++)
{
int max_x = buf_corner_x + idx_1D; // this is column index, add idx_1D
int max_y = buf_corner_y + row; //stepping by rows adjust y
int new_h = h - 1; // height index
int new_w = w - 1; // width index
// Load the values into the buffer
// This is a read from global memory global read
// Each thread is loading values into the buffer down columns
buffer_order0[row * buf_w + idx_1D] = in_zero[min(max(0, max_y), new_h) * w + min(max(0, max_x), new_w)];
buffer_order1[row * buf_w + idx_1D] = in_first[min(max(0, max_y), new_h) * w + min(max(0, max_x), new_w)];
}
}
//////////////////////coniditional statement to smooth///////////////////////
// Conditional with in bounds of the entire image
if (x < w && y < h)
{
float yneighbor_0_order0 = buffer_order0[(buf_y - 0) * buf_w + (buf_x - 4)];
float yneighbor_1_order0 = buffer_order0[(buf_y - 0) * buf_w + (buf_x - 3)];
float yneighbor_2_order0 = buffer_order0[(buf_y - 0) * buf_w + (buf_x - 2)];
float yneighbor_3_order0 = buffer_order0[(buf_y - 0) * buf_w + (buf_x - 1)];
float yneighbor_5_order0 = buffer_order0[(buf_y + 0) * buf_w + (buf_x + 1)];
float yneighbor_6_order0 = buffer_order0[(buf_y + 0) * buf_w + (buf_x + 2)];
float yneighbor_7_order0 = buffer_order0[(buf_y + 0) * buf_w + (buf_x + 3)];
float yneighbor_8_order0 = buffer_order0[(buf_y + 0) * buf_w + (buf_x + 4)];
float ypixel_order0 = buffer_order0[(buf_y + 0) * buf_w + (buf_x + 0)];
float yneighbor_0_order1 = buffer_order1[(buf_y - 0) * buf_w + (buf_x - 4)];
float yneighbor_1_order1 = buffer_order1[(buf_y - 0) * buf_w + (buf_x - 3)];
float yneighbor_2_order1 = buffer_order1[(buf_y - 0) * buf_w + (buf_x - 2)];
float yneighbor_3_order1 = buffer_order1[(buf_y - 0) * buf_w + (buf_x - 1)];
float yneighbor_5_order1 = buffer_order1[(buf_y + 0) * buf_w + (buf_x + 1)];
float yneighbor_6_order1 = buffer_order1[(buf_y + 0) * buf_w + (buf_x + 2)];
float yneighbor_7_order1 = buffer_order1[(buf_y + 0) * buf_w + (buf_x + 3)];
float yneighbor_8_order1 = buffer_order1[(buf_y + 0) * buf_w + (buf_x + 4)];
float ypixel_order1 = buffer_order1[(buf_y + 0) * buf_w + (buf_x + 0)];
//use a for loop to multiply by
float Ix = yneighbor_0_order0 * direct_der[0] + yneighbor_1_order0 * direct_der[1] + yneighbor_2_order0 *
direct_der[2] + yneighbor_3_order0 * direct_der[3] + ypixel_order0 * direct_der[4] + yneighbor_5_order0 * direct_der[5] + yneighbor_6_order0 * direct_der[6] +
yneighbor_7_order0 * direct_der[7] + yneighbor_8_order0 * direct_der[8];
float Iy = yneighbor_0_order1 * zero_kernel[0] + yneighbor_1_order1 * zero_kernel[1] + yneighbor_2_order1 *
zero_kernel[2] + yneighbor_3_order1 * zero_kernel[3] + ypixel_order1 * zero_kernel[4] + yneighbor_5_order1 * zero_kernel[5] + yneighbor_6_order1 * zero_kernel[6] +
yneighbor_7_order1 * zero_kernel[7] + yneighbor_8_order1 * zero_kernel[8];
out_Wxx[y * w + x] = Ix * Ix;
out_Wyy[y * w + x] = Iy * Iy;
out_Wxy[y * w + x] = Ix * Iy;
}
}
// Performes a zero derivative gaussian on the Y axis (verticle)
// Returs 3 arrays the size of the image - all partials smoothed.
__kernel void
filter_first_axis_second_pass(
__global float *in_Wxx,
__global float *in_Wyy,
__global float *in_Wxy,
__global float *out_Wxx,
__global float *out_Wyy,
__global float *out_Wxy,
__local float *buffer_Wxx,
__local float *buffer_Wyy,
__local float *buffer_Wxy,
int halo,
int w, int h,
int buf_w, int buf_h,
__global float *filter
)
{
//////////////////////Define Variables///////////////////////
// halo is the additional number of cells in one direction
// Global position of output pixel
int x = get_global_id(0);
int y = get_global_id(1);
// Local position relative to (0, 0) in workgroup
int lx = get_local_id(0); // with in workgroup, so less than buffer
int ly = get_local_id(1);
// coordinates of the upper left corner of the buffer in image (global)
// space, including halo
int buf_corner_x = x - lx - halo;
int buf_corner_y = y - ly - halo;
// coordinates of our pixel in the local buffer
// this shifts the buffer reference to the middle of the buffer
// where these pixels actualy exist in the buffer
int buf_x = lx + halo;
int buf_y = ly + halo;
// 1D index of thread within our work-group
int idx_1D = ly * get_local_size(0) + lx; //get_local_size = 8
//////////////////////loop to build Buffer///////////////////////
// Load the relevant labels to a local buffer with a halo
if (idx_1D < buf_w)
{
//Iterate down each colum, using a row iterator
for (int row = 0; row < buf_h; row++)
{
int max_x = buf_corner_x + idx_1D; // this is column index, add idx_1D
int max_y = buf_corner_y + row; //stepping by rows adjust y
int new_h = h - 1; // height index
int new_w = w - 1; // width index
// Load the values into the buffer
// This is a read from global memory global read
// Each thread is loading values into the buffer down columns
buffer_Wxx[row * buf_w + idx_1D] = in_Wxx[min(max(0, max_y), new_h) * w + min(max(0, max_x), new_w)];
buffer_Wyy[row * buf_w + idx_1D] = in_Wyy[min(max(0, max_y), new_h) * w + min(max(0, max_x), new_w)];
buffer_Wxy[row * buf_w + idx_1D] = in_Wxy[min(max(0, max_y), new_h) * w + min(max(0, max_x), new_w)];
}
}
//////////////////////coniditional statement to smooth///////////////////////
// Conditional with in bounds of the entire image
if (x < w && y < h)
{
float neighbor_0_Wxx = buffer_Wxx[(buf_y - 4) * buf_w + (buf_x - 0)];
float neighbor_1_Wxx = buffer_Wxx[(buf_y - 3) * buf_w + (buf_x - 0)];
float neighbor_2_Wxx = buffer_Wxx[(buf_y - 2) * buf_w + (buf_x - 0)];
float neighbor_3_Wxx = buffer_Wxx[(buf_y - 1) * buf_w + (buf_x - 0)];
float neighbor_5_Wxx = buffer_Wxx[(buf_y + 1) * buf_w + (buf_x + 0)];
float neighbor_6_Wxx = buffer_Wxx[(buf_y + 2) * buf_w + (buf_x + 0)];
float neighbor_7_Wxx = buffer_Wxx[(buf_y + 3) * buf_w + (buf_x + 0)];
float neighbor_8_Wxx = buffer_Wxx[(buf_y + 4) * buf_w + (buf_x + 0)];
float pixel_Wxx = buffer_Wxx[(buf_y + 0) * buf_w + (buf_x + 0)];
float Wxx_filter = pixel_Wxx * (filter[4]) + neighbor_0_Wxx * (filter[0]) + neighbor_1_Wxx * (filter[1]) +
neighbor_2_Wxx * (filter[2]) + neighbor_3_Wxx * (filter[3]) + neighbor_5_Wxx * (filter[5]) +
neighbor_6_Wxx * (filter[6]) + neighbor_7_Wxx * (filter[7]) + neighbor_8_Wxx * (filter[8]);
float neighbor_0_Wyy = buffer_Wyy[(buf_y - 4) * buf_w + (buf_x + 0)];
float neighbor_1_Wyy = buffer_Wyy[(buf_y - 3) * buf_w + (buf_x + 0)];
float neighbor_2_Wyy = buffer_Wyy[(buf_y - 2) * buf_w + (buf_x + 0)];
float neighbor_3_Wyy = buffer_Wyy[(buf_y - 1) * buf_w + (buf_x + 0)];
float neighbor_5_Wyy = buffer_Wyy[(buf_y + 1) * buf_w + (buf_x + 0)];
float neighbor_6_Wyy = buffer_Wyy[(buf_y + 2) * buf_w + (buf_x + 0)];
float neighbor_7_Wyy = buffer_Wyy[(buf_y + 3) * buf_w + (buf_x + 0)];
float neighbor_8_Wyy = buffer_Wyy[(buf_y + 4) * buf_w + (buf_x + 0)];
float pixel_Wyy = buffer_Wyy[(buf_y + 0) * buf_w + (buf_x + 0)];
float Wyy_filter = pixel_Wyy * (filter[4]) + neighbor_0_Wyy * (filter[0]) + neighbor_1_Wyy * (filter[1]) +
neighbor_2_Wyy * (filter[2]) + neighbor_3_Wyy * (filter[3]) + neighbor_5_Wyy * (filter[5]) +
neighbor_6_Wyy * (filter[6]) + neighbor_7_Wyy * (filter[7]) + neighbor_8_Wyy * (filter[8]);
float neighbor_0_Wxy = buffer_Wxy[(buf_y - 4) * buf_w + (buf_x + 0)];
float neighbor_1_Wxy = buffer_Wxy[(buf_y - 3) * buf_w + (buf_x + 0)];
float neighbor_2_Wxy = buffer_Wxy[(buf_y - 2) * buf_w + (buf_x + 0)];
float neighbor_3_Wxy = buffer_Wxy[(buf_y - 1) * buf_w + (buf_x + 0)];
float neighbor_5_Wxy = buffer_Wxy[(buf_y + 1) * buf_w + (buf_x + 0)];
float neighbor_6_Wxy = buffer_Wxy[(buf_y + 2) * buf_w + (buf_x + 0)];
float neighbor_7_Wxy = buffer_Wxy[(buf_y + 3) * buf_w + (buf_x + 0)];
float neighbor_8_Wxy = buffer_Wxy[(buf_y + 4) * buf_w + (buf_x + 0)];
float pixel_Wxy = buffer_Wxy[(buf_y + 0) * buf_w + (buf_x + 0)];
float Wxy_filter = pixel_Wxy * (filter[4]) + neighbor_0_Wxy * (filter[0]) + neighbor_1_Wxy * (filter[1]) +
neighbor_2_Wxy * (filter[2]) + neighbor_3_Wxy * (filter[3]) + neighbor_5_Wxy * (filter[5]) +
neighbor_6_Wxy * (filter[6]) + neighbor_7_Wxy * (filter[7]) + neighbor_8_Wxy * (filter[8]);
out_Wxx[y * w + x] = Wxx_filter;
out_Wyy[y * w + x] = Wyy_filter;
out_Wxy[y * w + x] = Wxy_filter;
}
}
// Performes a zero derivative gaussian on the X axis (verticle)
// Returs one array the size of the image
// Performs the harris eigen approximation and returns the full harris matrix
__kernel void
filter_second_axis_second_pass(
__global float *in_Wxx,
__global float *in_Wyy,
__global float *in_Wxy,
__global float *out_Harris,
__local float *buffer_Wxx,
__local float *buffer_Wyy,
__local float *buffer_Wxy,
int halo,
int w, int h,
int buf_w, int buf_h,
__global float *filter
)
{
//////////////////////Define Variables///////////////////////
// halo is the additional number of cells in one direction
// Global position of output pixel
int x = get_global_id(0);
int y = get_global_id(1);
// Local position relative to (0, 0) in workgroup
int lx = get_local_id(0); // with in workgroup, so less than buffer
int ly = get_local_id(1);
// coordinates of the upper left corner of the buffer in image (global)
// space, including halo
int buf_corner_x = x - lx - halo;
int buf_corner_y = y - ly - halo;
// coordinates of our pixel in the local buffer
// this shifts the buffer reference to the middle of the buffer
// where these pixels actualy exist in the buffer
int buf_x = lx + halo;
int buf_y = ly + halo;
// 1D index of thread within our work-group
int idx_1D = ly * get_local_size(0) + lx; //get_local_size = 8
//////////////////////loop to build Buffer///////////////////////
// Load the relevant labels to a local buffer with a halo
if (idx_1D < buf_w)
{
//Iterate down each colum, using a row iterator
for (int row = 0; row < buf_h; row++)
{
int max_x = buf_corner_x + idx_1D; // this is column index, add idx_1D
int max_y = buf_corner_y + row; //stepping by rows adjust y
int new_h = h - 1; // height index
int new_w = w - 1; // width index
// Load the values into the buffer
// This is a read from global memory global read
// Each thread is loading values into the buffer down columns
buffer_Wxx[row * buf_w + idx_1D] = in_Wxx[min(max(0, max_y), new_h) * w + min(max(0, max_x), new_w)];
buffer_Wyy[row * buf_w + idx_1D] = in_Wyy[min(max(0, max_y), new_h) * w + min(max(0, max_x), new_w)];
buffer_Wxy[row * buf_w + idx_1D] = in_Wxy[min(max(0, max_y), new_h) * w + min(max(0, max_x), new_w)];
}
}
//////////////////////coniditional statement to smooth///////////////////////
// Conditional with in bounds of the entire image
if (x < w && y < h)
{
float neighbor_0_Wxx = buffer_Wxx[(buf_y - 0) * buf_w + (buf_x - 4)];
float neighbor_1_Wxx = buffer_Wxx[(buf_y - 0) * buf_w + (buf_x - 3)];
float neighbor_2_Wxx = buffer_Wxx[(buf_y - 0) * buf_w + (buf_x - 2)];
float neighbor_3_Wxx = buffer_Wxx[(buf_y - 0) * buf_w + (buf_x - 1)];
float neighbor_5_Wxx = buffer_Wxx[(buf_y + 0) * buf_w + (buf_x + 1)];
float neighbor_6_Wxx = buffer_Wxx[(buf_y + 0) * buf_w + (buf_x + 2)];
float neighbor_7_Wxx = buffer_Wxx[(buf_y + 0) * buf_w + (buf_x + 3)];
float neighbor_8_Wxx = buffer_Wxx[(buf_y + 0) * buf_w + (buf_x + 4)];
float pixel_Wxx = buffer_Wxx[(buf_y + 0) * buf_w + (buf_x + 0)];
//use a nested for loop
float Wxx_filter = pixel_Wxx * (filter[4]) + neighbor_0_Wxx * (filter[0]) + neighbor_1_Wxx * (filter[1]) +
neighbor_2_Wxx * (filter[2]) + neighbor_3_Wxx * (filter[3]) + neighbor_5_Wxx * (filter[5]) +
neighbor_6_Wxx * (filter[6]) + neighbor_7_Wxx * (filter[7]) + neighbor_8_Wxx * (filter[8]);
//out_Wxx[y * w + x] = Wxx_filter;
float neighbor_0_Wyy = buffer_Wyy[(buf_y - 0) * buf_w + (buf_x - 4)];
float neighbor_1_Wyy = buffer_Wyy[(buf_y - 0) * buf_w + (buf_x - 3)];
float neighbor_2_Wyy = buffer_Wyy[(buf_y - 0) * buf_w + (buf_x - 2)];
float neighbor_3_Wyy = buffer_Wyy[(buf_y - 0) * buf_w + (buf_x - 1)];
float neighbor_5_Wyy = buffer_Wyy[(buf_y + 0) * buf_w + (buf_x + 1)];
float neighbor_6_Wyy = buffer_Wyy[(buf_y + 0) * buf_w + (buf_x + 2)];
float neighbor_7_Wyy = buffer_Wyy[(buf_y + 0) * buf_w + (buf_x + 3)];
float neighbor_8_Wyy = buffer_Wyy[(buf_y + 0) * buf_w + (buf_x + 4)];
float pixel_Wyy = buffer_Wyy[(buf_y + 0) * buf_w + (buf_x + 0)];
float Wyy_filter = pixel_Wyy * (filter[4]) + neighbor_0_Wyy * (filter[0]) + neighbor_1_Wyy * (filter[1]) +
neighbor_2_Wyy * (filter[2]) + neighbor_3_Wyy * (filter[3]) + neighbor_5_Wyy * (filter[5]) +
neighbor_6_Wyy * (filter[6]) + neighbor_7_Wyy * (filter[7]) + neighbor_8_Wyy * (filter[8]);
float neighbor_0_Wxy = buffer_Wxy[(buf_y - 0) * buf_w + (buf_x - 4)];
float neighbor_1_Wxy = buffer_Wxy[(buf_y - 0) * buf_w + (buf_x - 3)];
float neighbor_2_Wxy = buffer_Wxy[(buf_y - 0) * buf_w + (buf_x - 2)];
float neighbor_3_Wxy = buffer_Wxy[(buf_y - 0) * buf_w + (buf_x - 1)];
float neighbor_5_Wxy = buffer_Wxy[(buf_y + 0) * buf_w + (buf_x + 1)];
float neighbor_6_Wxy = buffer_Wxy[(buf_y + 0) * buf_w + (buf_x + 2)];
float neighbor_7_Wxy = buffer_Wxy[(buf_y + 0) * buf_w + (buf_x + 3)];
float neighbor_8_Wxy = buffer_Wxy[(buf_y + 0) * buf_w + (buf_x + 4)];
float pixel_Wxy = buffer_Wxy[(buf_y + 0) * buf_w + (buf_x + 0)];
float Wxy_filter = pixel_Wxy * (filter[4]) + neighbor_0_Wxy * (filter[0]) + neighbor_1_Wxy * (filter[1]) +
neighbor_2_Wxy * (filter[2]) + neighbor_3_Wxy * (filter[3]) + neighbor_5_Wxy * (filter[5]) +
neighbor_6_Wxy * (filter[6]) + neighbor_7_Wxy * (filter[7]) + neighbor_8_Wxy * (filter[8]);
float Wdet = Wxx_filter * Wyy_filter - Wxy_filter * Wxy_filter;
float Wtr = Wxx_filter + Wyy_filter;
float ans = Wdet / Wtr;
out_Harris[y * w + x] = ans;
}
}