当前位置:网站首页>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 .
边栏推荐
猜你喜欢
樂理基礎(簡述)
Open3d learning notes 1 [first glimpse, file reading]
Network metering - transport layer
联邦学习下的数据逆向攻击 -- GradInversion
Open3d learning note 5 [rgbd fusion]
Eklavya -- infer the parameters of functions in binary files using neural network
In the era of short video, how to ensure that works are more popular?
OpenCV3 6.2 低通滤波器的使用
Sequence problem for tqdm and print
【学习笔记】反向误差传播之数值微分
随机推荐
Organigramme des activités
Real world anti sample attack against semantic segmentation
[learning notes] matlab self compiled image convolution function
Open3D学习笔记一【初窥门径,文件读取】
多站点高可用部署
[learning notes] matlab self compiled Gaussian smoother +sobel operator derivation
力扣每日一题刷题总结:字符串篇(持续更新)
Network metering - transport layer
High school mathematics compulsory one
Open3d learning notes 1 [first glimpse, file reading]
Where do you find the materials for those articles that have read 10000?
稀疏矩阵存储
【Batch】learning notes
Sqlyog remote connection to MySQL database under centos7 system
Daily practice (19): print binary tree from top to bottom
浅谈深度学习模型中的后门
Hystrix dashboard cannot find hystrix Stream solution
Prompt 范式简述
服务器的内网可以访问,外网却不能访问的问题
Summary of open3d environment errors