卷积:
static int filter0(uint8_t *src, uint8_t *dst,int w, int h) { double start, end; int i =1; int j =1; if(w > WIDTH || h > HEIGHT) return 1; start = now_ms(); for (i=1; i < h - 1; ++i) { for (j=1; j < w - 1; ++j) { int index = j + i * w; uint8_t lu = src[index - 1 - w]; uint8_t lm = src[index - 1]; uint8_t ld = src[index - 1 + w]; uint8_t mu = src[index - w]; uint8_t mm = src[index]; uint8_t md = src[index + w]; uint8_t ru = src[index + 1 - w]; uint8_t rm = src[index + 1]; uint8_t rd = src[index + 1 + w]; int sum = lu + lm + ld + mu + mm + md + ru + rm + rd; dst[index] = (uint8_t)sum / 9 + 1; } } end = now_ms(); printf("filter %f ", end - start); return 0; }