空域滤波

Content

  • 利用均值模板平滑灰度图像

    具体内容:利用OpenCV对图像像素进行操作,分别利用3*3、5*5和9*9尺寸的均值模板平滑灰度图像。

  • 利用高斯模板平滑灰度图像

    具体内容: 利用OpenCV对图像像素进行操作,分别利用3*3、5*5和9*9尺寸的高斯模板平滑灰度图像。

  • 利用Laplacian、Robert、Sobel模板锐化灰度图像

    具体内容: 利用OpenCV对图像像素进行操作,分别利用Laplacian、Robert、Sobel模板锐化灰度图像。

  • 利用高提升滤波算法增强灰度图像

    具体内容:利用OpenCV对图像像素进行操作,设计高提升滤波算法增强图像。

  • 利用均值模板平滑彩色图像

    具体内容: 利用OpenCV分别对图像像素的RGB三个通道进行操作,分别利用3*3、5*5和9*9尺寸的均值模板平滑彩色图像。

  • 利用高斯模板平滑彩色图像

    具体内容: 利用OpenCV分别对图像像素的RGB三个通道进行操作,分别利用3*3、5*5和9*9尺寸的高斯模板平滑彩色图像。

  • 利用Laplacian、Robert、Sobel模板锐化彩色图像

    具体内容: 利用OpenCV分别对图像像素的RGB三个通道进行操作,分别利用Laplacian、Robert、Sobel模板锐化彩色图像。

Code

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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
#include <iostream>
#include <vector>
#include <opencv2/opencv.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
using namespace cv;
using namespace std;

// 灰度图像均值滤波
Mat meanFilter_Gray(const Mat& srcImage, int ksize)
{
Mat dstImage = srcImage.clone();
int nRows = srcImage.rows;
int nCols = srcImage.cols;
int nHalfSize = ksize / 2;
for (int i = nHalfSize; i < nRows - nHalfSize; i++)
{
for (int j = nHalfSize; j < nCols - nHalfSize; j++)
{
int sum = 0;
for (int m = -nHalfSize; m <= nHalfSize; m++)
{
for (int n = -nHalfSize; n <= nHalfSize; n++)
{
sum += srcImage.at<uchar>(i + m, j + n);
}
}
dstImage.at<uchar>(i, j) = sum / (ksize * ksize);
}
}
return dstImage;
}

// 彩色图像均值滤波
Mat meanFilter_RGB(const Mat& srcImage, int ksize)
{
Mat dstImage = srcImage.clone();
int nRows = srcImage.rows;
int nCols = srcImage.cols;
int nHalfSize = ksize / 2;
for (int i = nHalfSize; i < nRows - nHalfSize; i++)
{
for (int j = nHalfSize; j < nCols - nHalfSize; j++)
{
int sumB = 0;
int sumG = 0;
int sumR = 0;
for (int m = -nHalfSize; m <= nHalfSize; m++)
{
for (int n = -nHalfSize; n <= nHalfSize; n++)
{
sumB += srcImage.at<Vec3b>(i + m, j + n)[0];
sumG += srcImage.at<Vec3b>(i + m, j + n)[1];
sumR += srcImage.at<Vec3b>(i + m, j + n)[2];
}
}
dstImage.at<Vec3b>(i, j)[0] = sumB / (ksize * ksize);
dstImage.at<Vec3b>(i, j)[1] = sumG / (ksize * ksize);
dstImage.at<Vec3b>(i, j)[2] = sumR / (ksize * ksize);
}
}
return dstImage;
}

// 灰度图像高斯滤波
Mat gaussianFilter_Gray(const Mat& srcImage, int ksize, double sigma)
{
Mat dstImage = srcImage.clone();
int nRows = srcImage.rows;
int nCols = srcImage.cols;
int nHalfSize = ksize / 2;
double* kernel = new double[ksize * ksize];
double sum = 0;
for (int i = -nHalfSize; i <= nHalfSize; i++)
{
for (int j = -nHalfSize; j <= nHalfSize; j++)
{
kernel[(i + nHalfSize) * ksize + j + nHalfSize] = exp(-(i * i + j * j) / (2 * sigma * sigma));
sum += kernel[(i + nHalfSize) * ksize + j + nHalfSize];
}
}
for (int i = 0; i < ksize * ksize; i++)
{
kernel[i] /= sum;
}
for (int i = nHalfSize; i < nRows - nHalfSize; i++)
{
for (int j = nHalfSize; j < nCols - nHalfSize; j++)
{
double sum = 0;
for (int m = -nHalfSize; m <= nHalfSize; m++)
{
for (int n = -nHalfSize; n <= nHalfSize; n++)
{
sum += srcImage.at<uchar>(i + m, j + n) * kernel[(m + nHalfSize) * ksize + n + nHalfSize];
}
}
dstImage.at<uchar>(i, j) = sum;
}
}
return dstImage;
}

// 彩色图像高斯滤波
Mat gaussianFilter_RGB(const Mat& srcImage, int ksize, double sigma)
{
Mat dstImage = srcImage.clone();
int nRows = srcImage.rows;
int nCols = srcImage.cols;
int nHalfSize = ksize / 2;
double* kernel = new double[ksize * ksize];
double sum = 0;
for (int i = -nHalfSize; i <= nHalfSize; i++)
{
for (int j = -nHalfSize; j <= nHalfSize; j++)
{
kernel[(i + nHalfSize) * ksize + j + nHalfSize] = exp(-(i * i + j * j) / (2 * sigma * sigma));
sum += kernel[(i + nHalfSize) * ksize + j + nHalfSize];
}
}
for (int i = 0; i < ksize * ksize; i++)
{
kernel[i] /= sum;
}
for (int i = nHalfSize; i < nRows - nHalfSize; i++)
{
for (int j = nHalfSize; j < nCols - nHalfSize; j++)
{
double sumB = 0;
double sumG = 0;
double sumR = 0;
for (int m = -nHalfSize; m <= nHalfSize; m++)
{
for (int n = -nHalfSize; n <= nHalfSize; n++)
{
sumB += srcImage.at<Vec3b>(i + m, j + n)[0] * kernel[(m + nHalfSize) * ksize + n + nHalfSize];
sumG += srcImage.at<Vec3b>(i + m, j + n)[1] * kernel[(m + nHalfSize) * ksize + n + nHalfSize];
sumR += srcImage.at<Vec3b>(i + m, j + n)[2] * kernel[(m + nHalfSize) * ksize + n + nHalfSize];
}
}
dstImage.at<Vec3b>(i, j)[0] = sumB;
dstImage.at<Vec3b>(i, j)[1] = sumG;
dstImage.at<Vec3b>(i, j)[2] = sumR;
}
}
return dstImage;
}

// 灰度图拉普拉斯滤波
Mat laplacianFilter_Gray(const Mat& srcImage)
{
Mat dstImage = srcImage.clone();
int nRows = srcImage.rows;
int nCols = srcImage.cols;
int kernel[3][3] = { {0, 1, 0}, {1, -4, 1}, {0, 1, 0} };
for (int i = 1; i < nRows - 1; i++)
{
for (int j = 1; j < nCols - 1; j++)
{
int sum = 0;
for (int m = -1; m <= 1; m++)
{
for (int n = -1; n <= 1; n++)
{
sum += srcImage.at<uchar>(i + m, j + n) * kernel[m + 1][n + 1];
}
}
dstImage.at<uchar>(i, j) = sum;
}
}
return dstImage;
}

// 彩色图像拉普拉斯滤波
Mat laplacianFilter_RGB(const Mat& srcImage)
{
Mat dstImage = srcImage.clone();
int nRows = srcImage.rows;
int nCols = srcImage.cols;
int kernel[3][3] = { {0, 1, 0}, {1, -4, 1}, {0, 1, 0} };
for (int i = 1; i < nRows - 1; i++)
{
for (int j = 1; j < nCols - 1; j++)
{
int sumB = 0;
int sumG = 0;
int sumR = 0;
for (int m = -1; m <= 1; m++)
{
for (int n = -1; n <= 1; n++)
{
sumB += srcImage.at<Vec3b>(i + m, j + n)[0] * kernel[m + 1][n + 1];
sumG += srcImage.at<Vec3b>(i + m, j + n)[1] * kernel[m + 1][n + 1];
sumR += srcImage.at<Vec3b>(i + m, j + n)[2] * kernel[m + 1][n + 1];
}
}
dstImage.at<Vec3b>(i, j)[0] = sumB;
dstImage.at<Vec3b>(i, j)[1] = sumG;
dstImage.at<Vec3b>(i, j)[2] = sumR;
}
}
return dstImage;
}

// 灰度图Roberts滤波
Mat robertFilter_Gray(const Mat& srcImage)
{
Mat dstImage = srcImage.clone();
int nRows = srcImage.rows;
int nCols = srcImage.cols;
int kernelX[2][2] = { {-1, 0}, {0, 1} };
int kernelY[2][2] = { {0, -1}, {1, 0} };
for (int i = 0; i < nRows - 1; i++)
{
for (int j = 0; j < nCols - 1; j++)
{
int sumX = 0;
int sumY = 0;
for (int m = 0; m <= 1; m++)
{
for (int n = 0; n <= 1; n++)
{
sumX += srcImage.at<uchar>(i + m, j + n) * kernelX[m][n];
sumY += srcImage.at<uchar>(i + m, j + n) * kernelY[m][n];
}
}
dstImage.at<uchar>(i, j) = abs(sumX) + abs(sumY);
}
}
return dstImage;
}

// 彩色图Roberts滤波
Mat robertFilter_RGB(const Mat& srcImage)
{
Mat dstImage = srcImage.clone();
int nRows = srcImage.rows;
int nCols = srcImage.cols;
int kernelX[2][2] = { {-1, 0}, {0, 1} };
int kernelY[2][2] = { {0, -1}, {1, 0} };
for (int i = 0; i < nRows - 1; i++)
{
for (int j = 0; j < nCols - 1; j++)
{
int sumX_B = 0;
int sumY_B = 0;
int sumX_G = 0;
int sumY_G = 0;
int sumX_R = 0;
int sumY_R = 0;
for (int m = 0; m <= 1; m++)
{
for (int n = 0; n <= 1; n++)
{
sumX_B += srcImage.at<Vec3b>(i + m, j + n)[0] * kernelX[m][n];
sumY_B += srcImage.at<Vec3b>(i + m, j + n)[0] * kernelY[m][n];
sumX_G += srcImage.at<Vec3b>(i + m, j + n)[1] * kernelX[m][n];
sumY_G += srcImage.at<Vec3b>(i + m, j + n)[1] * kernelY[m][n];
sumX_R += srcImage.at<Vec3b>(i + m, j + n)[2] * kernelX[m][n];
sumY_R += srcImage.at<Vec3b>(i + m, j + n)[2] * kernelY[m][n];
}
}
dstImage.at<Vec3b>(i, j)[0] = abs(sumX_B) + abs(sumY_B);
dstImage.at<Vec3b>(i, j)[1] = abs(sumX_G) + abs(sumY_G);
dstImage.at<Vec3b>(i, j)[2] = abs(sumX_R) + abs(sumY_R);
}
}
return dstImage;
}

// 灰度图Sobel滤波
Mat sobelFilter_Gray(const Mat& srcImage)
{
Mat dstImage = srcImage.clone();
int nRows = srcImage.rows;
int nCols = srcImage.cols;
int kernelX[3][3] = { {1, 0, -1}, {2, 0, -2}, {1, 0, -1} };
int kernelY[3][3] = { {1, 2, 1}, {0, 0, 0}, {-1, -2, -1} };
for (int i = 1; i < nRows - 1; i++)
{
for (int j = 1; j < nCols - 1; j++)
{
int sumX = 0;
int sumY = 0;
for (int m = -1; m <= 1; m++)
{
for (int n = -1; n <= 1; n++)
{
sumX += srcImage.at<uchar>(i + m, j + n) * kernelX[m + 1][n + 1];
sumY += srcImage.at<uchar>(i + m, j + n) * kernelY[m + 1][n + 1];
}
}
dstImage.at<uchar>(i, j) = sqrt(sumX * sumX + sumY * sumY);
}
}
return dstImage;
}

// 彩色图Sobel滤波
Mat sobelFilter_RGB(const Mat& srcImage)
{
Mat dstImage = srcImage.clone();
int nRows = srcImage.rows;
int nCols = srcImage.cols;
int kernelX[3][3] = { {1, 0, -1}, {2, 0, -2}, {1, 0, -1} };
int kernelY[3][3] = { {1, 2, 1}, {0, 0, 0}, {-1, -2, -1} };
for (int i = 1; i < nRows - 1; i++)
{
for (int j = 1; j < nCols - 1; j++)
{
int sumX_B = 0;
int sumY_B = 0;
int sumX_G = 0;
int sumY_G = 0;
int sumX_R = 0;
int sumY_R = 0;
for (int m = -1; m <= 1; m++)
{
for (int n = -1; n <= 1; n++)
{
sumX_B += srcImage.at<Vec3b>(i + m, j + n)[0] * kernelX[m + 1][n + 1];
sumY_B += srcImage.at<Vec3b>(i + m, j + n)[0] * kernelY[m + 1][n + 1];
sumX_G += srcImage.at<Vec3b>(i + m, j + n)[1] * kernelX[m + 1][n + 1];
sumY_G += srcImage.at<Vec3b>(i + m, j + n)[1] * kernelY[m + 1][n + 1];
sumX_R += srcImage.at<Vec3b>(i + m, j + n)[2] * kernelX[m + 1][n + 1];
sumY_R += srcImage.at<Vec3b>(i + m, j + n)[2] * kernelY[m + 1][n + 1];
}
}
dstImage.at<Vec3b>(i, j)[0] = abs(sumX_B) + abs(sumY_B);
dstImage.at<Vec3b>(i, j)[1] = abs(sumX_G) + abs(sumY_G);
dstImage.at<Vec3b>(i, j)[2] = abs(sumX_R) + abs(sumY_R);
}
}
return dstImage;
}

Mat highBoostFilter_Gray(const Mat& srcImage, double k)
{
Mat dstImage = gaussianFilter_Gray(srcImage, 7, 1);
dstImage = srcImage + k * (srcImage - dstImage);
return dstImage;
}

Mat highBoostFilter_RGB(const Mat& srcImage, double k)
{
Mat dstImage = gaussianFilter_RGB(srcImage, 7, 1);
dstImage = srcImage + k * (srcImage - dstImage);
return dstImage;
}

int main()
{

Mat myImage = imread("wallhaven.jpg");
//imshow("Image", myImage);
Mat grayImage;
// 转换为灰度图像
cvtColor(myImage, grayImage, COLOR_BGR2GRAY);
imshow("GrayImage", grayImage);
imwrite("GrayImage.jpg", grayImage);

// 灰度图均值滤波 3 5 9
Mat grayImgAfterMeanFilter3 = meanFilter_Gray(grayImage, 3);
imshow("GrayImgAfterMeanFilter3", grayImgAfterMeanFilter3);
imwrite("GrayImgAfterMeanFilter3.jpg", grayImgAfterMeanFilter3);
Mat grayImgAfterMeanFilter5 = meanFilter_Gray(grayImage, 5);
imshow("GrayImgAfterMeanFilter5", grayImgAfterMeanFilter5);
imwrite("GrayImgAfterMeanFilter5.jpg", grayImgAfterMeanFilter5);
Mat grayImgAfterMeanFilter9 = meanFilter_Gray(grayImage, 9);
imshow("GrayImgAfterMeanFilter9", grayImgAfterMeanFilter9);
imwrite("GrayImgAfterMeanFilter9.jpg", grayImgAfterMeanFilter9);

// 彩色图均值滤波 3 5 9
Mat rgbImgAfterMeanFilter3 = meanFilter_RGB(myImage, 3);
imshow("RgbImgAfterMeanFilter3", rgbImgAfterMeanFilter3);
imwrite("RgbImgAfterMeanFilter3.jpg", rgbImgAfterMeanFilter3);
Mat rgbImgAfterMeanFilter5 = meanFilter_RGB(myImage, 5);
imshow("RgbImgAfterMeanFilter5", rgbImgAfterMeanFilter5);
imwrite("RgbImgAfterMeanFilter5.jpg", rgbImgAfterMeanFilter5);
Mat rgbImgAfterMeanFilter9 = meanFilter_RGB(myImage, 9);
imshow("RgbImgAfterMeanFilter9", rgbImgAfterMeanFilter9);
imwrite("RgbImgAfterMeanFilter9.jpg", rgbImgAfterMeanFilter9);

// OpenCV自带的均值滤波 用于对比
//Mat imgAfterMeanFilter_OpenCV;
//blur(myImage, imgAfterMeanFilter_OpenCV, Size(9, 9));
//imshow("imgAfterMeanFilter_OpenCV", imgAfterMeanFilter_OpenCV);

// 灰度图高斯滤波 3 5 9
Mat grayImgAfterGaussianFilter3 = gaussianFilter_Gray(grayImage, 3, 1);
imshow("GrayImgAfterGaussianFilter3", grayImgAfterGaussianFilter3);
imwrite("GrayImgAfterGaussianFilter3.jpg", grayImgAfterGaussianFilter3);
Mat grayImgAfterGaussianFilter5 = gaussianFilter_Gray(grayImage, 5, 1);
imshow("GrayImgAfterGaussianFilter5", grayImgAfterGaussianFilter5);
imwrite("GrayImgAfterGaussianFilter5.jpg", grayImgAfterGaussianFilter5);
Mat grayImgAfterGaussianFilter9 = gaussianFilter_Gray(grayImage, 9, 1);
imshow("GrayImgAfterGaussianFilter9", grayImgAfterGaussianFilter9);
imwrite("GrayImgAfterGaussianFilter9.jpg", grayImage);

// 彩色图高斯滤波 3 5 9
Mat rgbImgAfterGaussianFilter3 = gaussianFilter_RGB(myImage, 3, 1);
imshow("RgbImgAfterGaussianFilter3", rgbImgAfterGaussianFilter3);
imwrite("RgbImgAfterGaussianFilter3.jpg", rgbImgAfterGaussianFilter3);
Mat rgbImgAfterGaussianFilter5 = gaussianFilter_RGB(myImage, 5, 1);
imshow("RgbImgAfterGaussianFilter5", rgbImgAfterGaussianFilter5);
imwrite("RgbImgAfterGaussianFilter5.jpg", rgbImgAfterGaussianFilter5);
Mat rgbImgAfterGaussianFilter9 = gaussianFilter_RGB(myImage, 9, 1);
imshow("RgbImgAfterGaussianFilter9", rgbImgAfterGaussianFilter9);
imwrite("RgbImgAfterGaussianFilter9.jpg", rgbImgAfterGaussianFilter9);

// OpenCV自带的高斯滤波 用于对比
//Mat imgAfterGaussianFilter_OpenCV;
//GaussianBlur(myImage, imgAfterGaussianFilter_OpenCV, Size(7, 7), 1);
//imshow("GrayImgAfterGaussianFilter_OpenCV", imgAfterGaussianFilter_OpenCV);

// 灰度图拉普拉斯滤波
Mat grayImgAfterLaplacianFilter = laplacianFilter_Gray(grayImage);
Mat grayImgAfterLaplacianFilterDst=grayImage-grayImgAfterLaplacianFilter;
imshow("GrayLaplacianDst", grayImgAfterLaplacianFilterDst);
imwrite("GrayLaplacianDst.jpg", grayImgAfterLaplacianFilterDst);
imshow("GrayImgAfterLaplacianFilter", grayImgAfterLaplacianFilter);
imwrite("GrayImgAfterLaplacianFilter.jpg", grayImgAfterLaplacianFilter);

// 彩色图拉普拉斯滤波
Mat rgbImgAfterLaplacianFilter = laplacianFilter_RGB(myImage);
Mat rgbImgAfterLaplacianFilterDst =myImage-rgbImgAfterLaplacianFilter;
imshow("RGBLaplacianDst", rgbImgAfterLaplacianFilterDst);
imwrite("RGBLaplacianDst.jpg", rgbImgAfterLaplacianFilterDst);
imshow("RgbImgAfterLaplacianFilter", rgbImgAfterLaplacianFilter);
imwrite("RgbImgAfterLaplacianFilter.jpg", rgbImgAfterLaplacianFilter);

// 灰度图Roberts滤波
Mat grayImgAfterRobertFilter = robertFilter_Gray(grayImage);
Mat grayImgAfterRobertFilterDst=grayImage-grayImgAfterRobertFilter;
imshow("GrayRobertDst", grayImgAfterRobertFilterDst);
imwrite("GrayRobertDst.jpg", grayImgAfterRobertFilterDst);
imshow("GrayImgAfterRobertFilter", grayImgAfterRobertFilter);
imwrite("GrayImgAfterRobertFilter.jpg", grayImgAfterRobertFilter);

// 彩色图Roberts滤波
Mat rgbImgAfterRobertFilter = robertFilter_RGB(myImage);
Mat rgbImgAfterRobertFilterDst=myImage-rgbImgAfterRobertFilter;
imshow("RGBImgRobertDst", rgbImgAfterRobertFilterDst);
imwrite("RGBImgRobertDst.jpg", rgbImgAfterRobertFilterDst);
imshow("RgbImgAfterRobertFilter", rgbImgAfterRobertFilter);
imwrite("RgbImgAfterRobertFilter.jpg", rgbImgAfterRobertFilter);

// 灰度图Sobel滤波
Mat grayImgAfterSobelFilter = sobelFilter_Gray(grayImage);
Mat grayImgAfterSobelFilterDst=grayImage-grayImgAfterSobelFilter;
imshow("GraySobelDst", grayImgAfterSobelFilterDst);
imwrite("GraySobelDst.jpg", grayImgAfterSobelFilterDst);
imshow("GrayImgAfterSobelFilter", grayImgAfterSobelFilter);
imwrite("GrayImgAfterSobelFilter.jpg", grayImgAfterSobelFilter);

// 彩色图Sobel滤波
Mat rgbImgAfterSobelFilter = sobelFilter_RGB(myImage);
Mat rgbImgAfterSobelFilterDst=myImage-rgbImgAfterSobelFilter;
imshow("RGBImgSobelDst", rgbImgAfterSobelFilterDst);
imwrite("RGBImgSobelDst.jpg", rgbImgAfterSobelFilterDst);
imshow("RgbImgAfterSobelFilter", rgbImgAfterSobelFilter);
imwrite("RgbImgAfterSobelFilter.jpg", rgbImgAfterSobelFilter);

// 灰度图高提升滤波
Mat grayImgAfterHighBoostFilter = highBoostFilter_Gray(grayImage, 1.5);
imshow("GrayImgAfterHighBoostFilter", grayImgAfterHighBoostFilter);
imwrite("GrayImgAfterHighBoostFilter.jpg", grayImgAfterHighBoostFilter);

// 彩色图高提升滤波
Mat rgbImgAfterHighBoostFilter = highBoostFilter_RGB(myImage, 1.5);
imshow("RgbImgAfterHighBoostFilter", rgbImgAfterHighBoostFilter);
imwrite("RgbImgAfterHighBoostFilter.jpg", rgbImgAfterHighBoostFilter);

waitKey(0);
return 0;
}

Output

灰图 彩图
GrayImage wallhaven
均值模板 3*3 均值模板 3*3
GrayImgAfterMeanFilter3 RgbImgAfterMeanFilter3
均值模板 5*5 均值模板 5*5
GrayImgAfterMeanFilter5 RgbImgAfterMeanFilter5
均值模板 9*9 均值模板 9*9
GrayImgAfterMeanFilter9 RgbImgAfterMeanFilter9
高斯模板 3*3 高斯模板 3*3
GrayImgAfterGaussianFilter3 RgbImgAfterGaussianFilter3
高斯模板 5*5 *高斯模板 55 **
GrayImgAfterGaussianFilter5 RgbImgAfterGaussianFilter5
高斯模板 9*9 高斯模板 9*9
GrayImgAfterGaussianFilter9 RgbImgAfterGaussianFilter9
Laplacian Laplacian
GrayLaplacianDst RGBLaplacianDst
Robert Robert
GrayRobertDst RGBImgRobertDst
Sobel Sobel
GraySobelDst RGBImgSobelDst
高提升滤波 高提升滤波
GrayImgAfterHighBoostFilter RgbImgAfterHighBoostFilter