opencv实现图像邻域均值滤波、中值滤波、高斯滤波

  1. void CCVMFCView::OnBlurSmooth()//邻域均值滤波
  2. {
  3. IplImage* in;
  4. in = workImg;
  5. IplImage* out = cvCreateImage(cvGetSize(in),IPL_DEPTH_8U,workImg->nChannels);
  6. cvSmooth(in,out,CV_BLUR,3,workImg->nChannels); // 简单平均
  7. m_dibFlag=imageReplace(out,&workImg);
  8. Invalidate();
  9. }

[cpp] view plain copy print ?
  1. void CCVMFCView::OnMedianSmooth()
  2. {
  3. IplImage* in = workImg;
  4. IplImage* out = cvCreateImage(cvGetSize(in),
  5. IPL_DEPTH_8U,workImg->nChannels);
  6. cvSmooth(in,out,CV_MEDIAN,3,workImg->nChannels); // 中值滤波
  7. m_dibFlag=imageReplace(out,&workImg);
  8. Invalidate();
  9. }

[cpp] view plain copy print ?
  1. void CCVMFCView::OnGaussSmooth()
  2. {
  3. IplImage* in = workImg;
  4. IplImage* out = cvCreateImage(cvGetSize(in),IPL_DEPTH_8U,workImg->nChannels); // 建立辅助位图
  5. cvSmooth(in,out,CV_GAUSSIAN,3,workImg->nChannels); // Gauss 平滑
  6. m_dibFlag=imageReplace(out,&workImg); // 输出处理结果
  7. Invalidate();
  8. }

你可能感兴趣的:(opencv实现图像邻域均值滤波、中值滤波、高斯滤波)