Skip to content

Commit

Permalink
in void calculate_edge_histogram, 1)IMPORTANT: corrected the index us…
Browse files Browse the repository at this point in the history
…ed for img_buf, the +1 caused a out of array memory address to be looked up. Also it caused wrong calculations to take place arround the borders of the image 2)removed comments that were from an old version
  • Loading branch information
TitusBraber committed Mar 23, 2017
1 parent aab67c0 commit a75b2e8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions sw/airborne/modules/computer_vision/lib/vision/edge_flow.c
Expand Up @@ -122,9 +122,9 @@ void calculate_edge_histogram(struct image_t *img, int32_t edge_histogram[],
sobel_sum = 0;

for (c = -1; c <= 1; c++) {
idx = interlace * (image_width * y + (x + c)); // 2 for interlace
idx = interlace * (image_width * y + (x + c));

sobel_sum += Sobel[c + 1] * (int32_t)img_buf[idx + 1];
sobel_sum += Sobel[c + 1] * (int32_t)img_buf[idx];
}
sobel_sum = abs(sobel_sum);
if (sobel_sum > edge_threshold) {
Expand All @@ -141,9 +141,9 @@ void calculate_edge_histogram(struct image_t *img, int32_t edge_histogram[],
sobel_sum = 0;

for (c = -1; c <= 1; c++) {
idx = interlace * (image_width * (y + c) + x); // 2 for interlace
idx = interlace * (image_width * (y + c) + x);

sobel_sum += Sobel[c + 1] * (int32_t)img_buf[idx + 1];
sobel_sum += Sobel[c + 1] * (int32_t)img_buf[idx];
}
sobel_sum = abs(sobel_sum);
if (sobel_sum > edge_threshold) {
Expand Down

0 comments on commit a75b2e8

Please sign in to comment.