Commit 25c48887 authored by Pavel Vlasanek's avatar Pavel Vlasanek Committed by Pavel Vlasanek

F1-transform added and F0 minor fixes.

Documentation added.

Linux build fix.

Doc update.

Doc update.

Code review related fixes.

Whitespace fix.
parent 941a33ae
......@@ -20,3 +20,13 @@
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}
}
......@@ -44,6 +44,7 @@
#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"
/**
......@@ -52,13 +53,17 @@
Namespace for all functions is **ft**. The module brings implementation of the last image processing algorithms based on fuzzy mathematics.
@{
@defgroup f0_math Math with F0-transfrom support
@defgroup f0_math Math with F0-transform support
Fuzzy transform (F-transform) of the 0th degree transform whole image to a vector of its components. These components are used in latter computation.
Fuzzy transform (F0-transform) of the 0th degree transforms whole image to a matrix of its components. These components are used in latter computation where each of them represents average color of certain subarea.
@defgroup f1_math Math with F1-transform support
Fuzzy transform (F1-transform) of the 1th degree transforms whole image to a matrix of its components. Each component is polynomial of the 1th degree carrying information about average color and average gradient of certain subarea.
@defgroup f_image Fuzzy image processing
Image proceesing based on F-transform is fast to process and easy to understand.
Image proceesing based on fuzzy mathematics namely F-transform.
@}
*/
......
......@@ -56,7 +56,7 @@ namespace ft
/** @brief Computes components of the array using direct F0-transform.
@param matrix Input array.
@param kernel Kernel used for processing. Function **createKernel** can be used.
@param components Output 32-bit array for the components.
@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.
......@@ -64,24 +64,12 @@ namespace ft
@note
F-transform technique is described in paper @cite Perf:FT.
*/
CV_EXPORTS_AS(FT02D_components1) void FT02D_components(InputArray matrix, InputArray kernel, OutputArray components, InputArray mask);
/** @brief Computes components of the array using direct F0-transform.
@param matrix Input array.
@param kernel Kernel used for processing. Function **createKernel** can be used.
@param components Output 32-bit array for the components.
The function computes components using predefined kernel.
@note
F-transform technique is described in paper @cite Perf:FT.
*/
CV_EXPORTS_W void FT02D_components(InputArray matrix, InputArray kernel, OutputArray components);
CV_EXPORTS_W void FT02D_components(InputArray matrix, InputArray kernel, OutputArray components, InputArray mask = noArray());
/** @brief Computes inverse F0-transfrom.
@param components Input 32-bit single channel array for the components.
@param components Input 32-bit float single channel array for the components.
@param kernel Kernel used for processing. Function **createKernel** can be used.
@param output Output 32-bit array.
@param output Output 32-bit float array.
@param width Width of the output array.
@param height Height of the output array.
......@@ -93,26 +81,17 @@ namespace ft
/** @brief Computes F0-transfrom and inverse F0-transfrom at once.
@param matrix Input matrix.
@param kernel Kernel used for processing. Function **createKernel** can be used.
@param output Output 32-bit array.
@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 **Mat**.
*/
CV_EXPORTS_AS(FT02D_process1) void FT02D_process(InputArray matrix, InputArray kernel, OutputArray output, InputArray mask);
/** @brief Computes F0-transfrom and inverse F0-transfrom at once.
@param matrix Input matrix.
@param kernel Kernel used for processing. Function **createKernel** can be used.
@param output Output 32-bit array.
This function computes F-transfrom and inverse F-transfotm in one step. It is fully sufficient and optimized for **Mat**.
*/
CV_EXPORTS_W void FT02D_process(InputArray matrix, InputArray kernel, OutputArray output);
CV_EXPORTS_W void FT02D_process(InputArray matrix, InputArray kernel, OutputArray output, InputArray mask = noArray());
/** @brief Computes F0-transfrom and inverse F0-transfrom at once and return state.
@param matrix Input matrix.
@param kernel Kernel used for processing. Function **createKernel** can be used.
@param output Output 32-bit array.
@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.
......
/*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 F1-transform.
@param matrix Input array.
@param kernel Kernel used for processing. Function **createKernel** can be used.
@param components Output 32-bit float array for the components.
The function computes linear components using predefined kernel.
@note
F-transform technique of first degreee is described in paper @cite Vlas:FT.
*/
CV_EXPORTS_W void FT12D_components(InputArray matrix, InputArray kernel, OutputArray components);
/** @brief Computes elements of F1-transform components.
@param matrix Input array.
@param kernel Kernel used for processing. Function **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.
@note
F-transform technique of first degreee is described in paper @cite Vlas:FT.
*/
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 F1-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 F1-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 F1-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 F1-transfrom processing. It is used for gradient computation.
*/
CV_EXPORTS_W void FT12D_createPolynomMatrixHorizontal(int radius, OutputArray matrix, const int chn);
/** @brief Computes F1-transfrom and inverse F1-transfrom at once.
@param matrix Input matrix.
@param kernel Kernel used for processing. Function **createKernel** can be used.
@param output Output 32-bit float array.
@param mask Mask used for unwanted area marking.
This function computes F1-transfrom and inverse F1-transfotm in one step. It is fully sufficient and optimized for **Mat**.
*/
CV_EXPORTS_W void FT12D_process(InputArray matrix, InputArray kernel, OutputArray output, InputArray mask = noArray());
/** @brief Computes inverse F1-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.
@note
F-transform technique of first degreee is described in paper @cite Vlas:FT.
*/
CV_EXPORTS_W void FT12D_inverseFT(InputArray components, InputArray kernel, OutputArray output, int width, int height);
//! @}
}
}
#endif // __OPENCV_FUZZY_F1_MATH_H__
......@@ -301,7 +301,20 @@ void ft::FT02D_FL_process_float(InputArray matrix, const int radius, OutputArray
void ft::FT02D_components(InputArray matrix, InputArray kernel, OutputArray components, InputArray mask)
{
CV_Assert(matrix.channels() == kernel.channels() && mask.channels() == 1);
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;
......@@ -312,7 +325,7 @@ void ft::FT02D_components(InputArray matrix, InputArray kernel, OutputArray comp
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));
copyMakeBorder(inputMask, maskPadded, radiusY, kernel.rows(), radiusX, kernel.cols(), BORDER_CONSTANT, Scalar(0));
components.create(Bn, An, CV_MAKETYPE(CV_32F, matrix.channels()));
......@@ -343,13 +356,6 @@ void ft::FT02D_components(InputArray matrix, InputArray kernel, OutputArray comp
}
}
void ft::FT02D_components(InputArray matrix, InputArray kernel, OutputArray components)
{
Mat mask = Mat::ones(matrix.size(), CV_8U);
ft::FT02D_components(matrix, kernel, components, mask);
}
void ft::FT02D_inverseFT(InputArray components, InputArray kernel, OutputArray output, int width, int height)
{
CV_Assert(components.channels() == 1 && kernel.channels() == 1);
......@@ -386,16 +392,22 @@ void ft::FT02D_inverseFT(InputArray components, InputArray kernel, OutputArray o
outputZeroes(Rect(radiusX, radiusY, width, height)).copyTo(output);
}
void ft::FT02D_process(InputArray matrix, InputArray kernel, OutputArray output)
void ft::FT02D_process(InputArray matrix, InputArray kernel, OutputArray output, InputArray mask)
{
Mat mask = Mat::ones(matrix.size(), CV_8U);
CV_Assert(matrix.channels() == kernel.channels());
ft::FT02D_process(matrix, kernel, output, mask);
}
Mat inputMask;
void ft::FT02D_process(InputArray matrix, InputArray kernel, OutputArray output, InputArray mask)
{
CV_Assert(matrix.channels() == kernel.channels() && mask.channels() == 1);
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;
......@@ -412,7 +424,7 @@ void ft::FT02D_process(InputArray matrix, InputArray kernel, OutputArray output,
Mat outputZeroes(outputHeightPadded, outputWidthPadded, output.type(), Scalar(0));
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));
copyMakeBorder(inputMask, maskPadded, radiusY, kernel.rows(), radiusX, kernel.cols(), BORDER_CONSTANT, Scalar(0));
for (int i = 0; i < An; i++)
{
......
This diff is collapsed.
......@@ -96,27 +96,6 @@ TEST(fuzzy_f0, components)
TEST(fuzzy_f0, inversion)
{
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 },
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment