Goal
This tutorial demonstrates to you how to use F-transform for image filtering. You will see:
- basic theory behind,
- illustration of different settings.
Fuzzy transform application
As I shown in previous tutorial, F-transform is a tool of fuzzy mathematics highly usable in image processing. Let me rewrite the formula using kernel introduced before as well:
where centered to pixel and is a kernel. More details can be found in related papers.
Code
{
Mat I = imread(
"input.png");
ft::createKernel(ft::LINEAR, 3, kernel1, 3);
ft::createKernel(ft::LINEAR, 100, kernel2, 3);
ft::filter(I, kernel1, output1);
ft::filter(I, kernel2, output2);
imwrite("output1_filter.png", output1);
imwrite("output2_filter.png", output2);
return 0;
}
n-dimensional dense array class
Definition mat.hpp:829
int main(int argc, char *argv[])
Definition highgui_qt.cpp:3
Explanation
Image filtering changes input in a defined way to enhance or simply change some concrete feature. Let me demonstrate some simple blur.
As a first step, we load input image.
Mat I = imread(
"input.png");
Following the F-transform formula, we must specify a kernel.
ft::createKernel(ft::LINEAR, 3, kernel1, 3);
ft::createKernel(ft::LINEAR, 100, kernel2, 3);
So now, we have two kernels that differ in radius
. Bigger radius leads to bigger blur.
The filtering itself is applied as shown below.
ft::filter(I, kernel1, output1);
ft::filter(I, kernel2, output2);
Output images look as follows.
input, output1 (radius 3), output2 (radius 100)