From 37f55b0e7e400b6c94585d2cbfb46d4c416f6928 Mon Sep 17 00:00:00 2001 From: p8sljnpht <3178612685@qq.com> Date: Sat, 30 Nov 2024 09:38:04 +0800 Subject: [PATCH 1/3] ADD file via upload --- cxy/1.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 cxy/1.c diff --git a/cxy/1.c b/cxy/1.c new file mode 100644 index 0000000..420d1e2 --- /dev/null +++ b/cxy/1.c @@ -0,0 +1,52 @@ +#include +#include +#include +#include + +void applyGaussianBlur(void*, void*, int, int, float[3][3]); +void print(void* _a, int h, int w); +int main() { + float inputImage[5][5] = { + {1,2,3,4,5}, + {6,7,8,9,10}, + {11,12,13,14,15}, + {16,17,18,19,20}, + {21,22,23,24,25} + }; + float kernel[3][3] = { + {1.0f/16, 2.0f/16, 1.0f/16}, + {2.0f/16, 4.0f/16, 2.0f/16}, + {1.0f/16, 2.0f/16, 1.0f/16} + }; + float outputImage[5][5] = {0}; + clock_t start = clock(); + applyGaussianBlur(inputImage, outputImage, 5, 5, kernel); + clock_t end = clock(); + printf("Time: %lf s\n", (double)(end-start) / CLOCKS_PER_SEC); + print(outputImage, 5, 5); +} + +void applyGaussianBlur(void* _src, void* _dst, + int h, int w, float kernel[3][3]) { + int i, j; + float (*src)[w] = (float(*)[w])_src; + float (*dst)[w] = (float(*)[w])_dst; + for(i=1; i Date: Sat, 30 Nov 2024 09:38:13 +0800 Subject: [PATCH 2/3] ADD file via upload --- cxy/2.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 cxy/2.c diff --git a/cxy/2.c b/cxy/2.c new file mode 100644 index 0000000..9ac2e82 --- /dev/null +++ b/cxy/2.c @@ -0,0 +1,61 @@ +#include +#include +#include +#include +#define IDX(n) ((n) % 3) + +void applySeparableGaussianBlur(void*, void*, int, int, float[3], float[3]); +void print(void*, int h, int w); +int main() { + float inputImage[5][5] = { + {1,2,3,4,5}, + {6,7,8,9,10}, + {11,12,13,14,15}, + {16,17,18,19,20}, + {21,22,23,24,25} + }; + float kernel[3][3] = { + {1.0f/16, 2.0f/16, 1.0f/16}, + {2.0f/16, 4.0f/16, 2.0f/16}, + {1.0f/16, 2.0f/16, 1.0f/16} + }; + float kx[3] = {0.25f, 0.5f, 0.25f}; + float ky[3] = {0.25f, 0.5f, 0.25f}; + float outputImage[5][5] = {0}; + clock_t start = clock(); + applySeparableGaussianBlur(inputImage, outputImage, 5, 5, kx, ky); + clock_t end = clock(); + printf("Time: %lf s\n", (double)(end-start) / CLOCKS_PER_SEC); + print(outputImage, 5, 5); +} + +void applySeparableGaussianBlur(void* _src, void* _dst, + int h, int w, float kx[3], float ky[3]) { + float buf[3][101] = {0}; + int i, j; + float (*src)[w] = (float(*)[w])_src; + float (*dst)[w] = (float(*)[w])_dst; + // 计算前两行的行内卷积 + for(i=0; i<2; i++) + for(j=1; j Date: Sat, 30 Nov 2024 09:38:22 +0800 Subject: [PATCH 3/3] ADD file via upload --- cxy/3.c | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 cxy/3.c diff --git a/cxy/3.c b/cxy/3.c new file mode 100644 index 0000000..fc6a641 --- /dev/null +++ b/cxy/3.c @@ -0,0 +1,76 @@ +#include +#include +#include +#include +#include +#define IDX(n) ((n) % 3) + +void applySeparableGaussianBlur(float src[][100], float dst[][100], + int h, int w, float kx[], float ky[]); +void print(float a[][100], int h, int w); +int main() { + float inputImage[5][100] = { + {1,2,3,4,5}, + {6,7,8,9,10}, + {11,12,13,14,15}, + {16,17,18,19,20}, + {21,22,23,24,25} + }; + float kernel[3][3] = { + {1.0f/16, 2.0f/16, 1.0f/16}, + {2.0f/16, 4.0f/16, 2.0f/16}, + {1.0f/16, 2.0f/16, 1.0f/16} + }; + float kx[4] = {0.25f, 0.5f, 0.25f, 0.0f}; // 防止越界多定义一个 + float ky[4] = {0.25f, 0.5f, 0.25f, 0.0f}; + float outputImage[5][100] = {0}; + clock_t start = clock(); + applySeparableGaussianBlur(inputImage, outputImage, 5, 5, kx, ky); + clock_t end = clock(); + printf("Time: %lf s\n", (double)(end-start) / CLOCKS_PER_SEC); + print(outputImage, 5, 5); +} + +void applySeparableGaussianBlur(float src[][100], float dst[][100], + int h, int w, float kx[], float ky[]) { + int i, j; + float buf[3][101] = {0}; + float32x4_t kx_vec = vld1q_f32(kx); + float32x4_t ky_vec = vld1q_f32(ky); + // 计算前两行的行内卷积 + for(i=0; i<2; i++) + for(j=1; j