当前位置:网站首页>Use of opencv3 6.2 low pass filter
Use of opencv3 6.2 low pass filter
2022-07-02 08:08:00 【Villanelle#】
frequency domain 、 The concept of frequency
The method of observing the frequency of the change of image intensity value is called frequency domain , The method of observing gray distribution to describe image features is called airspace .
Areas in the image where the gray intensity changes slowly Low frequency , And the area with fast change of intensity value produces High frequency , The frequency is divided into Vertical frequency ( Changes in the vertical direction ) and Horizontal frequency ( Changes in the horizontal direction ).
It can be used The Fourier transform or cosine transform And other methods to display the frequency components of the image .
filter
Filtering is to selectively extract certain aspects of the image , You can enlarge some frequency bands in the image , At the same time, filter out operators of other frequency bands .
Filters can be divided into low pass filter and High pass filter , This section mainly introduces Block filter (box filter) and Gauss filter (gaussian filter).
Block filter
Block filter cv::blur You can replace the value of each function with the pixel neighborhood ( rectangular ) Average value .
The block filter uses the weighted accumulated value of the neighborhood pixels to replace the pixel value , So this filter is linear Of , And the block filter is a Mean filter , Because this example uses 5*5 The kernel of , Its kernel can be written as :
| 1/25 | 1/25 | 1/25 | 1/25 | 1/25 |
|---|---|---|---|---|
| 1/25 | 1/25 | 1/25 | 1/25 | 1/25 |
| 1/25 | 1/25 | 1/25 | 1/25 | 1/25 |
| 1/25 | 1/25 | 1/25 | 1/25 | 1/25 |
| 1/25 | 1/25 | 1/25 | 1/25 | 1/25 |
Use a linear filter to move the kernel to the image On every pixel of , And multiply the corresponding pixel by the weight , Mathematically, it is called Convolution .
Gauss filter
Gauss filter cv::GaussianBlur It is also a linear filter , But unlike block filters , The weight of the Gaussian filter pixel is proportional to the distance from it to the central pixel , Normal distribution function . The formula of one-dimensional Gaussian function is :
Parameters σ Determine the shape of Gaussian function curve ,σ The bigger it is , The flatter the function curve , That is, the smaller the weight of surrounding pixels ;σ The smaller it is , The steeper the function curve , That is, the greater the weight of surrounding pixels .
To create an image ( A two-dimensional space ) Apply two-dimensional Gaussian filter , Just apply a one-dimensional Gaussian filter on the horizontal line ( Filter the frequency in the horizontal direction ), Then apply one-dimensional Gaussian filter on the longitudinal line ( Filter the frequency in the vertical direction ). The principle is that Gaussian filter is a Separable filter , It can be divided into two one-dimensional filters .
Concrete realization
cv::Mat image = cv::imread("boldt.jpg");
cv::Mat boxblur, gaussianblur;
cv::blur(image, // Original image
boxblur, // The image filtered by the block filter
cv::Size(5, 5)); // The size is 5*5 Filter for
cv::GaussianBlur(image, // Original image
gaussianblur, // The image after Gaussian filtering
cv::Size(5, 5), // The size is 5*5 Filter for
1.5, // Parameters controlling the shape of Gaussian curve sigmaX,sigmaX The bigger it is , The smaller the proportion of nearby pixels
0); // Parameters controlling the shape of Gaussian curve sigmaY, If specified as 0 Or do not specify the default and sigmaX identical
cv::imshow("image", image);
cv::imshow("boxblur", boxblur);
cv::imshow("gaussianblur", gaussianblur);
Effect display



cv::blur Use of functions
Function signature
CV_EXPORTS_W void blur( InputArray src, OutputArray dst,
Size ksize, Point anchor = Point(-1,-1),
int borderType = BORDER_DEFAULT );
The parameters are : The input image , Output image , Filter size , Starting point ( The default is the middle point of the rectangle ), Type of boundary ( General default ).
cv::GaussianBlur Use of functions
Function signature
CV_EXPORTS_W void GaussianBlur( InputArray src, OutputArray dst, Size ksize,
double sigmaX, double sigmaY = 0,
int borderType = BORDER_DEFAULT );
The parameters are : The input image , Output image , Filter size ,x Direction σ Parameters sigmaX,y Direction σ Parameters sigmaY, Type of boundary ( General default ).
notes : If only fill in sigmaX( perhaps sigmaY Set to 0) It's fine too , Will default to sigmaY be equal to sigmaX. If sigmaX and sigmaY All set to 0, The function will determine the most suitable size by itself σ value .
边栏推荐
- 【C#笔记】winform中保存DataGridView中的数据为Excel和CSV
- Principes fondamentaux de la théorie musicale (brève introduction)
- Meta Learning 简述
- AR system summary harvest
- Summary of open3d environment errors
- [C # note] the data in DataGridView saved in WinForm is excel and CSV
- Vscode下中文乱码问题
- Graph Pooling 简析
- STL速查手册
- Carla-UE4Editor导入RoadRunner地图文件(保姆级教程)
猜你喜欢

Real world anti sample attack against semantic segmentation

服务器的内网可以访问,外网却不能访问的问题

11月24号,我们为“满月”庆祝

open3d学习笔记五【RGBD融合】

用MLP代替掉Self-Attention

Using super ball embedding to enhance confrontation training

【MagNet】《Progressive Semantic Segmentation》

A brief analysis of graph pooling

Correction binoculaire

On the confrontation samples and their generation methods in deep learning
随机推荐
Global and Chinese market of recovery equipment 2022-2028: Research Report on technology, participants, trends, market size and share
用于类别增量学习的动态可扩展表征 -- DER
业务架构图
深入理解JVM
【MagNet】《Progressive Semantic Segmentation》
力扣方法总结:双指针
Global and Chinese market of snow sweepers 2022-2028: Research Report on technology, participants, trends, market size and share
C # connect to MySQL database
Static library and dynamic library
用MLP代替掉Self-Attention
[learning notes] matlab self compiled Gaussian smoother +sobel operator derivation
Graph Pooling 简析
利用超球嵌入来增强对抗训练
E-R draw clear content
Cvpr19 deep stacked hierarchical multi patch network for image deblurring paper reproduction
[binocular vision] binocular stereo matching
業務架構圖
C language implements XML generation and parsing library (XML extension)
High school mathematics compulsory one
How gensim freezes some word vectors for incremental training