Skip to content

Commit 38dd47c

Browse files
committed
Merge pull request #1196 from tucna:fuzzy_documentation
2 parents 27f6d4e + ca6ccac commit 38dd47c

File tree

17 files changed

+373
-60
lines changed

17 files changed

+373
-60
lines changed

modules/fuzzy/doc/fuzzy.bib

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@ @article{Perf:FT
1010
}
1111

1212
@article{Perf:rec,
13-
title={Image Reconstruction by means of F-transform},
13+
title={Image Reconstruction by means of {F}-transform},
1414
author={Perfilieva, Irina and Vla{\v{s}}{\'a}nek, Pavel},
1515
journal={Knowledge-Based Systems},
16-
keywords = {myown},
1716
volume={70},
1817
pages={55--63},
1918
year={2014},
@@ -30,3 +29,50 @@ @article{Vlas:FT
3029
pages={54--62},
3130
year={2016}
3231
}
32+
33+
@article{MSLP:cod-decod,
34+
title={An image coding/decoding method based on direct and inverse fuzzy transforms},
35+
author={Di Martino, Ferdinando and Loia, Vincenzo and Perfilieva, Irina and Sessa, Salvatore},
36+
journal={International Journal of Approximate Reasoning},
37+
volume={48},
38+
number={1},
39+
pages={110--131},
40+
year={2008},
41+
publisher={Elsevier}
42+
}
43+
44+
@article{Fusion:AFS12,
45+
title={Advanced F-transform-based image fusion},
46+
author={Vajgl, Marek and Perfilieva, Irina and Hod'{\'a}kov{\'a}, Petra},
47+
journal={Advances in Fuzzy Systems},
48+
volume={2012},
49+
pages={4},
50+
year={2012},
51+
publisher={Hindawi Publishing Corp.}
52+
}
53+
54+
@incollection{IPMU2012,
55+
title={$F^1$-transform edge detector inspired by canny’s algorithm},
56+
author={Perfilieva, Irina and Hod'{\'a}kov{\'a}, Petra and Hurtík, Petr},
57+
booktitle={Advances on Computational Intelligence},
58+
pages={230--239},
59+
year={2012},
60+
publisher={Springer}
61+
}
62+
63+
@article{perfilieva2014differentiation,
64+
title={Differentiation by the {F}-transform and application to edge detection},
65+
author={Perfilieva, Irina and Hod{\'a}kov{\'a}, Petra and Hurt{\'\i}k, Petr},
66+
journal={Fuzzy Sets and Systems},
67+
year={2014},
68+
publisher={Elsevier}
69+
}
70+
71+
@inproceedings{vlavsanek2015patch,
72+
title={Patch based inpainting method based on the F1-transform},
73+
author={Vla{\v{s}}{\'a}nek, Pavel and Perfilieva, Irina},
74+
booktitle={Soft Computing and Pattern Recognition (SoCPaR), 2015 7th International Conference of},
75+
pages={235--240},
76+
year={2015},
77+
organization={IEEE}
78+
}

modules/fuzzy/include/opencv2/fuzzy.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,16 @@
5050
/**
5151
@defgroup fuzzy Image processing based on fuzzy mathematics
5252
53-
Namespace for all functions is **ft**. The module brings implementation of the last image processing algorithms based on fuzzy mathematics.
53+
Namespace for all functions is `ft`. The module brings implementation of the last image processing algorithms based on fuzzy mathematics. Method are named based on the pattern `FT`_degree_dimension`_`method.
5454
5555
@{
5656
@defgroup f0_math Math with F0-transform support
5757
58-
Fuzzy transform (F0-transform) of the 0th degree transforms whole image to a matrix of its components. These components are used in latter computation where each of them represents average color of certain subarea.
58+
Fuzzy transform (\f$F^0\f$-transform) of the 0th degree transforms whole image to a matrix of its components. These components are used in latter computation where each of them represents average color of certain subarea.
5959
6060
@defgroup f1_math Math with F1-transform support
6161
62-
Fuzzy transform (F1-transform) of the 1th degree transforms whole image to a matrix of its components. Each component is polynomial of the 1th degree carrying information about average color and average gradient of certain subarea.
62+
Fuzzy transform (\f$F^1\f$-transform) of the 1th degree transforms whole image to a matrix of its components. Each component is polynomial of the 1th degree carrying information about average color and average gradient of certain subarea.
6363
6464
@defgroup f_image Fuzzy image processing
6565

modules/fuzzy/include/opencv2/fuzzy/fuzzy_F0_math.hpp

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -53,68 +53,64 @@ namespace ft
5353
//! @addtogroup f0_math
5454
//! @{
5555

56-
/** @brief Computes components of the array using direct F0-transform.
56+
/** @brief Computes components of the array using direct \f$F^0\f$-transform.
5757
@param matrix Input array.
58-
@param kernel Kernel used for processing. Function **createKernel** can be used.
58+
@param kernel Kernel used for processing. Function `ft::createKernel` can be used.
5959
@param components Output 32-bit float array for the components.
6060
@param mask Mask can be used for unwanted area marking.
6161
6262
The function computes components using predefined kernel and mask.
63-
64-
@note
65-
F-transform technique is described in paper @cite Perf:FT.
6663
*/
6764
CV_EXPORTS_W void FT02D_components(InputArray matrix, InputArray kernel, OutputArray components, InputArray mask = noArray());
6865

69-
/** @brief Computes inverse F0-transfrom.
66+
/** @brief Computes inverse \f$F^0\f$-transfrom.
7067
@param components Input 32-bit float single channel array for the components.
71-
@param kernel Kernel used for processing. Function **createKernel** can be used.
68+
@param kernel Kernel used for processing. Function `ft::createKernel` can be used.
7269
@param output Output 32-bit float array.
7370
@param width Width of the output array.
7471
@param height Height of the output array.
7572
76-
@note
77-
F-transform technique is described in paper @cite Perf:FT.
73+
Computation of inverse F-transform.
7874
*/
7975
CV_EXPORTS_W void FT02D_inverseFT(InputArray components, InputArray kernel, OutputArray output, int width, int height);
8076

81-
/** @brief Computes F0-transfrom and inverse F0-transfrom at once.
77+
/** @brief Computes \f$F^0\f$-transfrom and inverse \f$F^0\f$-transfrom at once.
8278
@param matrix Input matrix.
83-
@param kernel Kernel used for processing. Function **createKernel** can be used.
79+
@param kernel Kernel used for processing. Function `ft::createKernel` can be used.
8480
@param output Output 32-bit float array.
8581
@param mask Mask used for unwanted area marking.
8682
87-
This function computes F-transfrom and inverse F-transfotm in one step. It is fully sufficient and optimized for **Mat**.
83+
This function computes F-transfrom and inverse F-transfotm in one step. It is fully sufficient and optimized for `cv::Mat`.
8884
*/
8985
CV_EXPORTS_W void FT02D_process(InputArray matrix, InputArray kernel, OutputArray output, InputArray mask = noArray());
9086

91-
/** @brief Computes F0-transfrom and inverse F0-transfrom at once and return state.
87+
/** @brief Computes \f$F^0\f$-transfrom and inverse \f$F^0\f$-transfrom at once and return state.
9288
@param matrix Input matrix.
93-
@param kernel Kernel used for processing. Function **createKernel** can be used.
89+
@param kernel Kernel used for processing. Function `ft::createKernel` can be used.
9490
@param output Output 32-bit float array.
9591
@param mask Mask used for unwanted area marking.
9692
@param maskOutput Mask after one iteration.
97-
@param firstStop If **true** function returns -1 when first problem appears. In case of **false**, the process is completed and summation of all problems returned.
93+
@param firstStop If **true** function returns -1 when first problem appears. In case of `false` the process is completed and summation of all problems returned.
9894
99-
This function computes iteration of F-transfrom and inverse F-transfotm and handle image and mask change. The function is used in *inpaint* function.
95+
This function computes iteration of F-transfrom and inverse F-transfotm and handle image and mask change. The function is used in `ft::inpaint` function.
10096
*/
10197
CV_EXPORTS_W int FT02D_iteration(InputArray matrix, InputArray kernel, OutputArray output, InputArray mask, OutputArray maskOutput, bool firstStop);
10298

103-
/** @brief Sligtly less accurate version of F0-transfrom computation optimized for higher speed. The methods counts with linear basic function.
99+
/** @brief Sligtly less accurate version of \f$F^0\f$-transfrom computation optimized for higher speed. The methods counts with linear basic function.
104100
@param matrix Input 3 channels matrix.
105-
@param radius Radius of the **LINEAR** basic function.
101+
@param radius Radius of the `ft::LINEAR` basic function.
106102
@param output Output array.
107103
108-
This function computes F-transfrom and inverse F-transfotm using linear basic function in one step. It is ~10 times faster than **FT02D_process** method.
104+
This function computes F-transfrom and inverse F-transfotm using linear basic function in one step. It is ~10 times faster than `ft::FT02D_process` method.
109105
*/
110106
CV_EXPORTS_W void FT02D_FL_process(InputArray matrix, const int radius, OutputArray output);
111107

112-
/** @brief Sligtly less accurate version of F0-transfrom computation optimized for higher speed. The methods counts with linear basic function.
108+
/** @brief Sligtly less accurate version of \f$F^0\f$-transfrom computation optimized for higher speed. The methods counts with linear basic function.
113109
@param matrix Input 3 channels matrix.
114-
@param radius Radius of the **LINEAR** basic function.
110+
@param radius Radius of the `ft::LINEAR` basic function.
115111
@param output Output array.
116112
117-
This function computes F-transfrom and inverse F-transfotm using linear basic function in one step. It is ~9 times faster then **FT02D_process** method and more accurate than **FT02D_FL_process** method.
113+
This function computes F-transfrom and inverse F-transfotm using linear basic function in one step. It is ~9 times faster then `ft::FT02D_process` method and more accurate than `ft::FT02D_FL_process` method.
118114
*/
119115
CV_EXPORTS_W void FT02D_FL_process_float(InputArray matrix, const int radius, OutputArray output);
120116

modules/fuzzy/include/opencv2/fuzzy/fuzzy_F1_math.hpp

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -53,71 +53,67 @@ namespace ft
5353
//! @addtogroup f1_math
5454
//! @{
5555

56-
/** @brief Computes components of the array using direct F1-transform.
56+
/** @brief Computes components of the array using direct \f$F^1\f$-transform.
5757
@param matrix Input array.
58-
@param kernel Kernel used for processing. Function **createKernel** can be used.
58+
@param kernel Kernel used for processing. Function `ft::createKernel` can be used.
5959
@param components Output 32-bit float array for the components.
6060
6161
The function computes linear components using predefined kernel.
62-
63-
@note
64-
F-transform technique of first degreee is described in paper @cite Vlas:FT.
6562
*/
6663
CV_EXPORTS_W void FT12D_components(InputArray matrix, InputArray kernel, OutputArray components);
6764

68-
/** @brief Computes elements of F1-transform components.
65+
/** @brief Computes elements of \f$F^1\f$-transform components.
6966
@param matrix Input array.
70-
@param kernel Kernel used for processing. Function **createKernel** can be used.
67+
@param kernel Kernel used for processing. Function `ft::createKernel` can be used.
7168
@param c00 Elements represent average color.
7269
@param c10 Elements represent average vertical gradient.
7370
@param c01 Elements represent average horizontal gradient.
7471
@param components Output 32-bit float array for the components.
7572
@param mask Mask can be used for unwanted area marking.
7673
7774
The function computes components and its elements using predefined kernel and mask.
78-
79-
@note
80-
F-transform technique of first degreee is described in paper @cite Vlas:FT.
8175
*/
8276
CV_EXPORTS_W void FT12D_polynomial(InputArray matrix, InputArray kernel, OutputArray c00, OutputArray c10, OutputArray c01, OutputArray components, InputArray mask = noArray());
8377

84-
/** @brief Creates vertical matrix for F1-transform computation.
78+
/** @brief Creates vertical matrix for \f$F^1\f$-transform computation.
8579
@param radius Radius of the basic function.
8680
@param matrix The vertical matrix.
8781
@param chn Number of channels.
8882
89-
The function creates helper vertical matrix for F1-transfrom processing. It is used for gradient computation.
83+
The function creates helper vertical matrix for \f$F^1\f$-transfrom processing. It is used for gradient computation.
9084
*/
9185
CV_EXPORTS_W void FT12D_createPolynomMatrixVertical(int radius, OutputArray matrix, const int chn);
9286

93-
/** @brief Creates horizontal matrix for F1-transform computation.
87+
/** @brief Creates horizontal matrix for \f$F^1\f$-transform computation.
9488
@param radius Radius of the basic function.
9589
@param matrix The horizontal matrix.
9690
@param chn Number of channels.
9791
98-
The function creates helper horizontal matrix for F1-transfrom processing. It is used for gradient computation.
92+
The function creates helper horizontal matrix for \f$F^1\f$-transfrom processing. It is used for gradient computation.
9993
*/
10094
CV_EXPORTS_W void FT12D_createPolynomMatrixHorizontal(int radius, OutputArray matrix, const int chn);
10195

102-
/** @brief Computes F1-transfrom and inverse F1-transfrom at once.
96+
/** @brief Computes \f$F^1\f$-transfrom and inverse \f$F^1\f$-transfrom at once.
10397
@param matrix Input matrix.
104-
@param kernel Kernel used for processing. Function **createKernel** can be used.
98+
@param kernel Kernel used for processing. Function `ft::createKernel` can be used.
10599
@param output Output 32-bit float array.
106100
@param mask Mask used for unwanted area marking.
107101
108-
This function computes F1-transfrom and inverse F1-transfotm in one step. It is fully sufficient and optimized for **Mat**.
102+
This function computes \f$F^1\f$-transfrom and inverse \f$F^1\f$-transfotm in one step. It is fully sufficient and optimized for `cv::Mat`.
103+
104+
@note
105+
F-transform technique of first degreee is described in paper @cite Vlas:FT.
109106
*/
110107
CV_EXPORTS_W void FT12D_process(InputArray matrix, InputArray kernel, OutputArray output, InputArray mask = noArray());
111108

112-
/** @brief Computes inverse F1-transfrom.
109+
/** @brief Computes inverse \f$F^1\f$-transfrom.
113110
@param components Input 32-bit float single channel array for the components.
114111
@param kernel Kernel used for processing. The same kernel as for components computation must be used.
115112
@param output Output 32-bit float array.
116113
@param width Width of the output array.
117114
@param height Height of the output array.
118115
119-
@note
120-
F-transform technique of first degreee is described in paper @cite Vlas:FT.
116+
Computation of inverse \f$F^1\f$-transform.
121117
*/
122118
CV_EXPORTS_W void FT12D_inverseFT(InputArray components, InputArray kernel, OutputArray output, int width, int height);
123119

modules/fuzzy/include/opencv2/fuzzy/fuzzy_image.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,11 @@ namespace ft
8080
@param output Output 32-bit image.
8181
@param radius Radius of the basic function.
8282
@param function Function type could be one of the following:
83-
- **LINEAR** Linear basic function.
83+
- `ft::LINEAR` Linear basic function.
8484
@param algorithm Algorithm could be one of the following:
85-
- **ONE_STEP** One step algorithm.
86-
- **MULTI_STEP** Algorithm automaticaly increasing radius of the basic function.
87-
- **ITERATIVE** Iterative algorithm running in more steps using partial computations.
85+
- `ft::ONE_STEP` One step algorithm.
86+
- `ft::MULTI_STEP` This algorithm automaticaly increases radius of the basic function.
87+
- `ft::ITERATIVE` Iterative algorithm running in more steps using partial computations.
8888
8989
This function provides inpainting technique based on the fuzzy mathematic.
9090

modules/fuzzy/include/opencv2/fuzzy/types.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ namespace ft
5252

5353
enum
5454
{
55-
LINEAR = 1,
56-
SINUS = 2
55+
LINEAR = 1, //!< linear (triangular) shape
56+
SINUS = 2 //!< sinusoidal shape
5757
};
5858

5959
enum
6060
{
61-
ONE_STEP = 1,
62-
MULTI_STEP = 2,
63-
ITERATIVE = 3
61+
ONE_STEP = 1, //!< processing in one step
62+
MULTI_STEP = 2, //!< processing in multiple step
63+
ITERATIVE = 3 //!< processing in several iterations
6464
};
6565

6666
//! @}

modules/fuzzy/src/fuzzy_image.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ void ft::createKernel(InputArray A, InputArray B, OutputArray kernel, const int
4747
{
4848
Mat AMat = A.getMat();
4949
Mat BMat = B.getMat();
50-
Mat kernelOneChannel = AMat * BMat;
50+
Mat kernelOneChannel = BMat * AMat;
5151
std::vector<Mat> channels;
5252

5353
for (int i = 0; i < chn; i++)

modules/fuzzy/test/test_image.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,11 @@ TEST(fuzzy_image, kernel)
102102
Mat kernel1;
103103
ft::createKernel(ft::LINEAR, 2, kernel1, 1);
104104

105-
Mat vector1 = (Mat_<float>(5, 1) << 0, 0.5, 1, 0.5, 0);
106-
Mat vector2 = (Mat_<float>(1, 5) << 0, 0.5, 1, 0.5, 0);
105+
Mat vectorA = (Mat_<float>(1, 5) << 0, 0.5, 1, 0.5, 0);
106+
Mat vectorB = (Mat_<float>(5, 1) << 0, 0.5, 1, 0.5, 0);
107107

108108
Mat kernel2;
109-
ft::createKernel(vector1, vector2, kernel2, 1);
109+
ft::createKernel(vectorA, vectorB, kernel2, 1);
110110

111111
double diff = cvtest::norm(kernel1, kernel2, NORM_INF);
112112

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
Filtering using F-transform {#tutorial_fuzzy_filtering}
2+
=============
3+
4+
Goal
5+
====
6+
This tutorial demonstrates to you how to use F-transform for image filtering. You will see:
7+
8+
- basic theory behind,
9+
- illustration of different settings.
10+
11+
Fuzzy transform application
12+
====
13+
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 \f$g\f$ introduced before as well:
14+
15+
\f[
16+
F^0_{kl}=\frac{\sum_{x=0}^{2h+1}\sum_{y=0}^{2h+1} \iota_{kl}(x,y) g(x,y)}{\sum_{x=0}^{2h+1}\sum_{y=0}^{2h+1} g(x,y)},
17+
\f]
18+
19+
where \f$\iota_{kl} \subset I\f$ centered to pixel \f$(k \cdot h,l \cdot h)\f$ and \f$g\f$ is a kernel. More details can be found in related papers.
20+
21+
Code
22+
====
23+
@include fuzzy/samples/fuzzy_filtering.cpp
24+
25+
Explanation
26+
====
27+
Image filtering changes input in a defined way to enhance or simply change some concrete feature. Let me demonstrate some simple blur.
28+
29+
As a first step, we load input image.
30+
31+
@code{.cpp}
32+
// Input image
33+
Mat I = imread("input.png");
34+
@endcode
35+
36+
Following the F-transform formula, we must specify a kernel.
37+
38+
@code{.cpp}
39+
// Kernel cretion
40+
Mat kernel1, kernel2;
41+
42+
ft::createKernel(ft::LINEAR, 3, kernel1, 3);
43+
ft::createKernel(ft::LINEAR, 100, kernel2, 3);
44+
@endcode
45+
46+
> So now, we have two kernels that differ in `radius`. Bigger radius leads to bigger blur.
47+
48+
The filtering itself is applied as shown below.
49+
50+
@code{.cpp}
51+
// Filtering
52+
Mat output1, output2;
53+
54+
ft::filter(I, kernel1, output1);
55+
ft::filter(I, kernel2, output2);
56+
@endcode
57+
58+
Output images look as follows.
59+
60+
![input, output1 (radius 3), output2 (radius 100)](images/fuzzy_filt_output.jpg)
Loading

0 commit comments

Comments
 (0)