diff --git a/cxy_opt/2.c b/cxy_opt/2.c new file mode 100644 index 0000000..dc0b8ed --- /dev/null +++ b/cxy_opt/2.c @@ -0,0 +1,38 @@ +#include +#include +#include +#include +#include "render.h" +#define IDX(n) ((n) % 3) + +void applySeparableGaussianBlur(float[][MAT_SIZE], float[][MAT_SIZE], float[3], float[3]); +int main() { + float inputImage[MAT_SIZE][MAT_SIZE]; + Render(inputImage); + + float kx[3] = {1.0f/4, 1.0f/2, 1.0f/4}; + float ky[3] = {1.0f/4, 1.0f/2, 1.0f/4}; + float outputImage[MAT_SIZE][MAT_SIZE] = {0}; + clock_t start = clock(); + applySeparableGaussianBlur(inputImage, outputImage, kx, ky); + clock_t end = clock(); + printf("Time: %lf s\n", (double)(end-start) / CLOCKS_PER_SEC); + Print(outputImage); +} + +void applySeparableGaussianBlur(float src[][MAT_SIZE], float dst[][MAT_SIZE], float kx[3], float ky[3]) { + float buf[3][MAT_SIZE+3]; + int i, j; + // 计算前两行的行内卷积 + for(i=0; i<2; i++) + for(j=1; j