 	FOR_WINDOW(i2, j2, i, j, h, w, 1) {
 		for (t = 0; t < nbacklogs; t++) {
 			uint32_t v = backlogs[t][i2*w+j2];
-			double d = distance(v, center);
+			uint32_t d = distance(v, center);
 			// Insert v into elems
 			for (e = nelems-1; e >= 0 && elems[e].d > d; e--) {
 				if (e < KNN_NELEMS-1) {

			continue;
		}
		uint32_t v = in[i2*w+j2];
		double d = distance(v, center);
		// Insert v into elems
		for (e = nelems-1; e >= 0 && elems[e].d > d; e--) {
			if (e < KNN_NELEMS-1) {

	FOR_WINDOW(i2, j2, i, j, h, w, 1) {
		for (t = 0; t < nf; t++) {
			uint32_t v = backlogs[t][i2*w+j2];
			uint32_t d = distance(v, center);
			if (edge && d > Z_THRD) {
				continue;
			}
