Skip to content

Commit efee450

Browse files
committed
Merge pull request #467 from vpisarev:fuzzy
2 parents 24d9e61 + 156a66d commit efee450

20 files changed

+1162
-0
lines changed

modules/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,5 @@ $ cmake -D OPENCV_EXTRA_MODULES_PATH=<opencv_contrib>/modules -D BUILD_opencv_re
5555
23. **opencv_stereo**: Stereo Correspondence done with different descriptors: Census / CS-Census / MCT / BRIEF / MV.
5656

5757
24. **opencv_hdf**: Hierarchical Data Format I/O.
58+
59+
25. **opencv_fuzzy**: New module focused on the fuzzy image processing.

modules/fuzzy/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
set(the_description "Fuzzy mathematical image processing")
2+
3+
ocv_define_module(fuzzy opencv_imgproc opencv_core)

modules/fuzzy/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
Fuzzy image processing
2+
=======================
3+
4+
Author and maintainer: Pavel Vlasanek
5+
6+
7+
This module is focused on the image processing using fuzzy mathematics, namely fuzzy (F)-transform. The F-transform technique approximates input function, where only few input values are known. The technique of F-transform takes local areas as areas with some additional structure. This structure is characterized by fuzzy predicates that may express any information which is relevant for a problem. In image processing, this can be, for example, a distance from a certain point, a relationship between points, color/intensity, texture, etc.
8+
9+
The F-transform is a technique putting a continuous/discrete function into a correspondence with a finite vector of its F-transform components. In image processing, where images are identified with intensity functions of two arguments, the F-transform of the latter is given by a matrix of components. The module currently covering F0-trasnform, where components are scalars.
10+
11+
The components can be used for inverse F-transform, where approximated input function is obtained. If input function (image) includes some damaged or missing areas, these areas are recomputed and restored after invesre F-transform processing.
12+
13+
Let me give you two related papers:
14+
15+
Perfilieva, Irina, and Pavel Vlašánek. "Image Reconstruction by means of F-transform." Knowledge-Based Systems 70 (2014): 55-63.
16+
17+
Perfilieva, Irina. "Fuzzy transforms: Theory and applications." Fuzzy sets and systems 157.8 (2006): 993-1023.
18+
19+
Investigation of the F-transform technique leads to several applications in image processing. Currently investigated are image inpainting, filtering, resampling, edge detection, compression and image fusion.
20+
21+
The module covers:
22+
23+
* F0 processing (fuzzy_F0_math.cpp): Functions for computation of the image F0 components and inverse F0-transform.
24+
* Fuzzy image processing (fuzzy_image.cpp): Functions aimed to image processing currently including image inpainting and image filtering.
25+
26+
There are also tests in test_image.cpp using resources from opencv_extra, and samples in fuzzy_inpainting.cpp and fuzzy_filtering.cpp.

modules/fuzzy/doc/fuzzy.bib

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
@article{Perf:FT,
2+
title={Fuzzy transforms: Theory and applications},
3+
author={Perfilieva, Irina},
4+
journal={Fuzzy sets and systems},
5+
volume={157},
6+
number={8},
7+
pages={993--1023},
8+
year={2006},
9+
publisher={Elsevier}
10+
}
11+
12+
@article{Perf:rec,
13+
title={Image Reconstruction by means of F-transform},
14+
author={Perfilieva, Irina and Vla{\v{s}}{\'a}nek, Pavel},
15+
journal={Knowledge-Based Systems},
16+
keywords = {myown},
17+
volume={70},
18+
pages={55--63},
19+
year={2014},
20+
doi = {10.1016/j.knosys.2014.04.007},
21+
publisher={Elsevier}
22+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*M///////////////////////////////////////////////////////////////////////////////////////
2+
//
3+
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
4+
//
5+
// By downloading, copying, installing or using the software you agree to this license.
6+
// If you do not agree to this license, do not download, install,
7+
// copy or use the software.
8+
//
9+
//
10+
// License Agreement
11+
// For Open Source Computer Vision Library
12+
//
13+
// Copyright (C) 2015, University of Ostrava, Institute for Research and Applications of Fuzzy Modeling,
14+
// Pavel Vlasanek, all rights reserved. Third party copyrights are property of their respective owners.
15+
//
16+
// Redistribution and use in source and binary forms, with or without modification,
17+
// are permitted provided that the following conditions are met:
18+
//
19+
// * Redistribution's of source code must retain the above copyright notice,
20+
// this list of conditions and the following disclaimer.
21+
//
22+
// * Redistribution's in binary form must reproduce the above copyright notice,
23+
// this list of conditions and the following disclaimer in the documentation
24+
// and/or other materials provided with the distribution.
25+
//
26+
// * The name of the copyright holders may not be used to endorse or promote products
27+
// derived from this software without specific prior written permission.
28+
//
29+
// This software is provided by the copyright holders and contributors "as is" and
30+
// any express or implied warranties, including, but not limited to, the implied
31+
// warranties of merchantability and fitness for a particular purpose are disclaimed.
32+
// In no event shall the Intel Corporation or contributors be liable for any direct,
33+
// indirect, incidental, special, exemplary, or consequential damages
34+
// (including, but not limited to, procurement of substitute goods or services;
35+
// loss of use, data, or profits; or business interruption) however caused
36+
// and on any theory of liability, whether in contract, strict liability,
37+
// or tort (including negligence or otherwise) arising in any way out of
38+
// the use of this software, even if advised of the possibility of such damage.
39+
//
40+
//M*/
41+
42+
#ifndef __OPENCV_FUZZY_H__
43+
#define __OPENCV_FUZZY_H__
44+
45+
#include "opencv2/fuzzy/types.hpp"
46+
#include "opencv2/fuzzy/fuzzy_F0_math.hpp"
47+
#include "opencv2/fuzzy/fuzzy_image.hpp"
48+
49+
/**
50+
@defgroup fuzzy Image processing based on fuzzy mathematics
51+
52+
Namespace for all functions is **ft**. The module brings implementation of the last image processing algorithms based on fuzzy mathematics.
53+
54+
@{
55+
@defgroup f0_math Math with F0-transfrom support
56+
57+
Fuzzy transform (F-transform) of the 0th degree transform whole image to a vector of its components. These components are used in latter computation.
58+
59+
@defgroup f_image Fuzzy image processing
60+
61+
Image proceesing based on F-transform is fast to process and easy to understand.
62+
@}
63+
64+
*/
65+
66+
#endif // __OPENCV_FUZZY_H__
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
/*M///////////////////////////////////////////////////////////////////////////////////////
2+
//
3+
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
4+
//
5+
// By downloading, copying, installing or using the software you agree to this license.
6+
// If you do not agree to this license, do not download, install,
7+
// copy or use the software.
8+
//
9+
//
10+
// License Agreement
11+
// For Open Source Computer Vision Library
12+
//
13+
// Copyright (C) 2015, University of Ostrava, Institute for Research and Applications of Fuzzy Modeling,
14+
// Pavel Vlasanek, all rights reserved. Third party copyrights are property of their respective owners.
15+
//
16+
// Redistribution and use in source and binary forms, with or without modification,
17+
// are permitted provided that the following conditions are met:
18+
//
19+
// * Redistribution's of source code must retain the above copyright notice,
20+
// this list of conditions and the following disclaimer.
21+
//
22+
// * Redistribution's in binary form must reproduce the above copyright notice,
23+
// this list of conditions and the following disclaimer in the documentation
24+
// and/or other materials provided with the distribution.
25+
//
26+
// * The name of the copyright holders may not be used to endorse or promote products
27+
// derived from this software without specific prior written permission.
28+
//
29+
// This software is provided by the copyright holders and contributors "as is" and
30+
// any express or implied warranties, including, but not limited to, the implied
31+
// warranties of merchantability and fitness for a particular purpose are disclaimed.
32+
// In no event shall the Intel Corporation or contributors be liable for any direct,
33+
// indirect, incidental, special, exemplary, or consequential damages
34+
// (including, but not limited to, procurement of substitute goods or services;
35+
// loss of use, data, or profits; or business interruption) however caused
36+
// and on any theory of liability, whether in contract, strict liability,
37+
// or tort (including negligence or otherwise) arising in any way out of
38+
// the use of this software, even if advised of the possibility of such damage.
39+
//
40+
//M*/
41+
42+
#ifndef __OPENCV_FUZZY_F0_MATH_H__
43+
#define __OPENCV_FUZZY_F0_MATH_H__
44+
45+
#include "opencv2/fuzzy/types.hpp"
46+
#include "opencv2/core.hpp"
47+
48+
namespace cv
49+
{
50+
51+
namespace ft
52+
{
53+
//! @addtogroup f0_math
54+
//! @{
55+
56+
/** @brief Computes components of the array using direct F0-transform.
57+
@param matrix Input 1-channel array.
58+
@param kernel Kernel used for processing. Function **createKernel** can be used.
59+
@param components Output 32-bit array for the components.
60+
@param mask Mask can be used for unwanted area marking.
61+
62+
The function computes components using predefined kernel and mask.
63+
64+
@note
65+
F-transform technique is described in paper @cite Perf:FT.
66+
*/
67+
CV_EXPORTS void FT02D_components(InputArray matrix, InputArray kernel, OutputArray components, InputArray mask);
68+
69+
/** @brief Computes components of the array using direct F0-transform.
70+
@param matrix Input 1-channel array.
71+
@param kernel Kernel used for processing. Function **createKernel** can be used.
72+
@param components Output 32-bit array for the components.
73+
74+
The function computes components using predefined kernel.
75+
76+
@note
77+
F-transform technique is described in paper @cite Perf:FT.
78+
*/
79+
CV_EXPORTS void FT02D_components(InputArray matrix, InputArray kernel, OutputArray components);
80+
81+
/** @brief Computes inverse F0-transfrom.
82+
@param components Input 32-bit array for the components.
83+
@param kernel Kernel used for processing. Function **createKernel** can be used.
84+
@param output Output 32-bit array.
85+
@param width Width of the output array.
86+
@param height Height of the output array.
87+
88+
@note
89+
F-transform technique is described in paper @cite Perf:FT.
90+
*/
91+
CV_EXPORTS void FT02D_inverseFT(InputArray components, InputArray kernel, OutputArray output, int width, int height);
92+
93+
/** @brief Computes F0-transfrom and inverse F0-transfrom at once.
94+
@param image Input image.
95+
@param kernel Kernel used for processing. Function **createKernel** can be used.
96+
@param output Output 32-bit array.
97+
@param mask Mask used for unwanted area marking.
98+
99+
This function computes F-transfrom and inverse F-transfotm in one step. It is fully sufficient and optimized for **Mat**.
100+
*/
101+
CV_EXPORTS void FT02D_process(const Mat &image, const Mat &kernel, Mat &output, const Mat &mask);
102+
103+
/** @brief Computes F0-transfrom and inverse F0-transfrom at once and return state.
104+
@param image Input image.
105+
@param kernel Kernel used for processing. Function **createKernel** can be used.
106+
@param imageOutput Output 32-bit array.
107+
@param mask Mask used for unwanted area marking.
108+
@param maskOutput Mask after one iteration.
109+
@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.
110+
111+
This function computes iteration of F-transfrom and inverse F-transfotm and handle image and mask change. The function is used in *inpaint* function.
112+
*/
113+
CV_EXPORTS int FT02D_iteration(const Mat &image, const Mat &kernel, Mat &imageOutput, const Mat &mask, Mat &maskOutput, bool firstStop = true);
114+
115+
//! @}
116+
}
117+
}
118+
119+
#endif // __OPENCV_FUZZY_F0_MATH_H__
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
/*M///////////////////////////////////////////////////////////////////////////////////////
2+
//
3+
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
4+
//
5+
// By downloading, copying, installing or using the software you agree to this license.
6+
// If you do not agree to this license, do not download, install,
7+
// copy or use the software.
8+
//
9+
//
10+
// License Agreement
11+
// For Open Source Computer Vision Library
12+
//
13+
// Copyright (C) 2015, University of Ostrava, Institute for Research and Applications of Fuzzy Modeling,
14+
// Pavel Vlasanek, all rights reserved. Third party copyrights are property of their respective owners.
15+
//
16+
// Redistribution and use in source and binary forms, with or without modification,
17+
// are permitted provided that the following conditions are met:
18+
//
19+
// * Redistribution's of source code must retain the above copyright notice,
20+
// this list of conditions and the following disclaimer.
21+
//
22+
// * Redistribution's in binary form must reproduce the above copyright notice,
23+
// this list of conditions and the following disclaimer in the documentation
24+
// and/or other materials provided with the distribution.
25+
//
26+
// * The name of the copyright holders may not be used to endorse or promote products
27+
// derived from this software without specific prior written permission.
28+
//
29+
// This software is provided by the copyright holders and contributors "as is" and
30+
// any express or implied warranties, including, but not limited to, the implied
31+
// warranties of merchantability and fitness for a particular purpose are disclaimed.
32+
// In no event shall the Intel Corporation or contributors be liable for any direct,
33+
// indirect, incidental, special, exemplary, or consequential damages
34+
// (including, but not limited to, procurement of substitute goods or services;
35+
// loss of use, data, or profits; or business interruption) however caused
36+
// and on any theory of liability, whether in contract, strict liability,
37+
// or tort (including negligence or otherwise) arising in any way out of
38+
// the use of this software, even if advised of the possibility of such damage.
39+
//
40+
//M*/
41+
42+
#ifndef __OPENCV_FUZZY_IMAGE_H__
43+
#define __OPENCV_FUZZY_IMAGE_H__
44+
45+
#include "types.hpp"
46+
#include "opencv2/core.hpp"
47+
48+
namespace cv
49+
{
50+
51+
namespace ft
52+
{
53+
//! @addtogroup f_image
54+
//! @{
55+
56+
/** @brief Creates kernel from basic functions.
57+
@param A Basic function used in axis **x**.
58+
@param B Basic function used in axis **y**.
59+
@param kernel Final 32-b kernel derived from **A** and **B**.
60+
@param chn Number of kernel channels.
61+
62+
The function creates kernel usable for latter fuzzy image processing.
63+
*/
64+
CV_EXPORTS void createKernel(cv::InputArray A, cv::InputArray B, cv::OutputArray kernel, const int chn = 1);
65+
66+
/** @brief Creates kernel from general functions.
67+
@param function Function type could be one of the following:
68+
- **LINEAR** Linear basic function.
69+
@param radius Radius of the basic function.
70+
@param kernel Final 32-b kernel.
71+
@param chn Number of kernel channels.
72+
73+
The function creates kernel from predefined functions.
74+
*/
75+
CV_EXPORTS void createKernel(int function, int radius, cv::OutputArray kernel, const int chn = 1);
76+
77+
/** @brief Image inpainting
78+
@param image Input image.
79+
@param mask Mask used for unwanted area marking.
80+
@param output Output 32-bit image.
81+
@param radius Radius of the basic function.
82+
@param function Function type could be one of the following:
83+
- **LINEAR** Linear basic function.
84+
@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.
88+
89+
This function provides inpainting technique based on the fuzzy mathematic.
90+
91+
@note
92+
The algorithms are described in paper @cite Perf:rec.
93+
*/
94+
CV_EXPORTS void inpaint(const cv::Mat &image, const cv::Mat &mask, cv::Mat &output, int radius = 2, int function = ft::LINEAR, int algorithm = ft::ONE_STEP);
95+
96+
/** @brief Image filtering
97+
@param image Input image.
98+
@param kernel Final 32-b kernel.
99+
@param output Output 32-bit image.
100+
101+
Filtering of the input image by means of F-transform.
102+
*/
103+
CV_EXPORTS void filter(const cv::Mat &image, const cv::Mat &kernel, cv::Mat &output);
104+
105+
//! @}
106+
}
107+
}
108+
109+
#endif // __OPENCV_FUZZY_IMAGE_H__

0 commit comments

Comments
 (0)