找传奇、传世资源到传世资源站!

图像预处理五种滤波

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

// 图像预处理五种滤波.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include <opencv2/core/core.hpp>#include <opencv2/highgui/highgui.hpp>#include <opencv2/imgproc/imgproc.hpp>#include <iostream>using namespace cv;using namespace std;Mat g_srcImage, g_dstImage1, g_dstImage2, g_dstImage3, g_dstImage4, g_dstImage5;int g_nBoxFilterValue = 6;//方框滤波的内核值int g_nMeanBlurValue = 10;//均值滤波的内核值int g_nGaussianBlurValue = 6;//高斯滤波内核值int g_nMedianBlurBlurValue = 10;//中值滤波参数int g_nBilateralFiterValue = 50;//双边滤波参数值//声明滚动条回调函数static void on_BoxFilter(int, void*);//方框static void on_MeanBulr(int, void*);//均值static void on_GaussianBulr(int, void*);//高斯static void on_MedianBlur(int, void*);//中值static void on_BilateralFiter(int, void*);//双边int main(){g_srcImage = imread("C:/Users/nemo/Desktop/2.jpg");if (!g_srcImage.data){printf("图片载入失败!\n");return -1;}g_dstImage1 = g_srcImage.clone();g_dstImage2 = g_srcImage.clone();g_dstImage3 = g_srcImage.clone();g_dstImage4 = g_srcImage.clone();g_dstImage5 = g_srcImage.clone();//显示原图namedWindow("原图");imshow("原图", g_srcImage);//方框滤波namedWindow("方框滤波");//创建滚动条createTrackbar("内核值:", "方框滤波", &g_nBoxFilterValue, 50, on_BoxFilter);on_BoxFilter(g_nBoxFilterValue, 0);imshow("方框滤波", g_dstImage1);//均值滤波namedWindow("均值滤波");createTrackbar("内核值:", "均值滤波", &g_nMeanBlurValue, 50, on_MeanBulr);on_MeanBulr(g_nMeanBlurValue, 0);imshow("均值滤波", g_dstImage2);//高斯namedWindow("高斯滤波");createTrackbar("内核值:", "高斯滤波", &g_nGaussianBlurValue, 50, on_GaussianBulr);on_GaussianBulr(g_nGaussianBlurValue, 0);imshow("高斯滤波", g_dstImage3);//中值namedWindow("中值滤波");createTrackbar("内核值:", "中值滤波", &g_nMedianBlurBlurValue, 50, on_MedianBlur);on_MedianBlur(g_nMedianBlurBlurValue, 0);imshow("中值滤波", g_dstImage4);//双边namedWindow("双边滤波");createTrackbar("内核值:", "双边滤波", &g_nBilateralFiterValue, 50, on_BilateralFiter);on_BilateralFiter(g_nBilateralFiterValue, 0);imshow("双边滤波", g_dstImage5);waitKey(0);return 0;}//回调函数//方框static void on_BoxFilter(int, void*){//方框滤波操作boxFilter(g_srcImage, g_dstImage1, -1, Size(g_nBoxFilterValue 1, g_nBoxFilterValue 1));//显示imshow("方框滤波", g_dstImage1);}//均值static void on_MeanBulr(int, void*){blur(g_srcImage, g_dstImage2, Size(g_nMeanBlurValue 1, g_nMeanBlurValue 1));imshow("均值滤波", g_dstImage2);}//高斯static void on_GaussianBulr(int, void*){GaussianBlur(g_srcImage, g_dstImage3, Size(g_nGaussianBlurValue * 2 1, g_nGaussianBlurValue * 2 1), 0, 0);//大于1的奇数imshow("高斯滤波", g_dstImage3);}//中值static void on_MedianBlur(int, void*){medianBlur(g_srcImage, g_dstImage4, g_nMedianBlurBlurValue * 2 1);imshow("中值滤波", g_dstImage4);}//双边static void on_BilateralFiter(int, void*){bilateralFilter(g_srcImage, g_dstImage5, g_nBilateralFiterValue, g_nBilateralFiterValue * 2, g_nBilateralFiterValue / 2);imshow("双边滤波", g_dstImage5);}

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复