当前位置:网站首页>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 .
边栏推荐
- 力扣每日一题刷题总结:栈与队列篇(持续更新)
- The internal network of the server can be accessed, but the external network cannot be accessed
- MySQL优化
- Get the width and height of the screen in real time (adaptive)
- 解决jetson nano安装onnx错误(ERROR: Failed building wheel for onnx)总结
- 【学习笔记】Matlab自编高斯平滑器+Sobel算子求导
- How gensim freezes some word vectors for incremental training
- 11月24号,我们为“满月”庆祝
- Replace self attention with MLP
- Comparison between setTimeout and requestanimationframe (page refresh)
猜你喜欢

Jetson nano installation tensorflow stepping pit record (scipy1.4.1)

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

Hystrix dashboard cannot find hystrix Stream solution

I'll show you why you don't need to log in every time you use Taobao, jd.com, etc?

用MLP代替掉Self-Attention

乐理基础(简述)

用MLP代替掉Self-Attention

open3d学习笔记四【表面重建】

Nacos service registration in the interface

樂理基礎(簡述)
随机推荐
OpenCV常用方法出处链接(持续更新)
Global and Chinese market of snow sweepers 2022-2028: Research Report on technology, participants, trends, market size and share
A brief analysis of graph pooling
Target detection for long tail distribution -- balanced group softmax
使用Matplotlib绘制图表初步
Vscode下中文乱码问题
Network metering - transport layer
AR system summary harvest
Global and Chinese markets for magnetic resonance imaging (MRI) transmission 2022-2028: Research Report on technology, participants, trends, market size and share
简易打包工具的安装与使用
Global and Chinese market of recovery equipment 2022-2028: Research Report on technology, participants, trends, market size and share
On the back door of deep learning model
Go functions make, slice, append
[learning notes] matlab self compiled Gaussian smoother +sobel operator derivation
包图画法注意规范
AR系统总结收获
Static library and dynamic library
C language implements XML generation and parsing library (XML extension)
STM32疑难杂症之ST-LINK Connection error INVALID ROM TABLE
图像增强的几个方法以及Matlab代码