![]() |
OpenCV
Open Source Computer Vision
|
Prev Tutorial: Thresholding Operations using inRange
Next Tutorial: Adding borders to your images
Original author | Ana Huamán |
Compatibility | OpenCV >= 3.0 |
In this tutorial you will learn how to:
In a very general sense, correlation is an operation between every part of an image and an operator (kernel).
A kernel is essentially a fixed size array of numerical coefficients along with an anchor point in that array, which is typically located at the center.
Assume you want to know the resulting value of a particular location in the image. The value of the correlation is calculated in the following way:
Expressing the procedure above in the form of an equation we would have:
Fortunately, OpenCV provides you with the function filter2D() so you do not have to code all these operations.
Performs a normalized box filter. For instance, for a kernel of size
The program will perform the filter operation with kernels of sizes 3, 5, 7, 9 and 11.
The tutorial code's is shown in the lines below.
You can also download it from here
Perform an infinite loop updating the kernel size and applying our linear filter to the input image. Let's analyze that more in detail:
The first line is to update the kernel_size to odd values in the range: