【c++|opencv】三、频率域滤波---3.高斯低通滤波 - C++ - opencv
1. 高斯低通滤波12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061#include<iostream>#include<opencv2/opencv.hpp>#include"mydft.h"#include"Salt.h"using namespace std;using namespace cv;int main(){ Mat img,img_gray,img_out,img_transform; img = imread("/home/v/home.png"); if(img.empty()){ cout<<"can't open the image"<<endl; return -1; } ...
【c++|opencv】三、频率域滤波---2.理想低通滤波 - C++ - opencv
1. 理想低通滤波123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263#include<iostream>#include<opencv2/opencv.hpp>#include"mydft.h"#include"Salt.h"using namespace std;using namespace cv;int main(){ Mat img,img_gray,img_out,img_transform; img = imread("/home/v/home.png"); if (img.empty()){ cout<<"can't open image"<<endl; return -1; ...
【c++|opencv】三、频率域滤波---1.傅里叶变换及频谱图 - C++ - opencv
1. 傅里叶变换和滤波123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778#include <iostream>#include <opencv2/opencv.hpp>#include <cmath>using namespace cv;using namespace std;// 定义 傅里叶变换函数void mydft(Mat img_input,Mat& out_img,Mat& transform_arr);int main(){ Mat img,img_gray,img_out,img_transform; img = imread("/home/v/home.png"); if (img.empty()){ co ...
【c++|opencv】二、灰度变换和空间滤波---6.锐化空间滤波
1. 锐化空间滤波123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960#include <iostream>#include <opencv2/opencv.hpp>using namespace std;using namespace cv;// 定义滤波函数void myfilter(Mat& img_input,Mat& img_output); // 四邻域void myfilter2(Mat& img_input,Mat& img_output); // 八邻域int main(){ Mat img,img_gray,imt_output,img_output2; img = imread("/home/v/home.png"); if (img.empty()){ cout< ...
【c++|opencv】二、灰度变换和空间滤波---5.中值滤波
1. 中值滤波1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374#include<iostream>#include<opencv2/opencv.hpp>#include"Salt.h"using namespace cv;using namespace std;void myfilter(int filter_size,Mat& img_input,Mat& img_output);int mysort(Mat& sortarray,int filter_size);int main(){ Mat img,img_gray,img_output,img_output2; img = imread("/home/v/home.png"); if ...
【c++|opencv】二、灰度变换和空间滤波---4.高斯滤波
1. 高斯滤波123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960#include <iostream>#include <opencv2/opencv.hpp>#include"Salt.h"using namespace std;using namespace cv;// 定义高斯滤波函数void myfilter(int filter_size,Mat& img_input,Mat& img_output);int main(){ Mat img,img_gray,img_out,img_out2; img = imread("/home/v/home.png"); if (img.empty()){ cout<<"can't open the ima ...
【c++|opencv】二、灰度变换和空间滤波---3.均值滤波
1. 均值滤波12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455#include <iostream>#include <opencv2/opencv.hpp>#include"Salt.h"using namespace cv;using namespace std;// 定义盒式滤波器void myfilter(int filter_size,Mat& img_input,Mat& img_output);int main(){ Mat img,img_gray,img_output,img_output2; img = imread("/home/v/home.png"); if (img.empty()){ cout<<"can not load image"< ...
【c++|opencv】二、灰度变换和空间滤波---2.直方图
1. 图像直方图1234567891011121314151617181920212223242526272829303132333435363738394041#include <iostream>#include <opencv2/opencv.hpp>using namespace cv;using namespace std;int main(){ Mat img, img_gray,hist; img = imread("/home/v/home.png"); if (img.empty()){ cout << "Could not open or find the image" << endl; return -1; } cvtColor(img, img_gray, COLOR_BGR2GRAY); imshow("img gray",img_gray); // 获取 ...
【c++|opencv】二、灰度变换和空间滤波---1.灰度变换
1. 灰度变换1234567891011121314151617181920212223242526272829303132#include <iostream>#include <opencv2/opencv.hpp>using namespace std;using namespace cv;int main() { Mat img,out_img,img_gray; img = imread("/home/v/home.png"); if (img.empty()){ cout << "Could not open or find the image" << endl; return -1; } cvtColor(img, img_gray, COLOR_BGR2GRAY); imshow("img gray",img_gray); out_img = img_gr ...
【c++|opencv】一、基础操作---4.访问图像像素
1. 访问图像像素1.1 访问某像素123456//灰度图像:image.at<uchar>(j, i) //j为行数,i为列数//BGR彩色图像image.at<Vec3b>(j, i)[0] //B分量image.at<Vec3b>(j, i)[1] //G分量image.at<Vec3b>(j, i)[2] //R分量
1.2 遍历像素以添加噪声为例
1.2.1 准备创建添加噪声函数
Salt.h
123456789#pragma once#include <iostream>#include <opencv2/opencv.hpp>#include <random>using namespace cv;using namespace std;void Salt(Mat img,int n); // n加入噪声点数
Salt.cpp
1234567891011121314151617181920212223#include "Salt.h"void Salt(Mat img, ...
