|
|
#include <iostream>
|
|
|
#include <ctime>
|
|
|
#include <arm_neon.h>
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
#define H 5
|
|
|
#define W 5
|
|
|
|
|
|
// 打印矩阵
|
|
|
void printMatrix(float matrix[H][W]) {
|
|
|
for (int i = 0; i < H; ++i) {
|
|
|
for (int j = 0; j < W; ++j) {
|
|
|
cout << matrix[i][j] << " ";
|
|
|
}
|
|
|
cout << endl;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
int main() {
|
|
|
// 输入的5×5图像矩阵
|
|
|
float src[H][W] = {
|
|
|
{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/16.0, 2/16.0, 1/16.0},
|
|
|
{2/16.0, 4/16.0, 2/16.0},
|
|
|
{1/16.0, 2/16.0, 1/16.0}
|
|
|
};
|
|
|
|
|
|
// 行列分离核
|
|
|
float kx[3] = {1/4.0, 2/4.0, 1/4.0};
|
|
|
float ky[3] = {1/4.0, 2/4.0, 1/4.0};
|
|
|
|
|
|
float dst1[H][W] = {0}, dst2[H][W] = {0}, dst3[H][W] = {0};
|
|
|
|
|
|
// 计时步骤1
|
|
|
clock_t start1 = clock();
|
|
|
// applyGaussianBlur(src, dst1, H, W, kernel); // 假设已实现
|
|
|
clock_t end1 = clock();
|
|
|
|
|
|
// 计时步骤2
|
|
|
clock_t start2 = clock();
|
|
|
// applySeparableGaussianBlur(src, dst2, H, W, kx, ky); // 假设已实现
|
|
|
clock_t end2 = clock();
|
|
|
|
|
|
// 计时步骤3
|
|
|
clock_t start3 = clock();
|
|
|
// applySeparableGaussianBlur_NEON(src, dst3, H, W, kx, ky); // 假设已实现
|
|
|
clock_t end3 = clock();
|
|
|
|
|
|
// 结果输出
|
|
|
cout << "步骤1输出矩阵:" << endl;
|
|
|
printMatrix(dst1);
|
|
|
cout << "步骤1运行时间: " << (double)(end1 - start1) / CLOCKS_PER_SEC << " 秒" << endl;
|
|
|
|
|
|
cout << "步骤2输出矩阵:" << endl;
|
|
|
printMatrix(dst2);
|
|
|
cout << "步骤2运行时间: " << (double)(end2 - start2) / CLOCKS_PER_SEC << " 秒" << endl;
|
|
|
|
|
|
cout << "步骤3输出矩阵:" << endl;
|
|
|
printMatrix(dst3);
|
|
|
cout << "步骤3运行时间: " << (double)(end3 - start3) / CLOCKS_PER_SEC << " 秒" << endl;
|
|
|
|
|
|
return 0;
|
|
|
} |