[TASK] Fix up the gauss filter weights.

This commit is contained in:
Jan Philipp Timme 2015-12-20 17:20:42 +01:00
parent 000a2be162
commit 09c9390f42

View File

@ -72,8 +72,13 @@ class CannyEdgeMachine {
// build the gauss filter // build the gauss filter
int* filter = (int*) malloc(sizeof(int) * filter_width* filter_width); int* filter = (int*) malloc(sizeof(int) * filter_width* filter_width);
int sum_weights = 0; int sum_weights = 0;
for(int i=0; i<filter_width; i++) { int filter_middle = (filter_width)/2;
for(int j=0; j<filter_width; j++) { for(int x=0; x<filter_width; x++) {
int i = x;
if(x > filter_middle) i = filter_middle - (x - filter_middle);
for(int y=0; y<filter_width; y++) {
int j = y;
if(y > filter_middle) j = filter_middle - (y - filter_middle);
filter[i*filter_width + j] = pow(2, i) * pow(2, j); filter[i*filter_width + j] = pow(2, i) * pow(2, j);
sum_weights += filter[i*filter_width + j]; sum_weights += filter[i*filter_width + j];
} }