main.cpp
#include <istream>
#include <opencv2/opencv.hpp>
using namespace cv;
using namespace std;
int main(int argc, char **argv) {
Mat src, blur_dst, gaussian_blur_dst, median_blur_dst, bilateral_dst;
// 加载图片
src = imread("../../picture/bg1.webp", 1);
if (!src.data) {
printf("No image data \n");
return -1;
}
char src_title[] = "src";
namedWindow(src_title, WINDOW_AUTOSIZE);
imshow(src_title, src);
// 均值模糊
char blur_dst_title[] = "blur_dst";
blur(src, blur_dst, Size(9, 9), Point(-1, -1), BORDER_DEFAULT);
namedWindow(blur_dst_title, WINDOW_AUTOSIZE);
imshow(blur_dst_title, blur_dst);
// 高斯模糊
char gaussian_blur_title[] = "gaussian_blur_dst";
GaussianBlur(src, gaussian_blur_dst, Size(9, 9), 11, 11, BORDER_DEFAULT);
namedWindow(gaussian_blur_title, WINDOW_AUTOSIZE);
imshow(gaussian_blur_title, gaussian_blur_dst);
// 中值模糊
char median_blur_title[] = "median_blur_dst";
medianBlur(src, median_blur_dst, 3);
namedWindow(median_blur_title, WINDOW_AUTOSIZE);
imshow(median_blur_title, median_blur_dst);
// 双边模糊
char bilateral_tile[] = "bilateral_dst";
bilateralFilter(src, bilateral_dst, 15, 150, 3, BORDER_DEFAULT);
namedWindow(bilateral_tile, WINDOW_AUTOSIZE);
imshow(bilateral_tile, bilateral_dst);
// 等待按键
waitKey(0);
return 0;
}