vendor: OpenCV 5.0.0 snapshot at 755e50675d97db9b7d449d8bd6b09888646f6c6e
@@ -0,0 +1,3 @@
|
||||
set(the_description "Fuzzy mathematical image processing")
|
||||
|
||||
ocv_define_module(fuzzy opencv_imgproc opencv_core WRAP python)
|
||||
@@ -0,0 +1,26 @@
|
||||
Fuzzy image processing
|
||||
=======================
|
||||
|
||||
Author and maintainer: Pavel Vlasanek
|
||||
pavel.vlasanek@osu.cz
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
Let me give you two related papers:
|
||||
|
||||
Perfilieva, Irina, and Pavel Vlašánek. "Image Reconstruction by means of F-transform." Knowledge-Based Systems 70 (2014): 55-63.
|
||||
|
||||
Perfilieva, Irina. "Fuzzy transforms: Theory and applications." Fuzzy sets and systems 157.8 (2006): 993-1023.
|
||||
|
||||
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.
|
||||
|
||||
The module covers:
|
||||
|
||||
* F0 processing (fuzzy_F0_math.cpp): Functions for computation of the image F0 components and inverse F0-transform.
|
||||
* Fuzzy image processing (fuzzy_image.cpp): Functions aimed to image processing currently including image inpainting and image filtering.
|
||||
|
||||
There are also tests in test_image.cpp using resources from opencv_extra, and samples in fuzzy_inpainting.cpp and fuzzy_filtering.cpp.
|
||||
@@ -0,0 +1,78 @@
|
||||
@article{Perf:FT,
|
||||
title={Fuzzy transforms: Theory and applications},
|
||||
author={Perfilieva, Irina},
|
||||
journal={Fuzzy sets and systems},
|
||||
volume={157},
|
||||
number={8},
|
||||
pages={993--1023},
|
||||
year={2006},
|
||||
publisher={Elsevier}
|
||||
}
|
||||
|
||||
@article{Perf:rec,
|
||||
title={Image Reconstruction by means of {F}-transform},
|
||||
author={Perfilieva, Irina and Vla{\v{s}}{\'a}nek, Pavel},
|
||||
journal={Knowledge-Based Systems},
|
||||
volume={70},
|
||||
pages={55--63},
|
||||
year={2014},
|
||||
doi = {10.1016/j.knosys.2014.04.007},
|
||||
publisher={Elsevier}
|
||||
}
|
||||
|
||||
@article{Vlas:FT,
|
||||
title={The F-transform in Terms of Image Processing Tools},
|
||||
author={Vla{\v{s}}{\'a}nek, Pavel and Perfilieva, Irina},
|
||||
journal={Journal of Fuzzy Set Valued Analysis},
|
||||
volume={2016},
|
||||
number={1},
|
||||
pages={54--62},
|
||||
year={2016}
|
||||
}
|
||||
|
||||
@article{MSLP:cod-decod,
|
||||
title={An image coding/decoding method based on direct and inverse fuzzy transforms},
|
||||
author={Di Martino, Ferdinando and Loia, Vincenzo and Perfilieva, Irina and Sessa, Salvatore},
|
||||
journal={International Journal of Approximate Reasoning},
|
||||
volume={48},
|
||||
number={1},
|
||||
pages={110--131},
|
||||
year={2008},
|
||||
publisher={Elsevier}
|
||||
}
|
||||
|
||||
@article{Fusion:AFS12,
|
||||
title={Advanced F-transform-based image fusion},
|
||||
author={Vajgl, Marek and Perfilieva, Irina and Hod'{\'a}kov{\'a}, Petra},
|
||||
journal={Advances in Fuzzy Systems},
|
||||
volume={2012},
|
||||
pages={4},
|
||||
year={2012},
|
||||
publisher={Hindawi Publishing Corp.}
|
||||
}
|
||||
|
||||
@incollection{IPMU2012,
|
||||
title={$F^1$-transform edge detector inspired by canny's algorithm},
|
||||
author={Perfilieva, Irina and Hod'{\'a}kov{\'a}, Petra and Hurtík, Petr},
|
||||
booktitle={Advances on Computational Intelligence},
|
||||
pages={230--239},
|
||||
year={2012},
|
||||
publisher={Springer}
|
||||
}
|
||||
|
||||
@article{perfilieva2014differentiation,
|
||||
title={Differentiation by the {F}-transform and application to edge detection},
|
||||
author={Perfilieva, Irina and Hod{\'a}kov{\'a}, Petra and Hurt{\'\i}k, Petr},
|
||||
journal={Fuzzy Sets and Systems},
|
||||
year={2014},
|
||||
publisher={Elsevier}
|
||||
}
|
||||
|
||||
@inproceedings{vlavsanek2015patch,
|
||||
title={Patch based inpainting method based on the F1-transform},
|
||||
author={Vla{\v{s}}{\'a}nek, Pavel and Perfilieva, Irina},
|
||||
booktitle={Soft Computing and Pattern Recognition (SoCPaR), 2015 7th International Conference of},
|
||||
pages={235--240},
|
||||
year={2015},
|
||||
organization={IEEE}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2015, University of Ostrava, Institute for Research and Applications of Fuzzy Modeling,
|
||||
// Pavel Vlasanek, all rights reserved. Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_FUZZY_H__
|
||||
#define __OPENCV_FUZZY_H__
|
||||
|
||||
#include "opencv2/fuzzy/types.hpp"
|
||||
#include "opencv2/fuzzy/fuzzy_F0_math.hpp"
|
||||
#include "opencv2/fuzzy/fuzzy_F1_math.hpp"
|
||||
#include "opencv2/fuzzy/fuzzy_image.hpp"
|
||||
|
||||
/**
|
||||
@defgroup fuzzy Image processing based on fuzzy mathematics
|
||||
|
||||
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.
|
||||
|
||||
@{
|
||||
@defgroup f0_math Math with F0-transform support
|
||||
|
||||
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.
|
||||
|
||||
@defgroup f1_math Math with F1-transform support
|
||||
|
||||
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.
|
||||
|
||||
@defgroup f_image Fuzzy image processing
|
||||
|
||||
Image proceesing based on fuzzy mathematics namely F-transform.
|
||||
@}
|
||||
|
||||
*/
|
||||
|
||||
#endif // __OPENCV_FUZZY_H__
|
||||
@@ -0,0 +1,121 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2015, University of Ostrava, Institute for Research and Applications of Fuzzy Modeling,
|
||||
// Pavel Vlasanek, all rights reserved. Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_FUZZY_F0_MATH_H__
|
||||
#define __OPENCV_FUZZY_F0_MATH_H__
|
||||
|
||||
#include "opencv2/fuzzy/types.hpp"
|
||||
#include "opencv2/core.hpp"
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
namespace ft
|
||||
{
|
||||
//! @addtogroup f0_math
|
||||
//! @{
|
||||
|
||||
/** @brief Computes components of the array using direct \f$F^0\f$-transform.
|
||||
@param matrix Input array.
|
||||
@param kernel Kernel used for processing. Function `ft::createKernel` can be used.
|
||||
@param components Output 32-bit float array for the components.
|
||||
@param mask Mask can be used for unwanted area marking.
|
||||
|
||||
The function computes components using predefined kernel and mask.
|
||||
*/
|
||||
CV_EXPORTS_W void FT02D_components(InputArray matrix, InputArray kernel, OutputArray components, InputArray mask = noArray());
|
||||
|
||||
/** @brief Computes inverse \f$F^0\f$-transfrom.
|
||||
@param components Input 32-bit float single channel array for the components.
|
||||
@param kernel Kernel used for processing. Function `ft::createKernel` can be used.
|
||||
@param output Output 32-bit float array.
|
||||
@param width Width of the output array.
|
||||
@param height Height of the output array.
|
||||
|
||||
Computation of inverse F-transform.
|
||||
*/
|
||||
CV_EXPORTS_W void FT02D_inverseFT(InputArray components, InputArray kernel, OutputArray output, int width, int height);
|
||||
|
||||
/** @brief Computes \f$F^0\f$-transfrom and inverse \f$F^0\f$-transfrom at once.
|
||||
@param matrix Input matrix.
|
||||
@param kernel Kernel used for processing. Function `ft::createKernel` can be used.
|
||||
@param output Output 32-bit float array.
|
||||
@param mask Mask used for unwanted area marking.
|
||||
|
||||
This function computes F-transfrom and inverse F-transfotm in one step. It is fully sufficient and optimized for `cv::Mat`.
|
||||
*/
|
||||
CV_EXPORTS_W void FT02D_process(InputArray matrix, InputArray kernel, OutputArray output, InputArray mask = noArray());
|
||||
|
||||
/** @brief Computes \f$F^0\f$-transfrom and inverse \f$F^0\f$-transfrom at once and return state.
|
||||
@param matrix Input matrix.
|
||||
@param kernel Kernel used for processing. Function `ft::createKernel` can be used.
|
||||
@param output Output 32-bit float array.
|
||||
@param mask Mask used for unwanted area marking.
|
||||
@param maskOutput Mask after one iteration.
|
||||
@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.
|
||||
|
||||
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.
|
||||
*/
|
||||
CV_EXPORTS_W int FT02D_iteration(InputArray matrix, InputArray kernel, OutputArray output, InputArray mask, OutputArray maskOutput, bool firstStop);
|
||||
|
||||
/** @brief Sligtly less accurate version of \f$F^0\f$-transfrom computation optimized for higher speed. The methods counts with linear basic function.
|
||||
@param matrix Input 3 channels matrix.
|
||||
@param radius Radius of the `ft::LINEAR` basic function.
|
||||
@param output Output array.
|
||||
|
||||
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.
|
||||
*/
|
||||
CV_EXPORTS_W void FT02D_FL_process(InputArray matrix, const int radius, OutputArray output);
|
||||
|
||||
/** @brief Sligtly less accurate version of \f$F^0\f$-transfrom computation optimized for higher speed. The methods counts with linear basic function.
|
||||
@param matrix Input 3 channels matrix.
|
||||
@param radius Radius of the `ft::LINEAR` basic function.
|
||||
@param output Output array.
|
||||
|
||||
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.
|
||||
*/
|
||||
CV_EXPORTS_W void FT02D_FL_process_float(InputArray matrix, const int radius, OutputArray output);
|
||||
|
||||
//! @}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // __OPENCV_FUZZY_F0_MATH_H__
|
||||
@@ -0,0 +1,124 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2015, University of Ostrava, Institute for Research and Applications of Fuzzy Modeling,
|
||||
// Pavel Vlasanek, all rights reserved. Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_FUZZY_F1_MATH_H__
|
||||
#define __OPENCV_FUZZY_F1_MATH_H__
|
||||
|
||||
#include "opencv2/fuzzy/types.hpp"
|
||||
#include "opencv2/core.hpp"
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
namespace ft
|
||||
{
|
||||
//! @addtogroup f1_math
|
||||
//! @{
|
||||
|
||||
/** @brief Computes components of the array using direct \f$F^1\f$-transform.
|
||||
@param matrix Input array.
|
||||
@param kernel Kernel used for processing. Function `ft::createKernel` can be used.
|
||||
@param components Output 32-bit float array for the components.
|
||||
|
||||
The function computes linear components using predefined kernel.
|
||||
*/
|
||||
CV_EXPORTS_W void FT12D_components(InputArray matrix, InputArray kernel, OutputArray components);
|
||||
|
||||
/** @brief Computes elements of \f$F^1\f$-transform components.
|
||||
@param matrix Input array.
|
||||
@param kernel Kernel used for processing. Function `ft::createKernel` can be used.
|
||||
@param c00 Elements represent average color.
|
||||
@param c10 Elements represent average vertical gradient.
|
||||
@param c01 Elements represent average horizontal gradient.
|
||||
@param components Output 32-bit float array for the components.
|
||||
@param mask Mask can be used for unwanted area marking.
|
||||
|
||||
The function computes components and its elements using predefined kernel and mask.
|
||||
*/
|
||||
CV_EXPORTS_W void FT12D_polynomial(InputArray matrix, InputArray kernel, OutputArray c00, OutputArray c10, OutputArray c01, OutputArray components, InputArray mask = noArray());
|
||||
|
||||
/** @brief Creates vertical matrix for \f$F^1\f$-transform computation.
|
||||
@param radius Radius of the basic function.
|
||||
@param matrix The vertical matrix.
|
||||
@param chn Number of channels.
|
||||
|
||||
The function creates helper vertical matrix for \f$F^1\f$-transfrom processing. It is used for gradient computation.
|
||||
*/
|
||||
CV_EXPORTS_W void FT12D_createPolynomMatrixVertical(int radius, OutputArray matrix, const int chn);
|
||||
|
||||
/** @brief Creates horizontal matrix for \f$F^1\f$-transform computation.
|
||||
@param radius Radius of the basic function.
|
||||
@param matrix The horizontal matrix.
|
||||
@param chn Number of channels.
|
||||
|
||||
The function creates helper horizontal matrix for \f$F^1\f$-transfrom processing. It is used for gradient computation.
|
||||
*/
|
||||
CV_EXPORTS_W void FT12D_createPolynomMatrixHorizontal(int radius, OutputArray matrix, const int chn);
|
||||
|
||||
/** @brief Computes \f$F^1\f$-transfrom and inverse \f$F^1\f$-transfrom at once.
|
||||
@param matrix Input matrix.
|
||||
@param kernel Kernel used for processing. Function `ft::createKernel` can be used.
|
||||
@param output Output 32-bit float array.
|
||||
@param mask Mask used for unwanted area marking.
|
||||
|
||||
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`.
|
||||
|
||||
@note
|
||||
F-transform technique of first degreee is described in paper @cite Vlas:FT.
|
||||
*/
|
||||
CV_EXPORTS_W void FT12D_process(InputArray matrix, InputArray kernel, OutputArray output, InputArray mask = noArray());
|
||||
|
||||
/** @brief Computes inverse \f$F^1\f$-transfrom.
|
||||
@param components Input 32-bit float single channel array for the components.
|
||||
@param kernel Kernel used for processing. The same kernel as for components computation must be used.
|
||||
@param output Output 32-bit float array.
|
||||
@param width Width of the output array.
|
||||
@param height Height of the output array.
|
||||
|
||||
Computation of inverse \f$F^1\f$-transform.
|
||||
*/
|
||||
CV_EXPORTS_W void FT12D_inverseFT(InputArray components, InputArray kernel, OutputArray output, int width, int height);
|
||||
|
||||
//! @}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // __OPENCV_FUZZY_F1_MATH_H__
|
||||
@@ -0,0 +1,109 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2015, University of Ostrava, Institute for Research and Applications of Fuzzy Modeling,
|
||||
// Pavel Vlasanek, all rights reserved. Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_FUZZY_IMAGE_H__
|
||||
#define __OPENCV_FUZZY_IMAGE_H__
|
||||
|
||||
#include "types.hpp"
|
||||
#include "opencv2/core.hpp"
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
namespace ft
|
||||
{
|
||||
//! @addtogroup f_image
|
||||
//! @{
|
||||
|
||||
/** @brief Creates kernel from basic functions.
|
||||
@param A Basic function used in axis **x**.
|
||||
@param B Basic function used in axis **y**.
|
||||
@param kernel Final 32-bit kernel derived from **A** and **B**.
|
||||
@param chn Number of kernel channels.
|
||||
|
||||
The function creates kernel usable for latter fuzzy image processing.
|
||||
*/
|
||||
CV_EXPORTS_AS(createKernel1) void createKernel(InputArray A, InputArray B, OutputArray kernel, const int chn);
|
||||
|
||||
/** @brief Creates kernel from general functions.
|
||||
@param function Function type could be one of the following:
|
||||
- **LINEAR** Linear basic function.
|
||||
@param radius Radius of the basic function.
|
||||
@param kernel Final 32-bit kernel.
|
||||
@param chn Number of kernel channels.
|
||||
|
||||
The function creates kernel from predefined functions.
|
||||
*/
|
||||
CV_EXPORTS_W void createKernel(int function, int radius, OutputArray kernel, const int chn);
|
||||
|
||||
/** @brief Image inpainting
|
||||
@param image Input image.
|
||||
@param mask Mask used for unwanted area marking.
|
||||
@param output Output 32-bit image.
|
||||
@param radius Radius of the basic function.
|
||||
@param function Function type could be one of the following:
|
||||
- `ft::LINEAR` Linear basic function.
|
||||
@param algorithm Algorithm could be one of the following:
|
||||
- `ft::ONE_STEP` One step algorithm.
|
||||
- `ft::MULTI_STEP` This algorithm automaticaly increases radius of the basic function.
|
||||
- `ft::ITERATIVE` Iterative algorithm running in more steps using partial computations.
|
||||
|
||||
This function provides inpainting technique based on the fuzzy mathematic.
|
||||
|
||||
@note
|
||||
The algorithms are described in paper @cite Perf:rec.
|
||||
*/
|
||||
CV_EXPORTS_W void inpaint(InputArray image, InputArray mask, OutputArray output, int radius, int function, int algorithm);
|
||||
|
||||
/** @brief Image filtering
|
||||
@param image Input image.
|
||||
@param kernel Final 32-bit kernel.
|
||||
@param output Output 32-bit image.
|
||||
|
||||
Filtering of the input image by means of F-transform.
|
||||
*/
|
||||
CV_EXPORTS_W void filter(InputArray image, InputArray kernel, OutputArray output);
|
||||
|
||||
//! @}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // __OPENCV_FUZZY_IMAGE_H__
|
||||
@@ -0,0 +1,70 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2015, University of Ostrava, Institute for Research and Applications of Fuzzy Modeling,
|
||||
// Pavel Vlasanek, all rights reserved. Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_FUZZY_TYPES_H__
|
||||
#define __OPENCV_FUZZY_TYPES_H__
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
namespace ft
|
||||
{
|
||||
//! @addtogroup fuzzy
|
||||
//! @{
|
||||
|
||||
enum
|
||||
{
|
||||
LINEAR = 1, //!< linear (triangular) shape
|
||||
SINUS = 2 //!< sinusoidal shape
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
ONE_STEP = 1, //!< processing in one step
|
||||
MULTI_STEP = 2, //!< processing in multiple step
|
||||
ITERATIVE = 3 //!< processing in several iterations
|
||||
};
|
||||
|
||||
//! @}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // __OPENCV_FUZZY_TYPES_H__
|
||||
@@ -0,0 +1,47 @@
|
||||
/* Sample - Filtering
|
||||
* Target is to apply filtering using F-transform
|
||||
* on the image "input.png". Two different kernels
|
||||
* are used, where bigger radius (100 in this case)
|
||||
* means higher level of blurriness.
|
||||
*
|
||||
* Image "output1_filter.png" is created from "input.png"
|
||||
* using "kernel1" with radius 3.
|
||||
*
|
||||
* Image "output2_filter.png" is created from "input.png"
|
||||
* using "kernel2" with radius 100.
|
||||
*
|
||||
* Both kernels are created from linear function, using
|
||||
* linear interpolation (parameter ft:LINEAR).
|
||||
*/
|
||||
|
||||
#include "opencv2/core.hpp"
|
||||
#include "opencv2/highgui.hpp"
|
||||
#include "opencv2/fuzzy.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace cv;
|
||||
|
||||
int main(void)
|
||||
{
|
||||
// Input image
|
||||
Mat I = imread("input.png");
|
||||
|
||||
// Kernel creation
|
||||
Mat kernel1, kernel2;
|
||||
|
||||
ft::createKernel(ft::LINEAR, 3, kernel1, 3);
|
||||
ft::createKernel(ft::LINEAR, 100, kernel2, 3);
|
||||
|
||||
// Filtering
|
||||
Mat output1, output2;
|
||||
|
||||
ft::filter(I, kernel1, output1);
|
||||
ft::filter(I, kernel2, output2);
|
||||
|
||||
// Save output
|
||||
|
||||
imwrite("output1_filter.png", output1);
|
||||
imwrite("output2_filter.png", output2);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
/* Sample - Inpainting
|
||||
* Target is to apply inpainting using F-transform
|
||||
* on the image "input.png". The image is damaged
|
||||
* by various types of corruption:
|
||||
*
|
||||
* input1 = image & mask1
|
||||
* input2 = image & mask2
|
||||
* input3 = image & mask3
|
||||
*
|
||||
* Three algorithms "ft::ONE_STEP", "ft::MULTI_STEP"
|
||||
* and "ft::ITERATIVE" are demonstrated on the
|
||||
* appropriate type of damage.
|
||||
*
|
||||
* ft::ONE_STEP
|
||||
* "output1_inpaint.png": input1, mask1
|
||||
*
|
||||
* ft::MULTI_STEP
|
||||
* "output2_inpaint.png": input2, mask2
|
||||
* "output3_inpaint.png": input3, mask3
|
||||
*
|
||||
* ft::ITERATIVE
|
||||
* "output4_inpaint.png": input3, mask3
|
||||
*
|
||||
* Linear kernel with radius 2 is used for all
|
||||
* samples.
|
||||
*/
|
||||
|
||||
#include "opencv2/core.hpp"
|
||||
#include "opencv2/highgui.hpp"
|
||||
#include "opencv2/fuzzy.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace cv;
|
||||
|
||||
int main(void)
|
||||
{
|
||||
// Input image
|
||||
Mat I = imread("input.png");
|
||||
|
||||
// Various masks
|
||||
Mat mask1 = imread("mask1.png", IMREAD_GRAYSCALE);
|
||||
Mat mask2 = imread("mask2.png", IMREAD_GRAYSCALE);
|
||||
Mat mask3 = imread("mask3.png", IMREAD_GRAYSCALE);
|
||||
|
||||
// Apply the damage
|
||||
Mat input1, input2, input3;
|
||||
|
||||
I.copyTo(input1, mask1);
|
||||
I.copyTo(input2, mask2);
|
||||
I.copyTo(input3, mask3);
|
||||
|
||||
// Inpaint with various algorithm
|
||||
Mat output1, output2, output3, output4;
|
||||
|
||||
ft::inpaint(input1, mask1, output1, 2, ft::LINEAR, ft::ONE_STEP);
|
||||
ft::inpaint(input2, mask2, output2, 2, ft::LINEAR, ft::MULTI_STEP);
|
||||
ft::inpaint(input3, mask3, output3, 2, ft::LINEAR, ft::MULTI_STEP);
|
||||
ft::inpaint(input3, mask3, output4, 2, ft::LINEAR, ft::ITERATIVE);
|
||||
|
||||
// Save output
|
||||
imwrite("output1_inpaint.png", output1);
|
||||
imwrite("output2_inpaint.png", output2);
|
||||
imwrite("output3_inpaint.png", output3);
|
||||
imwrite("output4_inpaint.png", output4);
|
||||
|
||||
// Save damaged input for comparison
|
||||
imwrite("input1.png", input1);
|
||||
imwrite("input2.png", input2);
|
||||
imwrite("input3.png", input3);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
After Width: | Height: | Size: 399 KiB |
|
After Width: | Height: | Size: 5.6 KiB |
|
After Width: | Height: | Size: 2.4 KiB |
|
After Width: | Height: | Size: 3.0 KiB |
@@ -0,0 +1,548 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2015, University of Ostrava, Institute for Research and Applications of Fuzzy Modeling,
|
||||
// Pavel Vlasanek, all rights reserved. Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
using namespace cv;
|
||||
|
||||
void ft::FT02D_FL_process(InputArray matrix, const int radius, OutputArray output)
|
||||
{
|
||||
CV_Assert(matrix.channels() == 3);
|
||||
|
||||
int borderPadding = 2 * radius + 1;
|
||||
Mat imagePadded;
|
||||
|
||||
copyMakeBorder(matrix, imagePadded, radius, borderPadding, radius, borderPadding, BORDER_CONSTANT, Scalar(0));
|
||||
|
||||
Mat channel[3];
|
||||
split(imagePadded, channel);
|
||||
|
||||
uchar *im_r = channel[2].data;
|
||||
uchar *im_g = channel[1].data;
|
||||
uchar *im_b = channel[0].data;
|
||||
|
||||
int width = imagePadded.cols;
|
||||
int height = imagePadded.rows;
|
||||
int n_width = width / radius + 1;
|
||||
int n_height = height / radius + 1;
|
||||
|
||||
std::vector<uchar> c_r(n_width * n_height);
|
||||
std::vector<uchar> c_g(n_width * n_height);
|
||||
std::vector<uchar> c_b(n_width * n_height);
|
||||
|
||||
int sum_r, sum_g, sum_b, num, c_wei;
|
||||
int c_pos, pos, pos2, wy;
|
||||
int cy = 0;
|
||||
float num_f;
|
||||
|
||||
std::vector<int> wei(radius + 1);
|
||||
|
||||
for (int i = 0; i <= radius; i++)
|
||||
{
|
||||
wei[i] = radius - i;
|
||||
}
|
||||
|
||||
for (int y = radius; y < height - radius; y += radius)
|
||||
{
|
||||
c_pos = cy;
|
||||
|
||||
for (int x = radius; x < width - radius; x += radius)
|
||||
{
|
||||
num = sum_r = sum_g = sum_b = 0;
|
||||
|
||||
for (int y1 = y - radius; y1 <= y + radius; y1++)
|
||||
{
|
||||
pos = y1 * width;
|
||||
wy = wei[abs(y1 - y)];
|
||||
|
||||
for (int x1 = x - radius; x1 <= x + radius; x1++)
|
||||
{
|
||||
c_wei = wei[abs(x1 - x)] * wy;
|
||||
pos2 = pos + x1;
|
||||
sum_r += im_r[pos2] * c_wei;
|
||||
sum_g += im_g[pos2] * c_wei;
|
||||
sum_b += im_b[pos2] * c_wei;
|
||||
num += c_wei;
|
||||
}
|
||||
}
|
||||
|
||||
num_f = 1.0f / (float)num;
|
||||
|
||||
c_r[c_pos] = (uchar)cvRound(sum_r * num_f);
|
||||
c_g[c_pos] = (uchar)cvRound(sum_g * num_f);
|
||||
c_b[c_pos] = (uchar)cvRound(sum_b * num_f);
|
||||
|
||||
c_pos++;
|
||||
}
|
||||
|
||||
cy += n_width;
|
||||
}
|
||||
|
||||
int p1, p2, p3, p4, yw, w1, w2, w3, w4, lx, ly, lx1, ly1, pos_iFT;
|
||||
float num_iFT;
|
||||
|
||||
int output_height = matrix.rows();
|
||||
int output_width = matrix.cols();
|
||||
|
||||
Mat compR(output_height, output_width, CV_8UC1);
|
||||
Mat compG(output_height, output_width, CV_8UC1);
|
||||
Mat compB(output_height, output_width, CV_8UC1);
|
||||
|
||||
uchar *img_r = compR.ptr();
|
||||
uchar *img_g = compG.ptr();
|
||||
uchar *img_b = compB.ptr();
|
||||
|
||||
for (int y = 0; y < output_height; y++)
|
||||
{
|
||||
ly1 = (y % radius);
|
||||
ly = radius - ly1;
|
||||
yw = y / radius * n_width;
|
||||
pos_iFT = y * output_width;
|
||||
|
||||
for (int x = 0; x < output_width; x++)
|
||||
{
|
||||
lx1 = (x % radius);
|
||||
lx = radius - lx1;
|
||||
|
||||
p1 = x / radius + yw;
|
||||
p2 = p1 + 1;
|
||||
p3 = p1 + n_width;
|
||||
p4 = p3 + 1;
|
||||
|
||||
w1 = lx * ly;
|
||||
w2 = lx1 * ly;
|
||||
w3 = lx * ly1;
|
||||
w4 = lx1 * ly1;
|
||||
|
||||
num_iFT = 1.0f / (float)(w1 + w2 + w3 + w4);
|
||||
|
||||
img_r[pos_iFT] = (uchar)((c_r[p1] * w1 + c_r[p2] * w2 + c_r[p3] * w3 + c_r[p4] * w4) * num_iFT);
|
||||
img_g[pos_iFT] = (uchar)((c_g[p1] * w1 + c_g[p2] * w2 + c_g[p3] * w3 + c_g[p4] * w4) * num_iFT);
|
||||
img_b[pos_iFT] = (uchar)((c_b[p1] * w1 + c_b[p2] * w2 + c_b[p3] * w3 + c_b[p4] * w4) * num_iFT);
|
||||
|
||||
pos_iFT++;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<Mat> oComp;
|
||||
|
||||
oComp.push_back(compB);
|
||||
oComp.push_back(compG);
|
||||
oComp.push_back(compR);
|
||||
|
||||
merge(oComp, output);
|
||||
}
|
||||
|
||||
void ft::FT02D_FL_process_float(InputArray matrix, const int radius, OutputArray output)
|
||||
{
|
||||
CV_Assert(matrix.channels() == 3);
|
||||
|
||||
int borderPadding = 2 * radius + 1;
|
||||
Mat imagePadded;
|
||||
|
||||
copyMakeBorder(matrix, imagePadded, radius, borderPadding, radius, borderPadding, BORDER_CONSTANT, Scalar(0));
|
||||
|
||||
Mat channel[3];
|
||||
split(imagePadded, channel);
|
||||
|
||||
uchar *im_r = channel[2].data;
|
||||
uchar *im_g = channel[1].data;
|
||||
uchar *im_b = channel[0].data;
|
||||
|
||||
int width = imagePadded.cols;
|
||||
int height = imagePadded.rows;
|
||||
int n_width = width / radius + 1;
|
||||
int n_height = height / radius + 1;
|
||||
|
||||
std::vector<float> c_r(n_width * n_height);
|
||||
std::vector<float> c_g(n_width * n_height);
|
||||
std::vector<float> c_b(n_width * n_height);
|
||||
|
||||
int sum_r, sum_g, sum_b, num, c_wei;
|
||||
int c_pos, pos, pos2, wy;
|
||||
int cy = 0;
|
||||
float num_f;
|
||||
|
||||
std::vector<int> wei(radius + 1);
|
||||
|
||||
for (int i = 0; i <= radius; i++)
|
||||
{
|
||||
wei[i] = radius - i;
|
||||
}
|
||||
|
||||
for (int y = radius; y < height - radius; y += radius)
|
||||
{
|
||||
c_pos = cy;
|
||||
|
||||
for (int x = radius; x < width - radius; x += radius)
|
||||
{
|
||||
num = sum_r = sum_g = sum_b = 0;
|
||||
|
||||
for (int y1 = y - radius; y1 <= y + radius; y1++)
|
||||
{
|
||||
pos = y1 * width;
|
||||
wy = wei[abs(y1 - y)];
|
||||
|
||||
for (int x1 = x - radius; x1 <= x + radius; x1++)
|
||||
{
|
||||
c_wei = wei[abs(x1 - x)] * wy;
|
||||
pos2 = pos + x1;
|
||||
sum_r += im_r[pos2] * c_wei;
|
||||
sum_g += im_g[pos2] * c_wei;
|
||||
sum_b += im_b[pos2] * c_wei;
|
||||
num += c_wei;
|
||||
}
|
||||
}
|
||||
|
||||
num_f = 1.0f / (float)num;
|
||||
|
||||
c_r[c_pos] = sum_r * num_f;
|
||||
c_g[c_pos] = sum_g * num_f;
|
||||
c_b[c_pos] = sum_b * num_f;
|
||||
|
||||
c_pos++;
|
||||
}
|
||||
|
||||
cy += n_width;
|
||||
}
|
||||
|
||||
int p1, p2, p3, p4, yw, w1, w2, w3, w4, lx, ly, lx1, ly1, pos_iFT;
|
||||
float num_iFT;
|
||||
|
||||
int output_height = matrix.rows();
|
||||
int output_width = matrix.cols();
|
||||
|
||||
Mat compR(output_height, output_width, CV_32FC1);
|
||||
Mat compG(output_height, output_width, CV_32FC1);
|
||||
Mat compB(output_height, output_width, CV_32FC1);
|
||||
|
||||
float *img_r = compR.ptr<float>();
|
||||
float *img_g = compG.ptr<float>();
|
||||
float *img_b = compB.ptr<float>();
|
||||
|
||||
for (int y = 0; y < output_height; y++)
|
||||
{
|
||||
ly1 = (y % radius);
|
||||
ly = radius - ly1;
|
||||
yw = y / radius * n_width;
|
||||
pos_iFT = y * output_width;
|
||||
|
||||
for (int x = 0; x < output_width; x++)
|
||||
{
|
||||
lx1 = (x % radius);
|
||||
lx = radius - lx1;
|
||||
|
||||
p1 = x / radius + yw;
|
||||
p2 = p1 + 1;
|
||||
p3 = p1 + n_width;
|
||||
p4 = p3 + 1;
|
||||
|
||||
w1 = lx * ly;
|
||||
w2 = lx1 * ly;
|
||||
w3 = lx * ly1;
|
||||
w4 = lx1 * ly1;
|
||||
|
||||
num_iFT = 1.0f / (float)(w1 + w2 + w3 + w4);
|
||||
|
||||
img_r[pos_iFT] = (c_r[p1] * w1 + c_r[p2] * w2 + c_r[p3] * w3 + c_r[p4] * w4) * num_iFT;
|
||||
img_g[pos_iFT] = (c_g[p1] * w1 + c_g[p2] * w2 + c_g[p3] * w3 + c_g[p4] * w4) * num_iFT;
|
||||
img_b[pos_iFT] = (c_b[p1] * w1 + c_b[p2] * w2 + c_b[p3] * w3 + c_b[p4] * w4) * num_iFT;
|
||||
|
||||
pos_iFT++;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<Mat> oComp;
|
||||
|
||||
oComp.push_back(compB);
|
||||
oComp.push_back(compG);
|
||||
oComp.push_back(compR);
|
||||
|
||||
merge(oComp, output);
|
||||
}
|
||||
|
||||
void ft::FT02D_components(InputArray matrix, InputArray kernel, OutputArray components, InputArray mask)
|
||||
{
|
||||
CV_Assert(matrix.channels() == kernel.channels());
|
||||
|
||||
Mat inputMask;
|
||||
|
||||
if (mask.getMat().empty())
|
||||
{
|
||||
inputMask = Mat::ones(matrix.size(), CV_8U);
|
||||
}
|
||||
else
|
||||
{
|
||||
CV_Assert(mask.channels() == 1);
|
||||
|
||||
inputMask = mask.getMat();
|
||||
}
|
||||
|
||||
int radiusX = (kernel.cols() - 1) / 2;
|
||||
int radiusY = (kernel.rows() - 1) / 2;
|
||||
int An = matrix.cols() / radiusX + 1;
|
||||
int Bn = matrix.rows() / radiusY + 1;
|
||||
|
||||
Mat matrixPadded;
|
||||
Mat maskPadded;
|
||||
|
||||
copyMakeBorder(matrix, matrixPadded, radiusY, kernel.rows(), radiusX, kernel.cols(), BORDER_CONSTANT, Scalar(0));
|
||||
copyMakeBorder(inputMask, maskPadded, radiusY, kernel.rows(), radiusX, kernel.cols(), BORDER_CONSTANT, Scalar(0));
|
||||
|
||||
components.create(Bn, An, CV_MAKETYPE(CV_32F, matrix.channels()));
|
||||
|
||||
Mat componentsMat = components.getMat();
|
||||
|
||||
for (int i = 0; i < An; i++)
|
||||
{
|
||||
for (int o = 0; o < Bn; o++)
|
||||
{
|
||||
int centerX = (i * radiusX) + radiusX;
|
||||
int centerY = (o * radiusY) + radiusY;
|
||||
Rect area(centerX - radiusX, centerY - radiusY, kernel.cols(), kernel.rows());
|
||||
|
||||
Mat roiImage(matrixPadded, area);
|
||||
Mat roiMask(maskPadded, area);
|
||||
Mat kernelMasked;
|
||||
|
||||
kernel.copyTo(kernelMasked, roiMask);
|
||||
|
||||
Mat numerator;
|
||||
multiply(roiImage, kernelMasked, numerator, 1, CV_32F);
|
||||
|
||||
Scalar value;
|
||||
divide(sum(numerator), sum(kernelMasked), value, 1, CV_32F);
|
||||
|
||||
componentsMat.row(o).col(i).setTo(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ft::FT02D_inverseFT(InputArray components, InputArray kernel, OutputArray output, int width, int height)
|
||||
{
|
||||
CV_Assert(components.channels() == 1 && kernel.channels() == 1);
|
||||
|
||||
Mat componentsMat = components.getMat();
|
||||
|
||||
int radiusX = (kernel.cols() - 1) / 2;
|
||||
int radiusY = (kernel.rows() - 1) / 2;
|
||||
int outputWidthPadded = radiusX + width + kernel.cols();
|
||||
int outputHeightPadded = radiusY + height + kernel.rows();
|
||||
|
||||
output.create(height, width, CV_32F);
|
||||
|
||||
Mat outputZeroes(outputHeightPadded, outputWidthPadded, CV_32F, Scalar(0));
|
||||
|
||||
for (int i = 0; i < componentsMat.cols; i++)
|
||||
{
|
||||
for (int o = 0; o < componentsMat.rows; o++)
|
||||
{
|
||||
int centerX = (i * radiusX) + radiusX;
|
||||
int centerY = (o * radiusY) + radiusY;
|
||||
Rect area(centerX - radiusX, centerY - radiusY, kernel.cols(), kernel.rows());
|
||||
|
||||
float component = componentsMat.at<float>(o, i);
|
||||
|
||||
Mat inverse;
|
||||
multiply(kernel, component, inverse, 1, CV_32F);
|
||||
|
||||
Mat roiOutput(outputZeroes, area);
|
||||
add(roiOutput, inverse, roiOutput);
|
||||
}
|
||||
}
|
||||
|
||||
outputZeroes(Rect(radiusX, radiusY, width, height)).copyTo(output);
|
||||
}
|
||||
|
||||
void ft::FT02D_process(InputArray matrix, InputArray kernel, OutputArray output, InputArray mask)
|
||||
{
|
||||
CV_Assert(matrix.channels() == kernel.channels());
|
||||
|
||||
Mat inputMask;
|
||||
|
||||
if (mask.getMat().empty())
|
||||
{
|
||||
inputMask = Mat::ones(matrix.size(), CV_8U);
|
||||
}
|
||||
else
|
||||
{
|
||||
CV_Assert(mask.channels() == 1);
|
||||
|
||||
inputMask = mask.getMat();
|
||||
}
|
||||
|
||||
int radiusX = (kernel.cols() - 1) / 2;
|
||||
int radiusY = (kernel.rows() - 1) / 2;
|
||||
int An = matrix.cols() / radiusX + 1;
|
||||
int Bn = matrix.rows() / radiusY + 1;
|
||||
int outputWidthPadded = radiusX + matrix.cols() + kernel.cols();
|
||||
int outputHeightPadded = radiusY + matrix.rows() + kernel.rows();
|
||||
|
||||
Mat matrixPadded;
|
||||
Mat maskPadded;
|
||||
|
||||
output.create(matrix.size(), CV_MAKETYPE(CV_32F, matrix.channels()));
|
||||
|
||||
Mat outputZeroes(outputHeightPadded, outputWidthPadded, output.type(), Scalar(0));
|
||||
|
||||
copyMakeBorder(matrix, matrixPadded, radiusY, kernel.rows(), radiusX, kernel.cols(), BORDER_CONSTANT, Scalar(0));
|
||||
copyMakeBorder(inputMask, maskPadded, radiusY, kernel.rows(), radiusX, kernel.cols(), BORDER_CONSTANT, Scalar(0));
|
||||
|
||||
for (int i = 0; i < An; i++)
|
||||
{
|
||||
for (int o = 0; o < Bn; o++)
|
||||
{
|
||||
int centerX = (i * radiusX) + radiusX;
|
||||
int centerY = (o * radiusY) + radiusY;
|
||||
Rect area(centerX - radiusX, centerY - radiusY, kernel.cols(), kernel.rows());
|
||||
|
||||
Mat roiMatrix(matrixPadded, area);
|
||||
Mat roiMask(maskPadded, area);
|
||||
Mat kernelMasked;
|
||||
|
||||
kernel.copyTo(kernelMasked, roiMask);
|
||||
|
||||
Mat numerator;
|
||||
multiply(roiMatrix, kernelMasked, numerator, 1, CV_32F);
|
||||
|
||||
Scalar component;
|
||||
divide(sum(numerator), sum(kernelMasked), component, 1, CV_32F);
|
||||
|
||||
Mat inverse;
|
||||
multiply(kernel, component, inverse, 1, CV_32F);
|
||||
|
||||
Mat roiOutput(outputZeroes, area);
|
||||
add(roiOutput, inverse, roiOutput);
|
||||
}
|
||||
}
|
||||
|
||||
outputZeroes(Rect(radiusX, radiusY, matrix.cols(), matrix.rows())).copyTo(output);
|
||||
}
|
||||
|
||||
int ft::FT02D_iteration(InputArray matrix, InputArray kernel, OutputArray output, InputArray mask, OutputArray maskOutput, bool firstStop)
|
||||
{
|
||||
CV_Assert(matrix.channels() == kernel.channels() && mask.channels() == 1);
|
||||
|
||||
int radiusX = (kernel.cols() - 1) / 2;
|
||||
int radiusY = (kernel.rows() - 1) / 2;
|
||||
int An = matrix.cols() / radiusX + 1;
|
||||
int Bn = matrix.rows() / radiusY + 1;
|
||||
int outputWidthPadded = radiusX + matrix.cols() + kernel.cols();
|
||||
int outputHeightPadded = radiusY + matrix.rows() + kernel.rows();
|
||||
int undefinedComponents = 0;
|
||||
|
||||
output.create(matrix.size(), CV_MAKETYPE(CV_32F, matrix.channels()));
|
||||
output.setTo(0);
|
||||
|
||||
if (maskOutput.needed())
|
||||
{
|
||||
maskOutput.create(mask.rows(), mask.cols(), CV_8UC1);
|
||||
maskOutput.setTo(1);
|
||||
}
|
||||
|
||||
Mat matrixOutputMat = Mat::zeros(outputHeightPadded, outputWidthPadded, CV_MAKETYPE(CV_32F, matrix.channels()));
|
||||
Mat maskOutputMat = Mat::ones(outputHeightPadded, outputWidthPadded, CV_8UC1);
|
||||
|
||||
Mat matrixPadded;
|
||||
Mat maskPadded;
|
||||
|
||||
copyMakeBorder(matrix, matrixPadded, radiusY, kernel.rows(), radiusX, kernel.cols(), BORDER_CONSTANT, Scalar(0));
|
||||
copyMakeBorder(mask, maskPadded, radiusY, kernel.rows(), radiusX, kernel.cols(), BORDER_CONSTANT, Scalar(0));
|
||||
|
||||
for (int i = 0; i < An; i++)
|
||||
{
|
||||
for (int o = 0; o < Bn; o++)
|
||||
{
|
||||
int centerX = (i * radiusX) + radiusX;
|
||||
int centerY = (o * radiusY) + radiusY;
|
||||
Rect area(centerX - radiusX, centerY - radiusY, kernel.cols(), kernel.rows());
|
||||
|
||||
Mat roiMatrix(matrixPadded, area);
|
||||
Mat roiMask(maskPadded, area);
|
||||
Mat kernelMasked;
|
||||
|
||||
kernel.copyTo(kernelMasked, roiMask);
|
||||
|
||||
Mat numerator;
|
||||
multiply(roiMatrix, kernelMasked, numerator, 1, CV_32F);
|
||||
|
||||
Scalar denominator = sum(kernelMasked);
|
||||
|
||||
if (denominator[0] == 0)
|
||||
{
|
||||
if (firstStop)
|
||||
{
|
||||
matrixOutputMat = matrixPadded(Rect(radiusX, radiusY, matrix.cols(), matrix.rows()));
|
||||
maskOutputMat = maskPadded(Rect(radiusX, radiusY, matrix.cols(), matrix.rows()));
|
||||
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
undefinedComponents++;
|
||||
|
||||
Mat roiMaskOutput(maskOutputMat, Rect(centerX - radiusX + 1, centerY - radiusY + 1, kernel.cols() - 2, kernel.rows() - 2));
|
||||
roiMaskOutput.setTo(0);
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
Scalar component;
|
||||
divide(sum(numerator), denominator, component, 1, CV_32F);
|
||||
|
||||
Mat inverse;
|
||||
multiply(kernel, component, inverse, 1, CV_32F);
|
||||
|
||||
Mat roiMatrixOutput(matrixOutputMat, area);
|
||||
add(roiMatrixOutput, inverse, roiMatrixOutput);
|
||||
}
|
||||
}
|
||||
|
||||
matrixOutputMat(Rect(radiusX, radiusY, matrix.cols(), matrix.rows())).copyTo(output);
|
||||
|
||||
if (maskOutput.needed())
|
||||
{
|
||||
maskOutputMat(Rect(radiusX, radiusY, matrix.cols(), matrix.rows())).copyTo(maskOutput);
|
||||
}
|
||||
|
||||
return undefinedComponents;
|
||||
}
|
||||
@@ -0,0 +1,305 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2015, University of Ostrava, Institute for Research and Applications of Fuzzy Modeling,
|
||||
// Pavel Vlasanek, all rights reserved. Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
using namespace cv;
|
||||
|
||||
void ft::FT12D_components(InputArray matrix, InputArray kernel, OutputArray components)
|
||||
{
|
||||
Mat c00, c10, c01;
|
||||
|
||||
FT12D_polynomial(matrix, kernel, c00, c10, c01, components);
|
||||
}
|
||||
|
||||
void ft::FT12D_polynomial(InputArray matrix, InputArray kernel, OutputArray c00, OutputArray c10, OutputArray c01, OutputArray components, InputArray mask)
|
||||
{
|
||||
CV_Assert(matrix.channels() == 1 && kernel.channels() == 1);
|
||||
|
||||
Mat inputMask;
|
||||
|
||||
if (mask.getMat().empty())
|
||||
{
|
||||
inputMask = Mat::ones(matrix.size(), CV_8U);
|
||||
}
|
||||
else
|
||||
{
|
||||
CV_Assert(mask.channels() == 1);
|
||||
|
||||
inputMask = mask.getMat();
|
||||
}
|
||||
|
||||
int radiusX = (kernel.cols() - 1) / 2;
|
||||
int radiusY = (kernel.rows() - 1) / 2;
|
||||
int An = matrix.cols() / radiusX + 1;
|
||||
int Bn = matrix.rows() / radiusY + 1;
|
||||
|
||||
Mat matrixPadded, maskPadded;
|
||||
copyMakeBorder(matrix, matrixPadded, radiusY, kernel.rows(), radiusX, kernel.cols(), BORDER_ISOLATED, Scalar(0));
|
||||
copyMakeBorder(inputMask, maskPadded, radiusY, kernel.rows(), radiusX, kernel.cols(), BORDER_ISOLATED, Scalar(0));
|
||||
|
||||
c00.create(Bn, An, CV_32F);
|
||||
c10.create(Bn, An, CV_32F);
|
||||
c01.create(Bn, An, CV_32F);
|
||||
components.create(Bn * kernel.rows(), An * kernel.cols(), CV_32F);
|
||||
|
||||
Mat c00Mat = c00.getMat();
|
||||
Mat c10Mat = c10.getMat();
|
||||
Mat c01Mat = c01.getMat();
|
||||
Mat componentsMat = components.getMat();
|
||||
|
||||
Mat vecX, vecY;
|
||||
FT12D_createPolynomMatrixVertical(radiusX, vecX, 1);
|
||||
FT12D_createPolynomMatrixHorizontal(radiusY, vecY, 1);
|
||||
|
||||
for (int i = 0; i < An; i++)
|
||||
{
|
||||
for (int o = 0; o < Bn; o++)
|
||||
{
|
||||
int centerX = (i * radiusX) + radiusX;
|
||||
int centerY = (o * radiusY) + radiusY;
|
||||
Rect area(centerX - radiusX, centerY - radiusY, kernel.cols(), kernel.rows());
|
||||
|
||||
Mat roiImage(matrixPadded, area);
|
||||
Mat roiMask(maskPadded, area);
|
||||
|
||||
Mat kernelMasked;
|
||||
kernel.copyTo(kernelMasked, roiMask);
|
||||
|
||||
Mat numerator00, numerator10, numerator01;
|
||||
multiply(roiImage, kernelMasked, numerator00, 1, CV_32F);
|
||||
multiply(numerator00, vecX, numerator10, 1, CV_32F);
|
||||
multiply(numerator00, vecY, numerator01, 1, CV_32F);
|
||||
|
||||
Mat denominator00, denominator10, denominator01;
|
||||
denominator00 = kernelMasked;
|
||||
multiply(vecX.mul(vecX), kernelMasked, denominator10, 1, CV_32F);
|
||||
multiply(vecY.mul(vecY), kernelMasked, denominator01, 1, CV_32F);
|
||||
|
||||
Scalar c00sum, c10sum, c01sum;
|
||||
divide(sum(numerator00), sum(denominator00), c00sum, 1, CV_32F);
|
||||
divide(sum(numerator10), sum(denominator10), c10sum, 1, CV_32F);
|
||||
divide(sum(numerator01), sum(denominator01), c01sum, 1, CV_32F);
|
||||
|
||||
c00Mat.row(o).col(i) = c00sum;
|
||||
c10Mat.row(o).col(i) = c10sum;
|
||||
c01Mat.row(o).col(i) = c01sum;
|
||||
|
||||
Mat vecXMasked, vecYMasked;
|
||||
vecX.copyTo(vecXMasked, roiMask);
|
||||
vecY.copyTo(vecYMasked, roiMask);
|
||||
|
||||
Mat updatedC10, updatedC01;
|
||||
multiply(c10sum, vecXMasked, updatedC10, 1, CV_32F);
|
||||
multiply(c01sum, vecYMasked, updatedC01, 1, CV_32F);
|
||||
|
||||
Mat component(componentsMat, Rect(i * kernelMasked.cols, o * kernelMasked.rows, kernelMasked.cols, kernelMasked.rows));
|
||||
add(updatedC01, updatedC10, component);
|
||||
add(component, c00sum, component);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ft::FT12D_createPolynomMatrixVertical(int radius, OutputArray matrix, const int chn)
|
||||
{
|
||||
int dimension = radius * 2 + 1;
|
||||
|
||||
std::vector<Mat> channels;
|
||||
Mat oneChannel(dimension, dimension, CV_16SC1, Scalar(0));
|
||||
|
||||
for (int i = 0; i < radius; i++)
|
||||
{
|
||||
oneChannel.col(i) = i - radius;
|
||||
oneChannel.col(dimension - 1 - i) = radius - i;
|
||||
}
|
||||
|
||||
for (int i = 0; i < chn; i++)
|
||||
{
|
||||
channels.push_back(oneChannel);
|
||||
}
|
||||
|
||||
merge(channels, matrix);
|
||||
}
|
||||
|
||||
void ft::FT12D_createPolynomMatrixHorizontal(int radius, OutputArray matrix, const int chn)
|
||||
{
|
||||
int dimension = radius * 2 + 1;
|
||||
|
||||
std::vector<Mat> channels;
|
||||
Mat oneChannel(dimension, dimension, CV_16SC1, Scalar(0));
|
||||
|
||||
for (int i = 0; i < radius; i++)
|
||||
{
|
||||
oneChannel.row(i) = i - radius;
|
||||
oneChannel.row(dimension - 1 - i) = radius - i;
|
||||
}
|
||||
|
||||
for (int i = 0; i < chn; i++)
|
||||
{
|
||||
channels.push_back(oneChannel);
|
||||
}
|
||||
|
||||
merge(channels, matrix);
|
||||
}
|
||||
|
||||
void ft::FT12D_inverseFT(InputArray components, InputArray kernel, OutputArray output, int width, int height)
|
||||
{
|
||||
CV_Assert(components.channels() == 1 && kernel.channels() == 1);
|
||||
|
||||
Mat componentsMat = components.getMat();
|
||||
|
||||
int radiusX = (kernel.cols() - 1) / 2;
|
||||
int radiusY = (kernel.rows() - 1) / 2;
|
||||
int outputWidthPadded = radiusX + width + kernel.cols();
|
||||
int outputHeightPadded = radiusY + height + kernel.rows();
|
||||
|
||||
output.create(height, width, CV_32F);
|
||||
|
||||
Mat outputZeroes(outputHeightPadded, outputWidthPadded, CV_32F, Scalar(0));
|
||||
|
||||
for (int i = 0; i < componentsMat.cols / kernel.cols(); i++)
|
||||
{
|
||||
for (int o = 0; o < componentsMat.rows / kernel.rows(); o++)
|
||||
{
|
||||
int centerX = (i * radiusX) + radiusX;
|
||||
int centerY = (o * radiusY) + radiusY;
|
||||
Rect area(centerX - radiusX, centerY - radiusY, kernel.cols(), kernel.rows());
|
||||
|
||||
Mat component(componentsMat, Rect(i * kernel.cols(), o * kernel.rows(), kernel.cols(), kernel.rows()));
|
||||
|
||||
Mat inverse;
|
||||
multiply(kernel, component, inverse, 1, CV_32F);
|
||||
|
||||
Mat roiOutput(outputZeroes, area);
|
||||
add(roiOutput, inverse, roiOutput);
|
||||
}
|
||||
}
|
||||
|
||||
outputZeroes(Rect(radiusX, radiusY, width, height)).copyTo(output);
|
||||
}
|
||||
|
||||
void ft::FT12D_process(InputArray matrix, InputArray kernel, OutputArray output, InputArray mask)
|
||||
{
|
||||
CV_Assert(matrix.channels() == kernel.channels());
|
||||
|
||||
Mat inputMask;
|
||||
|
||||
if (mask.getMat().empty())
|
||||
{
|
||||
inputMask = Mat::ones(matrix.size(), CV_8U);
|
||||
}
|
||||
else
|
||||
{
|
||||
CV_Assert(mask.channels() == 1);
|
||||
|
||||
inputMask = mask.getMat();
|
||||
}
|
||||
|
||||
Mat matrixPadded;
|
||||
Mat maskPadded;
|
||||
|
||||
int radiusX = (kernel.cols() - 1) / 2;
|
||||
int radiusY = (kernel.rows() - 1) / 2;
|
||||
int An = matrix.cols() / radiusX + 1;
|
||||
int Bn = matrix.rows() / radiusY + 1;
|
||||
int outputWidthPadded = radiusX + matrix.cols() + kernel.cols();
|
||||
int outputHeightPadded = radiusY + matrix.rows() + kernel.rows();
|
||||
|
||||
output.create(matrix.size(), CV_MAKETYPE(CV_32F, matrix.channels()));
|
||||
|
||||
Mat outputZeroes(outputHeightPadded, outputWidthPadded, output.type(), Scalar(0));
|
||||
|
||||
copyMakeBorder(matrix, matrixPadded, radiusY, kernel.rows(), radiusX, kernel.cols(), BORDER_CONSTANT, Scalar(0));
|
||||
copyMakeBorder(inputMask, maskPadded, radiusY, kernel.rows(), radiusX, kernel.cols(), BORDER_CONSTANT, Scalar(0));
|
||||
|
||||
Mat vecX;
|
||||
Mat vecY;
|
||||
|
||||
ft::FT12D_createPolynomMatrixVertical(radiusX, vecX, matrix.channels());
|
||||
ft::FT12D_createPolynomMatrixHorizontal(radiusY, vecY, matrix.channels());
|
||||
|
||||
for (int i = 0; i < An; i++)
|
||||
{
|
||||
for (int o = 0; o < Bn; o++)
|
||||
{
|
||||
int centerX = (i * radiusX) + radiusX;
|
||||
int centerY = (o * radiusY) + radiusY;
|
||||
Rect area(centerX - radiusX, centerY - radiusY, kernel.cols(), kernel.rows());
|
||||
|
||||
Mat roiImage(matrixPadded, area);
|
||||
Mat roiMask(maskPadded, area);
|
||||
Mat kernelMasked;
|
||||
|
||||
kernel.copyTo(kernelMasked, roiMask);
|
||||
|
||||
Mat numerator00, numerator10, numerator01;
|
||||
multiply(roiImage, kernelMasked, numerator00, 1, CV_32F);
|
||||
multiply(numerator00, vecX, numerator10, 1, CV_32F);
|
||||
multiply(numerator00, vecY, numerator01, 1, CV_32F);
|
||||
|
||||
Mat denominator00, denominator10, denominator01;
|
||||
denominator00 = kernelMasked;
|
||||
multiply(vecX.mul(vecX), kernelMasked, denominator10, 1, CV_32F);
|
||||
multiply(vecY.mul(vecY), kernelMasked, denominator01, 1, CV_32F);
|
||||
|
||||
Scalar c00, c10, c01;
|
||||
divide(sum(numerator00), sum(denominator00), c00, 1, CV_32F);
|
||||
divide(sum(numerator10), sum(denominator10), c10, 1, CV_32F);
|
||||
divide(sum(numerator01), sum(denominator01), c01, 1, CV_32F);
|
||||
|
||||
Mat component, updatedC10, updatedC01;
|
||||
|
||||
multiply(c10, vecX, updatedC10, 1, CV_32F);
|
||||
multiply(c01, vecY, updatedC01, 1, CV_32F);
|
||||
|
||||
add(updatedC01, updatedC10, component);
|
||||
add(component, c00, component);
|
||||
|
||||
Mat inverse;
|
||||
multiply(kernel, component, inverse, 1, CV_32F);
|
||||
|
||||
Mat roiOutput(outputZeroes, area);
|
||||
add(roiOutput, inverse, roiOutput);
|
||||
}
|
||||
}
|
||||
|
||||
outputZeroes(Rect(radiusX, radiusY, matrix.cols(), matrix.rows())).copyTo(output);
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2015, University of Ostrava, Institute for Research and Applications of Fuzzy Modeling,
|
||||
// Pavel Vlasanek, all rights reserved. Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
using namespace cv;
|
||||
|
||||
void ft::createKernel(InputArray A, InputArray B, OutputArray kernel, const int chn)
|
||||
{
|
||||
Mat AMat = A.getMat();
|
||||
Mat BMat = B.getMat();
|
||||
Mat kernelOneChannel = BMat * AMat;
|
||||
std::vector<Mat> channels;
|
||||
|
||||
for (int i = 0; i < chn; i++)
|
||||
{
|
||||
channels.push_back(kernelOneChannel);
|
||||
}
|
||||
|
||||
merge(channels, kernel);
|
||||
}
|
||||
|
||||
void ft::createKernel(int function, int radius, OutputArray kernel, const int chn)
|
||||
{
|
||||
int basicFunctionWidth = 2 * radius + 1;
|
||||
Mat kernelOneChannel;
|
||||
Mat A(1, basicFunctionWidth, CV_32F, 0.0f);
|
||||
std::vector<Mat> channels;
|
||||
|
||||
A.at<float>(0, radius) = 1;
|
||||
|
||||
if (function == ft::LINEAR)
|
||||
{
|
||||
float a = 1.0f / radius;
|
||||
|
||||
for (int i = 1; i < radius; i++)
|
||||
{
|
||||
float previous = A.at<float>(0, i - 1);
|
||||
float current = previous + a;
|
||||
|
||||
A.at<float>(0, i) = current;
|
||||
A.at<float>(0, (2 * radius) - i) = current;
|
||||
}
|
||||
|
||||
mulTransposed(A, kernelOneChannel, true);
|
||||
}
|
||||
|
||||
for (int i = 0; i < chn; i++)
|
||||
{
|
||||
channels.push_back(kernelOneChannel);
|
||||
}
|
||||
|
||||
merge(channels, kernel);
|
||||
}
|
||||
|
||||
void ft::inpaint(InputArray image, InputArray mask, OutputArray output, int radius, int function, int algorithm)
|
||||
{
|
||||
if (algorithm == ft::ONE_STEP)
|
||||
{
|
||||
Mat kernel;
|
||||
ft::createKernel(function, radius, kernel, image.channels());
|
||||
|
||||
Mat processingInput;
|
||||
image.getMat().convertTo(processingInput, CV_32F);
|
||||
|
||||
ft::FT02D_process(image, kernel, output, mask);
|
||||
|
||||
processingInput.copyTo(output, mask);
|
||||
}
|
||||
else if (algorithm == ft::MULTI_STEP)
|
||||
{
|
||||
Mat kernel;
|
||||
int state = 0;
|
||||
int currentRadius = radius;
|
||||
|
||||
Mat processingInput;
|
||||
image.getMat().convertTo(processingInput, CV_32F);
|
||||
|
||||
do
|
||||
{
|
||||
ft::createKernel(function, currentRadius, kernel, image.channels());
|
||||
|
||||
state = ft::FT02D_iteration(image, kernel, output, mask, noArray(), true);
|
||||
|
||||
currentRadius++;
|
||||
}
|
||||
while(state != 0);
|
||||
|
||||
processingInput.copyTo(output, mask);
|
||||
}
|
||||
else if (algorithm == ft::ITERATIVE)
|
||||
{
|
||||
Mat kernel;
|
||||
Mat processingOutput;
|
||||
Mat maskOutput;
|
||||
int state = 0;
|
||||
int currentRadius = radius;
|
||||
|
||||
Mat processingInput;
|
||||
image.getMat().convertTo(processingInput, CV_32F);
|
||||
|
||||
Mat processingMask;
|
||||
mask.copyTo(processingMask);
|
||||
|
||||
do
|
||||
{
|
||||
ft::createKernel(function, currentRadius, kernel, image.channels());
|
||||
|
||||
Mat invMask = 1 - processingMask;
|
||||
|
||||
state = ft::FT02D_iteration(processingInput, kernel, processingOutput, processingMask, maskOutput, false);
|
||||
|
||||
maskOutput.copyTo(processingMask);
|
||||
processingOutput.copyTo(processingInput, invMask);
|
||||
|
||||
currentRadius++;
|
||||
}
|
||||
while(state != 0);
|
||||
|
||||
processingInput.copyTo(output);
|
||||
}
|
||||
}
|
||||
|
||||
void ft::filter(InputArray image, InputArray kernel, OutputArray output)
|
||||
{
|
||||
Mat mask = Mat::ones(image.size(), CV_8U);
|
||||
|
||||
ft::FT02D_process(image, kernel, output, mask);
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2015, University of Ostrava, Institute for Research and Applications of Fuzzy Modeling,
|
||||
// Pavel Vlasanek, all rights reserved. Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_PRECOMP_H__
|
||||
#define __OPENCV_PRECOMP_H__
|
||||
|
||||
#include "opencv2/core/private.hpp"
|
||||
#include "opencv2/core/utility.hpp"
|
||||
#include "opencv2/imgproc.hpp"
|
||||
#include "opencv2/fuzzy.hpp"
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,233 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2015, University of Ostrava, Institute for Research and Applications of Fuzzy Modeling,
|
||||
// Pavel Vlasanek, all rights reserved. Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
|
||||
namespace opencv_test { namespace {
|
||||
|
||||
TEST(fuzzy_f0, components)
|
||||
{
|
||||
float arI[16][16] =
|
||||
{
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 }
|
||||
};
|
||||
Mat I = Mat(16, 16, CV_32F, arI);
|
||||
|
||||
float arDemandedComp[9][9] =
|
||||
{
|
||||
{ 0, 2.5, 33.75, 80.25, 127, 173.75, 220.75, 252.25, 255 },
|
||||
{ 0, 2.5, 33.75, 80.25, 127, 173.75, 220.75, 252.25, 255 },
|
||||
{ 0, 2.5, 33.75, 80.25, 127, 173.75, 220.75, 252.25, 255 },
|
||||
{ 0, 2.5, 33.75, 80.25, 127, 173.75, 220.75, 252.25, 255 },
|
||||
{ 0, 2.5, 33.75, 80.25, 127, 173.75, 220.75, 252.25, 255 },
|
||||
{ 0, 2.5, 33.75, 80.25, 127, 173.75, 220.75, 252.25, 255 },
|
||||
{ 0, 2.5, 33.75, 80.25, 127, 173.75, 220.75, 252.25, 255 },
|
||||
{ 0, 2.5, 33.75, 80.25, 127, 173.75, 220.75, 252.25, 255 },
|
||||
{ 0, 2.5, 33.75, 80.25, 127, 173.75, 220.75, 252.25, 255 }
|
||||
};
|
||||
Mat demandedComp = Mat(9, 9, CV_32F, arDemandedComp);
|
||||
|
||||
Mat kernel;
|
||||
ft::createKernel(ft::LINEAR, 2, kernel, 1);
|
||||
|
||||
Mat f0comp;
|
||||
ft::FT02D_components(I, kernel, f0comp);
|
||||
|
||||
double n1 = cvtest::norm(demandedComp, f0comp, NORM_INF);
|
||||
|
||||
EXPECT_DOUBLE_EQ(n1, 0);
|
||||
}
|
||||
|
||||
TEST(fuzzy_f0, inversion)
|
||||
{
|
||||
float arDemandedO[16][16] =
|
||||
{
|
||||
{ 0, 1.25, 2.5, 18.125, 33.75, 57, 80.25, 103.625, 127, 150.375, 173.75, 197.25, 220.75, 236.5, 252.25, 253.625 },
|
||||
{ 0, 1.25, 2.5, 18.125, 33.75, 57, 80.25, 103.625, 127, 150.375, 173.75, 197.25, 220.75, 236.5, 252.25, 253.625 },
|
||||
{ 0, 1.25, 2.5, 18.125, 33.75, 57, 80.25, 103.625, 127, 150.375, 173.75, 197.25, 220.75, 236.5, 252.25, 253.625 },
|
||||
{ 0, 1.25, 2.5, 18.125, 33.75, 57, 80.25, 103.625, 127, 150.375, 173.75, 197.25, 220.75, 236.5, 252.25, 253.625 },
|
||||
{ 0, 1.25, 2.5, 18.125, 33.75, 57, 80.25, 103.625, 127, 150.375, 173.75, 197.25, 220.75, 236.5, 252.25, 253.625 },
|
||||
{ 0, 1.25, 2.5, 18.125, 33.75, 57, 80.25, 103.625, 127, 150.375, 173.75, 197.25, 220.75, 236.5, 252.25, 253.625 },
|
||||
{ 0, 1.25, 2.5, 18.125, 33.75, 57, 80.25, 103.625, 127, 150.375, 173.75, 197.25, 220.75, 236.5, 252.25, 253.625 },
|
||||
{ 0, 1.25, 2.5, 18.125, 33.75, 57, 80.25, 103.625, 127, 150.375, 173.75, 197.25, 220.75, 236.5, 252.25, 253.625 },
|
||||
{ 0, 1.25, 2.5, 18.125, 33.75, 57, 80.25, 103.625, 127, 150.375, 173.75, 197.25, 220.75, 236.5, 252.25, 253.625 },
|
||||
{ 0, 1.25, 2.5, 18.125, 33.75, 57, 80.25, 103.625, 127, 150.375, 173.75, 197.25, 220.75, 236.5, 252.25, 253.625 },
|
||||
{ 0, 1.25, 2.5, 18.125, 33.75, 57, 80.25, 103.625, 127, 150.375, 173.75, 197.25, 220.75, 236.5, 252.25, 253.625 },
|
||||
{ 0, 1.25, 2.5, 18.125, 33.75, 57, 80.25, 103.625, 127, 150.375, 173.75, 197.25, 220.75, 236.5, 252.25, 253.625 },
|
||||
{ 0, 1.25, 2.5, 18.125, 33.75, 57, 80.25, 103.625, 127, 150.375, 173.75, 197.25, 220.75, 236.5, 252.25, 253.625 },
|
||||
{ 0, 1.25, 2.5, 18.125, 33.75, 57, 80.25, 103.625, 127, 150.375, 173.75, 197.25, 220.75, 236.5, 252.25, 253.625 },
|
||||
{ 0, 1.25, 2.5, 18.125, 33.75, 57, 80.25, 103.625, 127, 150.375, 173.75, 197.25, 220.75, 236.5, 252.25, 253.625 },
|
||||
{ 0, 1.25, 2.5, 18.125, 33.75, 57, 80.25, 103.625, 127, 150.375, 173.75, 197.25, 220.75, 236.5, 252.25, 253.625 }
|
||||
};
|
||||
Mat demandedO = Mat(16, 16, CV_32F, arDemandedO);
|
||||
|
||||
float arComp[9][9] =
|
||||
{
|
||||
{ 0, 2.5, 33.75, 80.25, 127, 173.75, 220.75, 252.25, 255 },
|
||||
{ 0, 2.5, 33.75, 80.25, 127, 173.75, 220.75, 252.25, 255 },
|
||||
{ 0, 2.5, 33.75, 80.25, 127, 173.75, 220.75, 252.25, 255 },
|
||||
{ 0, 2.5, 33.75, 80.25, 127, 173.75, 220.75, 252.25, 255 },
|
||||
{ 0, 2.5, 33.75, 80.25, 127, 173.75, 220.75, 252.25, 255 },
|
||||
{ 0, 2.5, 33.75, 80.25, 127, 173.75, 220.75, 252.25, 255 },
|
||||
{ 0, 2.5, 33.75, 80.25, 127, 173.75, 220.75, 252.25, 255 },
|
||||
{ 0, 2.5, 33.75, 80.25, 127, 173.75, 220.75, 252.25, 255 },
|
||||
{ 0, 2.5, 33.75, 80.25, 127, 173.75, 220.75, 252.25, 255 }
|
||||
};
|
||||
Mat comp = Mat(9, 9, CV_32F, arComp);
|
||||
|
||||
Mat kernel;
|
||||
ft::createKernel(ft::LINEAR, 2, kernel, 1);
|
||||
|
||||
Mat O;
|
||||
ft::FT02D_inverseFT(comp, kernel, O, 16, 16);
|
||||
|
||||
double n1 = cvtest::norm(demandedO, O, NORM_INF);
|
||||
|
||||
EXPECT_DOUBLE_EQ(n1, 0);
|
||||
}
|
||||
|
||||
TEST(fuzzy_f0, process)
|
||||
{
|
||||
float arI[16][16] =
|
||||
{
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 }
|
||||
};
|
||||
Mat I = Mat(16, 16, CV_32F, arI);
|
||||
|
||||
float arDemandedO[16][16] =
|
||||
{
|
||||
{ 0, 1.25, 2.5, 18.125, 33.75, 57, 80.25, 103.625, 127, 150.375, 173.75, 197.25, 220.75, 236.5, 252.25, 253.625 },
|
||||
{ 0, 1.25, 2.5, 18.125, 33.75, 57, 80.25, 103.625, 127, 150.375, 173.75, 197.25, 220.75, 236.5, 252.25, 253.625 },
|
||||
{ 0, 1.25, 2.5, 18.125, 33.75, 57, 80.25, 103.625, 127, 150.375, 173.75, 197.25, 220.75, 236.5, 252.25, 253.625 },
|
||||
{ 0, 1.25, 2.5, 18.125, 33.75, 57, 80.25, 103.625, 127, 150.375, 173.75, 197.25, 220.75, 236.5, 252.25, 253.625 },
|
||||
{ 0, 1.25, 2.5, 18.125, 33.75, 57, 80.25, 103.625, 127, 150.375, 173.75, 197.25, 220.75, 236.5, 252.25, 253.625 },
|
||||
{ 0, 1.25, 2.5, 18.125, 33.75, 57, 80.25, 103.625, 127, 150.375, 173.75, 197.25, 220.75, 236.5, 252.25, 253.625 },
|
||||
{ 0, 1.25, 2.5, 18.125, 33.75, 57, 80.25, 103.625, 127, 150.375, 173.75, 197.25, 220.75, 236.5, 252.25, 253.625 },
|
||||
{ 0, 1.25, 2.5, 18.125, 33.75, 57, 80.25, 103.625, 127, 150.375, 173.75, 197.25, 220.75, 236.5, 252.25, 253.625 },
|
||||
{ 0, 1.25, 2.5, 18.125, 33.75, 57, 80.25, 103.625, 127, 150.375, 173.75, 197.25, 220.75, 236.5, 252.25, 253.625 },
|
||||
{ 0, 1.25, 2.5, 18.125, 33.75, 57, 80.25, 103.625, 127, 150.375, 173.75, 197.25, 220.75, 236.5, 252.25, 253.625 },
|
||||
{ 0, 1.25, 2.5, 18.125, 33.75, 57, 80.25, 103.625, 127, 150.375, 173.75, 197.25, 220.75, 236.5, 252.25, 253.625 },
|
||||
{ 0, 1.25, 2.5, 18.125, 33.75, 57, 80.25, 103.625, 127, 150.375, 173.75, 197.25, 220.75, 236.5, 252.25, 253.625 },
|
||||
{ 0, 1.25, 2.5, 18.125, 33.75, 57, 80.25, 103.625, 127, 150.375, 173.75, 197.25, 220.75, 236.5, 252.25, 253.625 },
|
||||
{ 0, 1.25, 2.5, 18.125, 33.75, 57, 80.25, 103.625, 127, 150.375, 173.75, 197.25, 220.75, 236.5, 252.25, 253.625 },
|
||||
{ 0, 1.25, 2.5, 18.125, 33.75, 57, 80.25, 103.625, 127, 150.375, 173.75, 197.25, 220.75, 236.5, 252.25, 253.625 },
|
||||
{ 0, 1.25, 2.5, 18.125, 33.75, 57, 80.25, 103.625, 127, 150.375, 173.75, 197.25, 220.75, 236.5, 252.25, 253.625 }
|
||||
};
|
||||
Mat demandedO = Mat(16, 16, CV_32F, arDemandedO);
|
||||
|
||||
Mat kernel;
|
||||
ft::createKernel(ft::LINEAR, 2, kernel, 1);
|
||||
|
||||
Mat O;
|
||||
ft::FT02D_process(I, kernel, O);
|
||||
|
||||
double n1 = cvtest::norm(demandedO, O, NORM_INF);
|
||||
|
||||
EXPECT_DOUBLE_EQ(n1, 0);
|
||||
}
|
||||
|
||||
TEST(fuzzy_f0, FL_process)
|
||||
{
|
||||
string folder = string(cvtest::TS::ptr()->get_data_path()) + "fuzzy/";
|
||||
Mat orig = imread(folder + "orig.png");
|
||||
Mat exp5 = imread(folder + "exp5.png");
|
||||
|
||||
EXPECT_TRUE(!orig.empty() && !exp5.empty());
|
||||
|
||||
Mat res5;
|
||||
ft::FT02D_FL_process(orig, 5, res5);
|
||||
|
||||
res5.convertTo(res5, CV_8UC3);
|
||||
|
||||
double n1 = cvtest::norm(exp5, res5, NORM_INF);
|
||||
|
||||
EXPECT_LE(n1, 1);
|
||||
}
|
||||
|
||||
TEST(fuzzy_f0, FL_process_float)
|
||||
{
|
||||
string folder = string(cvtest::TS::ptr()->get_data_path()) + "fuzzy/";
|
||||
Mat orig = imread(folder + "orig.png");
|
||||
Mat exp6 = imread(folder + "exp6.png");
|
||||
|
||||
EXPECT_TRUE(!orig.empty() && !exp6.empty());
|
||||
|
||||
Mat res6;
|
||||
ft::FT02D_FL_process_float(orig, 5, res6);
|
||||
|
||||
res6.convertTo(res6, CV_8UC3);
|
||||
|
||||
double n1 = cvtest::norm(exp6, res6, NORM_INF);
|
||||
|
||||
EXPECT_LE(n1, 1);
|
||||
}
|
||||
|
||||
}} // namespace
|
||||
@@ -0,0 +1,398 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2015, University of Ostrava, Institute for Research and Applications of Fuzzy Modeling,
|
||||
// Pavel Vlasanek, all rights reserved. Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
|
||||
namespace opencv_test { namespace {
|
||||
|
||||
TEST(fuzzy_f1, elements)
|
||||
{
|
||||
float arI[16][16] =
|
||||
{
|
||||
{0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255},
|
||||
{0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255},
|
||||
{0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255},
|
||||
{0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255},
|
||||
{0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255},
|
||||
{0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255},
|
||||
{0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255},
|
||||
{0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255},
|
||||
{0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255},
|
||||
{0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255},
|
||||
{0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255},
|
||||
{0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255},
|
||||
{0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255},
|
||||
{0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255},
|
||||
{0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255},
|
||||
{0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255}
|
||||
};
|
||||
Mat I = Mat(16, 16, CV_32F, arI);
|
||||
|
||||
float arDemandedC00[9][9] =
|
||||
{
|
||||
{0, 2.5, 33.75, 80.25, 127, 173.75, 220.75, 252.25, 255},
|
||||
{0, 2.5, 33.75, 80.25, 127, 173.75, 220.75, 252.25, 255},
|
||||
{0, 2.5, 33.75, 80.25, 127, 173.75, 220.75, 252.25, 255},
|
||||
{0, 2.5, 33.75, 80.25, 127, 173.75, 220.75, 252.25, 255},
|
||||
{0, 2.5, 33.75, 80.25, 127, 173.75, 220.75, 252.25, 255},
|
||||
{0, 2.5, 33.75, 80.25, 127, 173.75, 220.75, 252.25, 255},
|
||||
{0, 2.5, 33.75, 80.25, 127, 173.75, 220.75, 252.25, 255},
|
||||
{0, 2.5, 33.75, 80.25, 127, 173.75, 220.75, 252.25, 255},
|
||||
{0, 2.5, 33.75, 80.25, 127, 173.75, 220.75, 252.25, 255}
|
||||
};
|
||||
Mat demandedC00 = Mat(9, 9, CV_32F, arDemandedC00);
|
||||
|
||||
float arDemandedC10[9][9] =
|
||||
{
|
||||
{0, 5, 23.5, 23.5, 23, 23.5, 23.5, 5.5, -255},
|
||||
{0, 5, 23.5, 23.5, 23, 23.5, 23.5, 5.5, -255},
|
||||
{0, 5, 23.5, 23.5, 23, 23.5, 23.5, 5.5, -255},
|
||||
{0, 5, 23.5, 23.5, 23, 23.5, 23.5, 5.5, -255},
|
||||
{0, 5, 23.5, 23.5, 23, 23.5, 23.5, 5.5, -255},
|
||||
{0, 5, 23.5, 23.5, 23, 23.5, 23.5, 5.5, -255},
|
||||
{0, 5, 23.5, 23.5, 23, 23.5, 23.5, 5.5, -255},
|
||||
{0, 5, 23.5, 23.5, 23, 23.5, 23.5, 5.5, -255},
|
||||
{0, 5, 23.5, 23.5, 23, 23.5, 23.5, 5.5, -255}
|
||||
};
|
||||
Mat demandedC10 = Mat(9, 9, CV_32F, arDemandedC10);
|
||||
|
||||
float arDemandedC01[9][9] =
|
||||
{
|
||||
{0, 2.5, 33.75, 80.25, 127, 173.75, 220.75, 252.25, 255},
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{0, -2.5, -33.75, -80.25, -127, -173.75, -220.75, -252.25, -255}
|
||||
};
|
||||
Mat demandedC01 = Mat(9, 9, CV_32F, arDemandedC01);
|
||||
|
||||
float arDemandedComp[45][45] =
|
||||
{
|
||||
{0, 0, 0, 0, 0, 2.5, 2.5, 2.5, 2.5, 2.5, 33.75, 33.75, 33.75, 33.75, 33.75, 80.25, 80.25, 80.25, 80.25, 80.25, 127, 127, 127, 127, 127, 173.75, 173.75, 173.75, 173.75, 173.75, 220.75, 220.75, 220.75, 220.75, 220.75, 252.25, 252.25, 252.25, 252.25, 252.25, 255, 255, 255, 255, 255},
|
||||
{0, 0, 0, 0, 0, 2.5, 2.5, 2.5, 2.5, 2.5, 33.75, 33.75, 33.75, 33.75, 33.75, 80.25, 80.25, 80.25, 80.25, 80.25, 127, 127, 127, 127, 127, 173.75, 173.75, 173.75, 173.75, 173.75, 220.75, 220.75, 220.75, 220.75, 220.75, 252.25, 252.25, 252.25, 252.25, 252.25, 255, 255, 255, 255, 255},
|
||||
{0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
|
||||
{0, 0, 0, 0, 0, -5, 0, 5, 10, 15, 20.5, 44, 67.5, 91, 114.5, 113.5, 137, 160.5, 184, 207.5, 208, 231, 254, 277, 300, 300.5, 324, 347.5, 371, 394.5, 394.5, 418, 441.5, 465, 488.5, 493.5, 499, 504.5, 510, 252.25, 1020, 765, 255, 255, 255},
|
||||
{0, 0, 0, 0, 0, -2.5, 2.5, 7.5, 12.5, 17.5, 54.25, 77.75, 101.25, 124.75, 148.25, 193.75, 217.25, 240.75, 264.25, 287.75, 335, 358, 381, 404, 427, 474.25, 497.75, 521.25, 544.75, 568.25, 615.25, 638.75, 662.25, 685.75, 709.25, 745.75, 751.25, 756.75, 762.25, 252.25, 1275, 1020, 255, 255, 255},
|
||||
{0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
|
||||
{0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
|
||||
{0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
|
||||
{0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
|
||||
{0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
|
||||
{0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
|
||||
{0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
|
||||
{0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
|
||||
{0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
|
||||
{0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
|
||||
{0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
|
||||
{0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
|
||||
{0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
|
||||
{0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
|
||||
{0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
|
||||
{0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
|
||||
{0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
|
||||
{0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
|
||||
{0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
|
||||
{0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
|
||||
{0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
|
||||
{0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
|
||||
{0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
|
||||
{0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
|
||||
{0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
|
||||
{0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
|
||||
{0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
|
||||
{0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
|
||||
{0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
|
||||
{0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
|
||||
{0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
|
||||
{0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
|
||||
{0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
|
||||
{0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
|
||||
{0, 0, 0, 0, 0, 2.5, 2.5, 2.5, 2.5, 2.5, 33.75, 33.75, 33.75, 33.75, 33.75, 80.25, 80.25, 80.25, 80.25, 80.25, 127, 127, 127, 127, 127, 173.75, 173.75, 173.75, 173.75, 173.75, 220.75, 220.75, 220.75, 220.75, 220.75, 252.25, 252.25, 252.25, 252.25, 252.25, 255, 255, 255, 255, 255},
|
||||
{0, 0, 0, 0, 0, -2.5, 2.5, 7.5, 12.5, 17.5, 54.25, 77.75, 101.25, 124.75, 148.25, 193.75, 217.25, 240.75, 264.25, 287.75, 335, 358, 381, 404, 427, 474.25, 497.75, 521.25, 544.75, 568.25, 615.25, 638.75, 662.25, 685.75, 709.25, 745.75, 751.25, 756.75, 762.25, 252.25, 1275, 1020, 255, 255, 255},
|
||||
{0, 0, 0, 0, 0, -5, 0, 5, 10, 15, 20.5, 44, 67.5, 91, 114.5, 113.5, 137, 160.5, 184, 207.5, 208, 231, 254, 277, 300, 300.5, 324, 347.5, 371, 394.5, 394.5, 418, 441.5, 465, 488.5, 493.5, 499, 504.5, 510, 252.25, 1020, 765, 255, 255, 255},
|
||||
{0, 0, 0, 0, 0, 2.5, 2.5, 2.5, 2.5, 2.5, 33.75, 33.75, 33.75, 33.75, 33.75, 80.25, 80.25, 80.25, 80.25, 80.25, 127, 127, 127, 127, 127, 173.75, 173.75, 173.75, 173.75, 173.75, 220.75, 220.75, 220.75, 220.75, 220.75, 252.25, 252.25, 252.25, 252.25, 252.25, 255, 255, 255, 255, 255},
|
||||
{0, 0, 0, 0, 0, 2.5, 2.5, 2.5, 2.5, 2.5, 33.75, 33.75, 33.75, 33.75, 33.75, 80.25, 80.25, 80.25, 80.25, 80.25, 127, 127, 127, 127, 127, 173.75, 173.75, 173.75, 173.75, 173.75, 220.75, 220.75, 220.75, 220.75, 220.75, 252.25, 252.25, 252.25, 252.25, 252.25, 255, 255, 255, 255, 255},
|
||||
{0, 0, 0, 0, 0, 2.5, 2.5, 2.5, 2.5, 2.5, 33.75, 33.75, 33.75, 33.75, 33.75, 80.25, 80.25, 80.25, 80.25, 80.25, 127, 127, 127, 127, 127, 173.75, 173.75, 173.75, 173.75, 173.75, 220.75, 220.75, 220.75, 220.75, 220.75, 252.25, 252.25, 252.25, 252.25, 252.25, 255, 255, 255, 255, 255}
|
||||
};
|
||||
Mat demandedComp = Mat(45, 45, CV_32F, arDemandedComp);
|
||||
|
||||
Mat kernel;
|
||||
ft::createKernel(ft::LINEAR, 2, kernel, 1);
|
||||
|
||||
Mat c00, c10, c01, f1comp;
|
||||
ft::FT12D_polynomial(I, kernel, c00, c10, c01, f1comp);
|
||||
|
||||
double n1 = cvtest::norm(demandedC00, c00, NORM_INF);
|
||||
double n2 = cvtest::norm(demandedC10, c10, NORM_INF);
|
||||
double n3 = cvtest::norm(demandedC01, c01, NORM_INF);
|
||||
double n4 = cvtest::norm(demandedComp, f1comp, NORM_INF);
|
||||
|
||||
EXPECT_DOUBLE_EQ(n1 + n2 + n3 + n4, 0);
|
||||
}
|
||||
|
||||
TEST(fuzzy_f1, components)
|
||||
{
|
||||
float arI[16][16] =
|
||||
{
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 }
|
||||
};
|
||||
Mat I = Mat(16, 16, CV_32F, arI);
|
||||
|
||||
float arDemandedComp[45][45] =
|
||||
{
|
||||
{ 0, 0, 0, 0, 0, 2.5, 2.5, 2.5, 2.5, 2.5, 33.75, 33.75, 33.75, 33.75, 33.75, 80.25, 80.25, 80.25, 80.25, 80.25, 127, 127, 127, 127, 127, 173.75, 173.75, 173.75, 173.75, 173.75, 220.75, 220.75, 220.75, 220.75, 220.75, 252.25, 252.25, 252.25, 252.25, 252.25, 255, 255, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, 2.5, 2.5, 2.5, 2.5, 2.5, 33.75, 33.75, 33.75, 33.75, 33.75, 80.25, 80.25, 80.25, 80.25, 80.25, 127, 127, 127, 127, 127, 173.75, 173.75, 173.75, 173.75, 173.75, 220.75, 220.75, 220.75, 220.75, 220.75, 252.25, 252.25, 252.25, 252.25, 252.25, 255, 255, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -5, 0, 5, 10, 15, 20.5, 44, 67.5, 91, 114.5, 113.5, 137, 160.5, 184, 207.5, 208, 231, 254, 277, 300, 300.5, 324, 347.5, 371, 394.5, 394.5, 418, 441.5, 465, 488.5, 493.5, 499, 504.5, 510, 252.25, 1020, 765, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -2.5, 2.5, 7.5, 12.5, 17.5, 54.25, 77.75, 101.25, 124.75, 148.25, 193.75, 217.25, 240.75, 264.25, 287.75, 335, 358, 381, 404, 427, 474.25, 497.75, 521.25, 544.75, 568.25, 615.25, 638.75, 662.25, 685.75, 709.25, 745.75, 751.25, 756.75, 762.25, 252.25, 1275, 1020, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, 2.5, 2.5, 2.5, 2.5, 2.5, 33.75, 33.75, 33.75, 33.75, 33.75, 80.25, 80.25, 80.25, 80.25, 80.25, 127, 127, 127, 127, 127, 173.75, 173.75, 173.75, 173.75, 173.75, 220.75, 220.75, 220.75, 220.75, 220.75, 252.25, 252.25, 252.25, 252.25, 252.25, 255, 255, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -2.5, 2.5, 7.5, 12.5, 17.5, 54.25, 77.75, 101.25, 124.75, 148.25, 193.75, 217.25, 240.75, 264.25, 287.75, 335, 358, 381, 404, 427, 474.25, 497.75, 521.25, 544.75, 568.25, 615.25, 638.75, 662.25, 685.75, 709.25, 745.75, 751.25, 756.75, 762.25, 252.25, 1275, 1020, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -5, 0, 5, 10, 15, 20.5, 44, 67.5, 91, 114.5, 113.5, 137, 160.5, 184, 207.5, 208, 231, 254, 277, 300, 300.5, 324, 347.5, 371, 394.5, 394.5, 418, 441.5, 465, 488.5, 493.5, 499, 504.5, 510, 252.25, 1020, 765, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, 2.5, 2.5, 2.5, 2.5, 2.5, 33.75, 33.75, 33.75, 33.75, 33.75, 80.25, 80.25, 80.25, 80.25, 80.25, 127, 127, 127, 127, 127, 173.75, 173.75, 173.75, 173.75, 173.75, 220.75, 220.75, 220.75, 220.75, 220.75, 252.25, 252.25, 252.25, 252.25, 252.25, 255, 255, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, 2.5, 2.5, 2.5, 2.5, 2.5, 33.75, 33.75, 33.75, 33.75, 33.75, 80.25, 80.25, 80.25, 80.25, 80.25, 127, 127, 127, 127, 127, 173.75, 173.75, 173.75, 173.75, 173.75, 220.75, 220.75, 220.75, 220.75, 220.75, 252.25, 252.25, 252.25, 252.25, 252.25, 255, 255, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, 2.5, 2.5, 2.5, 2.5, 2.5, 33.75, 33.75, 33.75, 33.75, 33.75, 80.25, 80.25, 80.25, 80.25, 80.25, 127, 127, 127, 127, 127, 173.75, 173.75, 173.75, 173.75, 173.75, 220.75, 220.75, 220.75, 220.75, 220.75, 252.25, 252.25, 252.25, 252.25, 252.25, 255, 255, 255, 255, 255 }
|
||||
};
|
||||
Mat demandedComp = Mat(45, 45, CV_32F, arDemandedComp);
|
||||
|
||||
Mat kernel;
|
||||
ft::createKernel(ft::LINEAR, 2, kernel, 1);
|
||||
|
||||
Mat f1comp;
|
||||
ft::FT12D_components(I, kernel, f1comp);
|
||||
|
||||
double n1 = cvtest::norm(demandedComp, f1comp, NORM_INF);
|
||||
|
||||
EXPECT_DOUBLE_EQ(n1, 0);
|
||||
}
|
||||
|
||||
TEST(fuzzy_f1, process)
|
||||
{
|
||||
float arI[16][16] =
|
||||
{
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
|
||||
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 }
|
||||
};
|
||||
Mat I = Mat(16, 16, CV_32F, arI);
|
||||
|
||||
float arDemandedO[16][16] =
|
||||
{
|
||||
{ 0, -1.25, 2.5, 8.875, 33.75, 57, 80.25, 103.875, 127, 150.125, 173.75, 197.25, 220.75, 245.5, 252.25, 383.875 },
|
||||
{ 0, -0.625, 3.75, 17.9375, 50.625, 85.5, 120.375, 155.6875, 190.5, 225.3125, 260.625, 295.875, 331.125, 363.75, 378.375, 510.6875 },
|
||||
{ 0, -1.25, 2.5, 8.875, 33.75, 57, 80.25, 103.875, 127, 150.125, 173.75, 197.25, 220.75, 245.5, 252.25, 383.875 },
|
||||
{ 0, -1.25, 2.5, 8.875, 33.75, 57, 80.25, 103.875, 127, 150.125, 173.75, 197.25, 220.75, 245.5, 252.25, 383.875 },
|
||||
{ 0, -1.25, 2.5, 8.875, 33.75, 57, 80.25, 103.875, 127, 150.125, 173.75, 197.25, 220.75, 245.5, 252.25, 383.875 },
|
||||
{ 0, -1.25, 2.5, 8.875, 33.75, 57, 80.25, 103.875, 127, 150.125, 173.75, 197.25, 220.75, 245.5, 252.25, 383.875 },
|
||||
{ 0, -1.25, 2.5, 8.875, 33.75, 57, 80.25, 103.875, 127, 150.125, 173.75, 197.25, 220.75, 245.5, 252.25, 383.875 },
|
||||
{ 0, -1.25, 2.5, 8.875, 33.75, 57, 80.25, 103.875, 127, 150.125, 173.75, 197.25, 220.75, 245.5, 252.25, 383.875 },
|
||||
{ 0, -1.25, 2.5, 8.875, 33.75, 57, 80.25, 103.875, 127, 150.125, 173.75, 197.25, 220.75, 245.5, 252.25, 383.875 },
|
||||
{ 0, -1.25, 2.5, 8.875, 33.75, 57, 80.25, 103.875, 127, 150.125, 173.75, 197.25, 220.75, 245.5, 252.25, 383.875 },
|
||||
{ 0, -1.25, 2.5, 8.875, 33.75, 57, 80.25, 103.875, 127, 150.125, 173.75, 197.25, 220.75, 245.5, 252.25, 383.875 },
|
||||
{ 0, -1.25, 2.5, 8.875, 33.75, 57, 80.25, 103.875, 127, 150.125, 173.75, 197.25, 220.75, 245.5, 252.25, 383.875 },
|
||||
{ 0, -1.25, 2.5, 8.875, 33.75, 57, 80.25, 103.875, 127, 150.125, 173.75, 197.25, 220.75, 245.5, 252.25, 383.875 },
|
||||
{ 0, -1.25, 2.5, 8.875, 33.75, 57, 80.25, 103.875, 127, 150.125, 173.75, 197.25, 220.75, 245.5, 252.25, 383.875 },
|
||||
{ 0, -1.25, 2.5, 8.875, 33.75, 57, 80.25, 103.875, 127, 150.125, 173.75, 197.25, 220.75, 245.5, 252.25, 383.875 },
|
||||
{ 0, -0.625, 3.75, 17.9375, 50.625, 85.5, 120.375, 155.6875, 190.5, 225.3125, 260.625, 295.875, 331.125, 363.75, 378.375, 510.6875 }
|
||||
};
|
||||
Mat demandedO = Mat(16, 16, CV_32F, arDemandedO);
|
||||
|
||||
Mat kernel;
|
||||
ft::createKernel(ft::LINEAR, 2, kernel, 1);
|
||||
|
||||
Mat O;
|
||||
ft::FT12D_process(I, kernel, O);
|
||||
|
||||
double n1 = cvtest::norm(demandedO, O, NORM_INF);
|
||||
|
||||
EXPECT_DOUBLE_EQ(n1, 0);
|
||||
}
|
||||
|
||||
TEST(fuzzy_f1, inversion)
|
||||
{
|
||||
float arDemandedO[16][16] =
|
||||
{
|
||||
{ 0, -1.25, 2.5, 8.875, 33.75, 57, 80.25, 103.875, 127, 150.125, 173.75, 197.25, 220.75, 245.5, 252.25, 383.875 },
|
||||
{ 0, -0.625, 3.75, 17.9375, 50.625, 85.5, 120.375, 155.6875, 190.5, 225.3125, 260.625, 295.875, 331.125, 363.75, 378.375, 510.6875 },
|
||||
{ 0, -1.25, 2.5, 8.875, 33.75, 57, 80.25, 103.875, 127, 150.125, 173.75, 197.25, 220.75, 245.5, 252.25, 383.875 },
|
||||
{ 0, -1.25, 2.5, 8.875, 33.75, 57, 80.25, 103.875, 127, 150.125, 173.75, 197.25, 220.75, 245.5, 252.25, 383.875 },
|
||||
{ 0, -1.25, 2.5, 8.875, 33.75, 57, 80.25, 103.875, 127, 150.125, 173.75, 197.25, 220.75, 245.5, 252.25, 383.875 },
|
||||
{ 0, -1.25, 2.5, 8.875, 33.75, 57, 80.25, 103.875, 127, 150.125, 173.75, 197.25, 220.75, 245.5, 252.25, 383.875 },
|
||||
{ 0, -1.25, 2.5, 8.875, 33.75, 57, 80.25, 103.875, 127, 150.125, 173.75, 197.25, 220.75, 245.5, 252.25, 383.875 },
|
||||
{ 0, -1.25, 2.5, 8.875, 33.75, 57, 80.25, 103.875, 127, 150.125, 173.75, 197.25, 220.75, 245.5, 252.25, 383.875 },
|
||||
{ 0, -1.25, 2.5, 8.875, 33.75, 57, 80.25, 103.875, 127, 150.125, 173.75, 197.25, 220.75, 245.5, 252.25, 383.875 },
|
||||
{ 0, -1.25, 2.5, 8.875, 33.75, 57, 80.25, 103.875, 127, 150.125, 173.75, 197.25, 220.75, 245.5, 252.25, 383.875 },
|
||||
{ 0, -1.25, 2.5, 8.875, 33.75, 57, 80.25, 103.875, 127, 150.125, 173.75, 197.25, 220.75, 245.5, 252.25, 383.875 },
|
||||
{ 0, -1.25, 2.5, 8.875, 33.75, 57, 80.25, 103.875, 127, 150.125, 173.75, 197.25, 220.75, 245.5, 252.25, 383.875 },
|
||||
{ 0, -1.25, 2.5, 8.875, 33.75, 57, 80.25, 103.875, 127, 150.125, 173.75, 197.25, 220.75, 245.5, 252.25, 383.875 },
|
||||
{ 0, -1.25, 2.5, 8.875, 33.75, 57, 80.25, 103.875, 127, 150.125, 173.75, 197.25, 220.75, 245.5, 252.25, 383.875 },
|
||||
{ 0, -1.25, 2.5, 8.875, 33.75, 57, 80.25, 103.875, 127, 150.125, 173.75, 197.25, 220.75, 245.5, 252.25, 383.875 },
|
||||
{ 0, -0.625, 3.75, 17.9375, 50.625, 85.5, 120.375, 155.6875, 190.5, 225.3125, 260.625, 295.875, 331.125, 363.75, 378.375, 510.6875 }
|
||||
};
|
||||
Mat demandedO = Mat(16, 16, CV_32F, arDemandedO);
|
||||
|
||||
float arComp[45][45] =
|
||||
{
|
||||
{ 0, 0, 0, 0, 0, 2.5, 2.5, 2.5, 2.5, 2.5, 33.75, 33.75, 33.75, 33.75, 33.75, 80.25, 80.25, 80.25, 80.25, 80.25, 127, 127, 127, 127, 127, 173.75, 173.75, 173.75, 173.75, 173.75, 220.75, 220.75, 220.75, 220.75, 220.75, 252.25, 252.25, 252.25, 252.25, 252.25, 255, 255, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, 2.5, 2.5, 2.5, 2.5, 2.5, 33.75, 33.75, 33.75, 33.75, 33.75, 80.25, 80.25, 80.25, 80.25, 80.25, 127, 127, 127, 127, 127, 173.75, 173.75, 173.75, 173.75, 173.75, 220.75, 220.75, 220.75, 220.75, 220.75, 252.25, 252.25, 252.25, 252.25, 252.25, 255, 255, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -5, 0, 5, 10, 15, 20.5, 44, 67.5, 91, 114.5, 113.5, 137, 160.5, 184, 207.5, 208, 231, 254, 277, 300, 300.5, 324, 347.5, 371, 394.5, 394.5, 418, 441.5, 465, 488.5, 493.5, 499, 504.5, 510, 252.25, 1020, 765, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -2.5, 2.5, 7.5, 12.5, 17.5, 54.25, 77.75, 101.25, 124.75, 148.25, 193.75, 217.25, 240.75, 264.25, 287.75, 335, 358, 381, 404, 427, 474.25, 497.75, 521.25, 544.75, 568.25, 615.25, 638.75, 662.25, 685.75, 709.25, 745.75, 751.25, 756.75, 762.25, 252.25, 1275, 1020, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, 2.5, 2.5, 2.5, 2.5, 2.5, 33.75, 33.75, 33.75, 33.75, 33.75, 80.25, 80.25, 80.25, 80.25, 80.25, 127, 127, 127, 127, 127, 173.75, 173.75, 173.75, 173.75, 173.75, 220.75, 220.75, 220.75, 220.75, 220.75, 252.25, 252.25, 252.25, 252.25, 252.25, 255, 255, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -2.5, 2.5, 7.5, 12.5, 17.5, 54.25, 77.75, 101.25, 124.75, 148.25, 193.75, 217.25, 240.75, 264.25, 287.75, 335, 358, 381, 404, 427, 474.25, 497.75, 521.25, 544.75, 568.25, 615.25, 638.75, 662.25, 685.75, 709.25, 745.75, 751.25, 756.75, 762.25, 252.25, 1275, 1020, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, -5, 0, 5, 10, 15, 20.5, 44, 67.5, 91, 114.5, 113.5, 137, 160.5, 184, 207.5, 208, 231, 254, 277, 300, 300.5, 324, 347.5, 371, 394.5, 394.5, 418, 441.5, 465, 488.5, 493.5, 499, 504.5, 510, 252.25, 1020, 765, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, 2.5, 2.5, 2.5, 2.5, 2.5, 33.75, 33.75, 33.75, 33.75, 33.75, 80.25, 80.25, 80.25, 80.25, 80.25, 127, 127, 127, 127, 127, 173.75, 173.75, 173.75, 173.75, 173.75, 220.75, 220.75, 220.75, 220.75, 220.75, 252.25, 252.25, 252.25, 252.25, 252.25, 255, 255, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, 2.5, 2.5, 2.5, 2.5, 2.5, 33.75, 33.75, 33.75, 33.75, 33.75, 80.25, 80.25, 80.25, 80.25, 80.25, 127, 127, 127, 127, 127, 173.75, 173.75, 173.75, 173.75, 173.75, 220.75, 220.75, 220.75, 220.75, 220.75, 252.25, 252.25, 252.25, 252.25, 252.25, 255, 255, 255, 255, 255 },
|
||||
{ 0, 0, 0, 0, 0, 2.5, 2.5, 2.5, 2.5, 2.5, 33.75, 33.75, 33.75, 33.75, 33.75, 80.25, 80.25, 80.25, 80.25, 80.25, 127, 127, 127, 127, 127, 173.75, 173.75, 173.75, 173.75, 173.75, 220.75, 220.75, 220.75, 220.75, 220.75, 252.25, 252.25, 252.25, 252.25, 252.25, 255, 255, 255, 255, 255 }
|
||||
};
|
||||
Mat comp = Mat(45, 45, CV_32F, arComp);
|
||||
|
||||
Mat kernel;
|
||||
ft::createKernel(ft::LINEAR, 2, kernel, 1);
|
||||
|
||||
Mat O;
|
||||
ft::FT12D_inverseFT(comp, kernel, O, 16, 16);
|
||||
|
||||
double n1 = cvtest::norm(demandedO, O, NORM_INF);
|
||||
|
||||
EXPECT_DOUBLE_EQ(n1, 0);
|
||||
}
|
||||
|
||||
}} // namespace
|
||||
@@ -0,0 +1,113 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2015, University of Ostrava, Institute for Research and Applications of Fuzzy Modeling,
|
||||
// Pavel Vlasanek, all rights reserved. Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
|
||||
namespace opencv_test { namespace {
|
||||
|
||||
TEST(fuzzy_image, inpainting)
|
||||
{
|
||||
string folder = string(cvtest::TS::ptr()->get_data_path()) + "fuzzy/";
|
||||
Mat orig = imread(folder + "orig.png");
|
||||
Mat exp1 = imread(folder + "exp1.png");
|
||||
Mat exp2 = imread(folder + "exp2.png");
|
||||
Mat exp3 = imread(folder + "exp3.png");
|
||||
Mat mask1 = imread(folder + "mask1.png", IMREAD_GRAYSCALE);
|
||||
Mat mask2 = imread(folder + "mask2.png", IMREAD_GRAYSCALE);
|
||||
|
||||
EXPECT_TRUE(!orig.empty() && !exp1.empty() && !exp2.empty() && !exp3.empty() && !mask1.empty() && !mask2.empty());
|
||||
|
||||
Mat res1, res2, res3;
|
||||
ft::inpaint(orig, mask1, res1, 2, ft::LINEAR, ft::ONE_STEP);
|
||||
ft::inpaint(orig, mask2, res2, 2, ft::LINEAR, ft::MULTI_STEP);
|
||||
ft::inpaint(orig, mask2, res3, 2, ft::LINEAR, ft::ITERATIVE);
|
||||
|
||||
res1.convertTo(res1, CV_8UC3);
|
||||
res2.convertTo(res2, CV_8UC3);
|
||||
res3.convertTo(res3, CV_8UC3);
|
||||
|
||||
double n1 = cvtest::norm(exp1, res1, NORM_INF);
|
||||
double n2 = cvtest::norm(exp2, res2, NORM_INF);
|
||||
double n3 = cvtest::norm(exp3, res3, NORM_INF);
|
||||
|
||||
EXPECT_LE(n1, 1);
|
||||
EXPECT_LE(n2, 1);
|
||||
EXPECT_LE(n3, 1);
|
||||
}
|
||||
|
||||
TEST(fuzzy_image, filtering)
|
||||
{
|
||||
string folder = string(cvtest::TS::ptr()->get_data_path()) + "fuzzy/";
|
||||
Mat orig = imread(folder + "orig.png");
|
||||
Mat exp4 = imread(folder + "exp4.png");
|
||||
|
||||
EXPECT_TRUE(!orig.empty() && !exp4.empty());
|
||||
|
||||
Mat kernel;
|
||||
ft::createKernel(ft::LINEAR, 20, kernel, 3);
|
||||
|
||||
Mat res4;
|
||||
ft::filter(orig, kernel, res4);
|
||||
|
||||
res4.convertTo(res4, CV_8UC3);
|
||||
|
||||
double n1 = cvtest::norm(exp4, res4, NORM_INF);
|
||||
|
||||
EXPECT_LE(n1, 1);
|
||||
}
|
||||
|
||||
TEST(fuzzy_image, kernel)
|
||||
{
|
||||
Mat kernel1;
|
||||
ft::createKernel(ft::LINEAR, 2, kernel1, 1);
|
||||
|
||||
Mat vectorA = (Mat_<float>(1, 5) << 0, 0.5, 1, 0.5, 0);
|
||||
Mat vectorB = (Mat_<float>(5, 1) << 0, 0.5, 1, 0.5, 0);
|
||||
|
||||
Mat kernel2;
|
||||
ft::createKernel(vectorA, vectorB, kernel2, 1);
|
||||
|
||||
double diff = cvtest::norm(kernel1, kernel2, NORM_INF);
|
||||
|
||||
EXPECT_DOUBLE_EQ(diff, 0);
|
||||
}
|
||||
|
||||
}} // namespace
|
||||
@@ -0,0 +1,6 @@
|
||||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
#include "test_precomp.hpp"
|
||||
|
||||
CV_TEST_MAIN("cv")
|
||||
@@ -0,0 +1,11 @@
|
||||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
#ifndef __OPENCV_TEST_PRECOMP_HPP__
|
||||
#define __OPENCV_TEST_PRECOMP_HPP__
|
||||
|
||||
#include "opencv2/ts.hpp"
|
||||
#include "opencv2/imgcodecs.hpp"
|
||||
#include "opencv2/fuzzy.hpp"
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,60 @@
|
||||
Filtering using F-transform {#tutorial_fuzzy_filtering}
|
||||
=============
|
||||
|
||||
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 \f$g\f$ introduced before as well:
|
||||
|
||||
\f[
|
||||
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)},
|
||||
\f]
|
||||
|
||||
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.
|
||||
|
||||
Code
|
||||
====
|
||||
@include fuzzy/samples/fuzzy_filtering.cpp
|
||||
|
||||
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.
|
||||
|
||||
@code{.cpp}
|
||||
// Input image
|
||||
Mat I = imread("input.png");
|
||||
@endcode
|
||||
|
||||
Following the F-transform formula, we must specify a kernel.
|
||||
|
||||
@code{.cpp}
|
||||
// Kernel cretion
|
||||
Mat kernel1, kernel2;
|
||||
|
||||
ft::createKernel(ft::LINEAR, 3, kernel1, 3);
|
||||
ft::createKernel(ft::LINEAR, 100, kernel2, 3);
|
||||
@endcode
|
||||
|
||||
> So now, we have two kernels that differ in `radius`. Bigger radius leads to bigger blur.
|
||||
|
||||
The filtering itself is applied as shown below.
|
||||
|
||||
@code{.cpp}
|
||||
// Filtering
|
||||
Mat output1, output2;
|
||||
|
||||
ft::filter(I, kernel1, output1);
|
||||
ft::filter(I, kernel2, output2);
|
||||
@endcode
|
||||
|
||||
Output images look as follows.
|
||||
|
||||

|
||||
|
After Width: | Height: | Size: 66 KiB |
@@ -0,0 +1,26 @@
|
||||
Fuzzy image processing tutorials {#tutorial_fuzzy}
|
||||
=============================================================
|
||||
|
||||
- @subpage tutorial_fuzzy_theory
|
||||
|
||||
_Compatibility:_ \> OpenCV 3.2.0
|
||||
|
||||
_Author:_ Pavel Vlasanek
|
||||
|
||||
You will learn basics about fuzzy mathematics namely F-transform of certain degree.
|
||||
|
||||
- @subpage tutorial_fuzzy_inpainting
|
||||
|
||||
_Compatibility:_ \> OpenCV 3.2.0
|
||||
|
||||
_Author:_ Pavel Vlasanek
|
||||
|
||||
You will learn how to use fuzzy mathematics in task of image inpainting.
|
||||
|
||||
- @subpage tutorial_fuzzy_filtering
|
||||
|
||||
_Compatibility:_ \> OpenCV 3.2.0
|
||||
|
||||
_Author:_ Pavel Vlasanek
|
||||
|
||||
You will learn how to use fuzzy mathematics in task of image filtering.
|
||||
|
After Width: | Height: | Size: 122 KiB |
|
After Width: | Height: | Size: 82 KiB |
@@ -0,0 +1,104 @@
|
||||
Inpainting using F-transform {#tutorial_fuzzy_inpainting}
|
||||
=============
|
||||
|
||||
Goal
|
||||
====
|
||||
In this tutorial, you will learn how image inpainting using F-transform works. It consists in:
|
||||
|
||||
- basic theory behind,
|
||||
- three different algorithms.
|
||||
|
||||
Introduction
|
||||
====
|
||||
The goal of this tutorial is to show that the inverse F-transform can be used for image reconstruction. By the image reconstruction, we mean a reconstruction of a corrupted image where corruption is everything that the original image does not include. It can be noise, text, scratch, etc. Proposal is to solve the problem of reconstruction with the help of an approximation technique. This means that we will be looking for an approximating image which is close to the given one and at the same time, does not contain what we recognize as the corruption. This task is called _image inpainting_.
|
||||
|
||||
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 \f$g\f$ introduced before as well:
|
||||
|
||||
\f[
|
||||
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)},
|
||||
\f]
|
||||
|
||||
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. For purpose of image processing, a binary mask \f$S\f$ is used such as
|
||||
|
||||
\f[
|
||||
g^s_{kl} = g \circ s_{kl}
|
||||
\f]
|
||||
|
||||
where \f$s_{k,l} \subset S\f$. Subarea \f$s\f$ of mask \f$S\f$ corresponds with subarea \f$\iota\f$ of image \f$I\f$. Operator \f$\circ\f$ is element-wise matrix multiplication (Hadamard product). Formula is updated to
|
||||
|
||||
\f[
|
||||
F^0_{kl}=\frac{\sum_{x=0}^{2h+1}\sum_{y=0}^{2h+1} \iota_{kl}(x,y) g^s(x,y)}{\sum_{x=0}^{2h+1}\sum_{y=0}^{2h+1} g^s(x,y)}.
|
||||
\f]
|
||||
|
||||
More details can be found in related papers.
|
||||
|
||||
Code
|
||||
====
|
||||
|
||||
@include fuzzy/samples/fuzzy_inpainting.cpp
|
||||
|
||||
Explanation
|
||||
====
|
||||
The sample below demonstrates the usage of image inpainting. Three artificial images are created using the same input and three different type of corruption. In the real life usage, the input image will be already presented but here we created it by ourselves.
|
||||
|
||||
First of all, we must load our image and three masks used for artificial damage creation.
|
||||
|
||||
@code{.cpp}
|
||||
// Input image
|
||||
Mat I = imread("input.png");
|
||||
|
||||
// Various masks
|
||||
Mat mask1 = imread("mask1.png", IMREAD_GRAYSCALE);
|
||||
Mat mask2 = imread("mask2.png", IMREAD_GRAYSCALE);
|
||||
Mat mask3 = imread("mask3.png", IMREAD_GRAYSCALE);
|
||||
@endcode
|
||||
|
||||
> See that mask must be loaded as `IMREAD_GRAYSCALE`.
|
||||
|
||||
In the next step, the masks are used for damaging our input image.
|
||||
|
||||
@code{.cpp}
|
||||
// Apply the damage
|
||||
Mat input1, input2, input3;
|
||||
|
||||
I.copyTo(input1, mask1);
|
||||
I.copyTo(input2, mask2);
|
||||
I.copyTo(input3, mask3);
|
||||
@endcode
|
||||
|
||||
Using the masks, we applied three different kind of corruption on the same input image. Here is the result.
|
||||
|
||||

|
||||
|
||||
> Do not forget that in real life usage, images `input1`, `input2` and `input3` are created naturally and used as the input directly.
|
||||
|
||||
Declaration of output images follows. In the following lines, the method of inpainting is applied. Let me explain three different algorithms one by one.
|
||||
|
||||
First of them is `ONE_STEP`.
|
||||
|
||||
@code{.cpp}
|
||||
ft::inpaint(input1, mask1, output1, 2, ft::LINEAR, ft::ONE_STEP);
|
||||
@endcode
|
||||
|
||||
The `ONE_STEP` algorithm simply compute direct F-transform ignoring damaged parts using kernel with radius `2` (as specified in the method calling). Inverse F-transform fill up the missing area using values from the components nearby. It is up to you to choose radius which is big enough.
|
||||
|
||||
Second is `MULTI_STEP`.
|
||||
|
||||
@code{.cpp}
|
||||
ft::inpaint(input2, mask2, output2, 2, ft::LINEAR, ft::MULTI_STEP);
|
||||
ft::inpaint(input3, mask3, output3, 2, ft::LINEAR, ft::MULTI_STEP);
|
||||
@endcode
|
||||
|
||||
`MULTI_STEP` algorithm works in the same way but defined radius (`2` in this case) is automatically increased if it is found insufficient. If you want to fill up the hole and you are not sure how big radius you need, you can choose `MULTI_STEP` and let the computer decide. The lowest possible will be found.
|
||||
|
||||
Last one is `ITERATIVE`.
|
||||
|
||||
@code{.cpp}
|
||||
ft::inpaint(input3, mask3, output4, 2, ft::LINEAR, ft::ITERATIVE);
|
||||
@endcode
|
||||
|
||||
Best choice in majority of cases is `ITERATIVE`. This way of processing use small radius of basic functions for small kind of damage and higher ones for bigger holes.
|
||||
|
||||

|
||||
|
After Width: | Height: | Size: 33 KiB |
|
After Width: | Height: | Size: 35 KiB |
@@ -0,0 +1,85 @@
|
||||
F-transform theory {#tutorial_fuzzy_theory}
|
||||
=============
|
||||
|
||||
Goal
|
||||
====
|
||||
In this tutorial, the basic concept of fuzzy transform is presented. You will learn:
|
||||
|
||||
- mathematic background,
|
||||
- how to apply concept of fuzziness to image processing.
|
||||
|
||||
The presented explanation demands knowledge of basic math. All related papers are cited and mostly accessible on https://www.researchgate.net/.
|
||||
|
||||
Introduction
|
||||
====
|
||||
In the last years, the theory of F-transforms has been intensively developed in many directions. In image processing, it has had successful applications in image compression and reduction, image fusion, edge detection and image reconstruction @cite Perf:FT @cite MSLP:cod-decod @cite Fusion:AFS12 @cite IPMU2012 @cite Perf:rec @cite vlavsanek2015patch. The F-transform is a technique that places a continuous/discrete function in correspondence with a finite vector of its F-transform components. In image processing, where images are identified by intensity functions of two arguments, the F-transform of the latter is given by a matrix of components.
|
||||
|
||||
Let me introduce F-transform of a 2D grayscale image \f$I\f$ that is considered as a function \f$I:[0,M]\times [0,N]\to [0,255]\f$ where \f$[0,M]=\{0,1,2,\ldots,M\}; [0,N]=\{0,1,2,\ldots,N\}\f$. It is assumed that the image is defined at points (pixels) that belong to the set \f$P\f$, where \f$P=\{(x,y)\mid x=0,1,\ldots, M;y=0,1,\ldots, N\}\f$.
|
||||
|
||||
Let \f$A_0, \dots ,A_m\f$ and \f$B_0, \dots ,B_n\f$ be basic functions, \f$A_0, \dots ,A_m : [0,M] \to [0, 1]\f$ be fuzzy partition of \f$[0,M]\f$ and \f$B_0, \dots ,B_n :[0,N]\to [0, 1]\f$ be fuzzy partition of \f$[0,N]\f$. Assume that the set of pixels \f$P\f$ is _sufficiently dense with respect to the chosen partitions_. This means that for all \f$k\in{0,\dots, m}(\exists x\in [0,M]) \ A_k(x)>0\f$, and for all \f$l\in{0,\dots, n}(\exists y\in [0,N])\ B_l(y)>0\f$.
|
||||
|
||||
\f$F^0\f$-transform
|
||||
====
|
||||
We say that the \f$m\times n\f$-matrix of real numbers \f$F^0_{mn}[I] = (F^0_{kl})\f$ is called _the (discrete) F-transform_ of \f$I\f$ with respect to \f$\{A_0, \dots,A_m\}\f$ and \f$\{B_0, \dots,B_n\}\f$ if for all \f$k=0,\dots,m,\ l=0,\dots,n\f$:
|
||||
|
||||
\f[
|
||||
F^0_{kl}=\frac{\sum_{y=0}^{N}\sum_{x=0}^{M} I(x,y)A_k(x)B_l(y)}{\sum_{y=0}^{N}\sum_{x=0}^{M} A_k(x)B_l(y)}.
|
||||
\f]
|
||||
|
||||
The coefficients \f$F^0_{kl}\f$ are called _components_ of the \f$F^0\f$-transform.
|
||||
|
||||
\f$F^1\f$-transform
|
||||
====
|
||||
\f$F^1\f$-transform has been presented in @cite perfilieva2014differentiation. We say that matrix \f$F^1_{mn}[I] = (F^1_{kl}), k=0,\ldots, m, l=0,\ldots, n\f$, is the \f$F^1\f$-transform of \f$I\f$ with respect to \f$\{A_k\times B_l\mid k=0,\ldots, m, l=0,\ldots, n\}\f$, and \f$F^1_{kl}\f$ is the corresponding \f$F^1\f$-transform component.
|
||||
|
||||
The \f$F^1\f$-transform components of \f$I\f$ are linear polynomials in the form
|
||||
|
||||
\f[
|
||||
F^1_{kl}(x,y)= c^{00}_{kl} + c^{10}_{kl}(x-x_k) + c^{01}_{kl}(y-y_l),
|
||||
\f]
|
||||
|
||||
where the coefficients are given by
|
||||
|
||||
\f[
|
||||
c_{kl}^{00} =\frac{\sum_{y=0}^{N}\sum_{x=0}^{M} I(x,y)A_k(x)B_l(y)}{\sum_{y=0}^{N}\sum_{x=0}^{M} A_k(x)B_l(y)}, \\
|
||||
c_{kl}^{10} =\frac{\sum_{y=0}^{N}\sum_{x=0}^{M} I(x,y)(x - x_k)A_k(x)B_l(y)}{\sum_{y=0}^{N}\sum_{x=0}^{M} (x - x_k)^2A_k(x)B_l(y)}, \\
|
||||
c_{kl}^{01} =\frac{\sum_{y=0}^{N}\sum_{x=0}^{M} I(x,y)(y - y_l)A_k(x)B_l(y)}{\sum_{y=0}^{N}\sum_{x=0}^{M} (y - y_l)^2A_k(x)B_l(y)}.
|
||||
\f]
|
||||
|
||||
Application to image processing
|
||||
====
|
||||
The technique of F-transforms uses two steps: _direct and inverse_. The direct step is described in the previous section whereas the inverse is as follows
|
||||
|
||||
\f[
|
||||
O(x,y)=\sum_{k=0}^{m}\sum_{l=0}^{n} F^d_{kl}A_k(x)B_l(y),
|
||||
\f]
|
||||
|
||||
where \f$O\f$ is the output (reconstructed) image and \f$d\f$ is F-transform degree. In fact, the algorithm computes the F-transform components of the input image \f$I\f$ and spreads the components afterwards to the size of \f$I\f$. For details see @cite Perf:rec. Application to image processing is possible to take from two different views.
|
||||
|
||||
From pixel point of view
|
||||
----
|
||||
The pixels are processed one by one in a way that appropriate basic functions are found for each of them. It will be exactly four, two in each direction. We need some helper structure in the memory for collecting their values. The values will be used in the nominator of the related fuzzy component. Implementation of this approach uses keyword `FL` as __fast__ processing (because of more optimizations) and __linear basic function__.
|
||||
|
||||

|
||||
|
||||
From fuzzy component point of view
|
||||
----
|
||||
In this way, image is divided to the regular areas. Each area is processed separately using kernel window. This approach benefits from easy to understand, matrix based processing with straight forward parallelization.
|
||||
|
||||

|
||||
|
||||
This approach uses kernel \f$g\f$. Let us show linear case with radius \f$h = 2\f$ as an example.
|
||||
|
||||
\f[
|
||||
A = (0, 0.5, 1, 0.5, 0) \\
|
||||
B^T = (0, 0.5, 1, 0.5, 0) \\
|
||||
g = AB^T=\left(
|
||||
\begin{array}{ccccc}
|
||||
0 & 0 & 0 & 0 & 0 \\
|
||||
0 & 0.25 & 0.5 & 0.25 & 0 \\
|
||||
0 & 0.5 & 1 & 0.5 & 0 \\
|
||||
0 & 0.25 & 0.5 & 0.25 & 0 \\
|
||||
0 & 0 & 0 & 0 & 0 \\
|
||||
\end{array}
|
||||
\right)
|
||||
\f]
|
||||