#include <opencv2\highgui\highgui.hpp>
#include <iostream>
#include<vector> using namespace cv;
using namespace std;
void gaussianFilter2(vector<uchar> corrupted, vector<uchar> &smooth, int width, int height)
{
int templates[25] = { 1, 4, 7, 4, 1,
4, 16, 26, 16, 4,
7, 26, 41, 26, 7,
4, 16, 26, 16, 4,
1, 4, 7, 4, 1 }; //滤波器模板 smooth=corrupted; //复制像素
for (int j = 0; j<height ; j++)
{
for (int i =0; i<width ; i++)
{
int sum = 0;
int index = 0;
for (int m = j - 2; m<j + 3; m++)
{
for (int n = i - 2; n<i + 3; n++)
{if (m<0 || n<0 || m>height - 1 || n>width - 1)continue;  //边缘处理
sum += corrupted[m*width + n] * templates[index++];
}
}
sum /= 273;
if (sum > 255)
sum = 255;
smooth[j*width + i] = sum;
}
}
} int main() { Mat img = imread("123.jpg", 0);
cout << img.rows*img.cols;
// namedWindow("MyWindow");
// imshow("MyWindow", img); vector<uchar> array(img.rows*img.cols);
if (img.isContinuous()) { array.assign(img.datastart, img.dataend); } cout << array.size(); vector<uchar> no(img.rows*img.cols); gaussianFilter2(array, no,img.cols ,img.rows ); Mat now((int)img.rows, (int)img.cols, 0);
for (int i = 0; i < img.rows; i++)
for (int j = 0; j < img.cols; j++)
now.at<uchar>(i, j) = no[i*img.cols + j]; // namedWindow("MyWindow1");
// imshow("MyWindow1", now);
// waitKey(0);
imwrite("1123.jpg", now);
system("pause"); return
0; }

  

最新文章

  1. [转]Android开源项目第二篇——工具库篇
  2. 关于Response.Redirect和Server.Execute的区别
  3. Android中将xml布局文件转化为View树的过程分析(上)
  4. 《head first java 》读书笔记(五)
  5. 自定义View 实现软键盘实现搜索
  6. vbs脚本发送邮件
  7. iOS远程消息推送自我整理版
  8. Entity Framework 4.1 绕过 EF 查询映射
  9. Python定时任务
  10. Arduino语言简介
  11. Java笔试面试题整理第八波
  12. 解决linux下“XX不在 sudoers 文件中。此事将被报告&quot;的问题
  13. Centos 7 安装 Supervisor 及使用
  14. py-faster-rcnn代码阅读3-roidb.py
  15. Creating Reusable XAML User Controls with Xamarin Forms
  16. unity 打包资源及网络请求资源包
  17. vscode 自定义快捷键
  18. c++学习之map基本操作
  19. A Node Influence Based Label Propagation Algorithm for Community detection in networks 文章算法实现的疑问
  20. 配置Ubuntu16.04虚拟机 (用途:CTF_pwn)

热门文章

  1. SDRAM 之时序收敛(学习了特权老师)
  2. Delphi IOS 蓝牙锁屏后台运行
  3. Wcf调用方式
  4. HTML_基础篇
  5. xcode添加build phase
  6. SSH隧道技术简介
  7. cocos2D-x demo 的源码分析 #define ..##.. 的妙用.
  8. ubuntu 16.04 ARM glog移植
  9. PCL点云库中的坐标系(CoordinateSystem)
  10. xml 操作(动态添加 property属性 其他节点同理)