标签:sys pac i++ mes template 模板 amp height gui
#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 = 2; j<height - 2; j++) //边缘不处理 { for (int i = 2; i<width - 2; 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++) { 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; }
标签:sys pac i++ mes template 模板 amp height gui
原文地址:http://www.cnblogs.com/goudanli/p/7906715.html