vendor: OpenCV 5.0.0 snapshot at 40738fb16ceddb5fb3fea747585f7ce6abb0605b
This commit is contained in:
@@ -0,0 +1,967 @@
|
||||
/*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) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2008-2012, Willow Garage Inc., 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_PHOTO_HPP
|
||||
#define OPENCV_PHOTO_HPP
|
||||
|
||||
#include "opencv2/core.hpp"
|
||||
#include "opencv2/imgproc.hpp"
|
||||
#include "opencv2/photo/ccm.hpp"
|
||||
|
||||
/**
|
||||
@defgroup photo Computational Photography
|
||||
|
||||
This module includes photo processing algorithms
|
||||
@{
|
||||
@defgroup photo_inpaint Inpainting
|
||||
@defgroup photo_denoise Denoising
|
||||
@defgroup photo_hdr HDR imaging
|
||||
|
||||
This section describes high dynamic range imaging algorithms namely tonemapping, exposure alignment,
|
||||
camera calibration with multiple exposures and exposure fusion.
|
||||
|
||||
@defgroup photo_decolor Contrast Preserving Decolorization
|
||||
|
||||
Useful links:
|
||||
|
||||
http://www.cse.cuhk.edu.hk/leojia/projects/color2gray/index.html
|
||||
|
||||
@defgroup photo_clone Seamless Cloning
|
||||
|
||||
Useful links:
|
||||
|
||||
https://www.learnopencv.com/seamless-cloning-using-opencv-python-cpp
|
||||
|
||||
@defgroup photo_render Non-Photorealistic Rendering
|
||||
|
||||
Useful links:
|
||||
|
||||
http://www.inf.ufrgs.br/~eslgastal/DomainTransform
|
||||
|
||||
https://www.learnopencv.com/non-photorealistic-rendering-using-opencv-python-c/
|
||||
|
||||
@}
|
||||
*/
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
//! @addtogroup photo
|
||||
//! @{
|
||||
|
||||
//! @addtogroup photo_inpaint
|
||||
//! @{
|
||||
//! the inpainting algorithm
|
||||
enum
|
||||
{
|
||||
INPAINT_NS = 0, //!< Use Navier-Stokes based method
|
||||
INPAINT_TELEA = 1 //!< Use the algorithm proposed by Alexandru Telea @cite Telea04
|
||||
};
|
||||
|
||||
/** @brief Restores the selected region in an image using the region neighborhood.
|
||||
|
||||
@param src Input 8-bit, 16-bit unsigned or 32-bit float 1-channel or 8-bit 3-channel image.
|
||||
@param inpaintMask Inpainting mask, 8-bit 1-channel image. Non-zero pixels indicate the area that
|
||||
needs to be inpainted.
|
||||
@param dst Output image with the same size and type as src .
|
||||
@param inpaintRadius Radius of a circular neighborhood of each point inpainted that is considered
|
||||
by the algorithm.
|
||||
@param flags Inpainting method that could be cv::INPAINT_NS or cv::INPAINT_TELEA
|
||||
|
||||
The function reconstructs the selected image area from the pixel near the area boundary. The
|
||||
function may be used to remove dust and scratches from a scanned photo, or to remove undesirable
|
||||
objects from still images or video. See <http://en.wikipedia.org/wiki/Inpainting> for more details.
|
||||
|
||||
@note
|
||||
- An example using the inpainting technique can be found at
|
||||
opencv_source_code/samples/cpp/inpaint.cpp
|
||||
- (Python) An example using the inpainting technique can be found at
|
||||
opencv_source_code/samples/python/inpaint.py
|
||||
*/
|
||||
CV_EXPORTS_W void inpaint( InputArray src, InputArray inpaintMask,
|
||||
OutputArray dst, double inpaintRadius, int flags );
|
||||
|
||||
//! @} photo_inpaint
|
||||
|
||||
//! @addtogroup photo_denoise
|
||||
//! @{
|
||||
|
||||
/** @brief Perform image denoising using Non-local Means Denoising algorithm
|
||||
<http://www.ipol.im/pub/algo/bcm_non_local_means_denoising/> with several computational
|
||||
optimizations. Noise expected to be a gaussian white noise
|
||||
|
||||
@param src Input 8-bit 1-channel, 2-channel, 3-channel or 4-channel image.
|
||||
@param dst Output image with the same size and type as src .
|
||||
@param templateWindowSize Size in pixels of the template patch that is used to compute weights.
|
||||
Should be odd. Recommended value 7 pixels
|
||||
@param searchWindowSize Size in pixels of the window that is used to compute weighted average for
|
||||
given pixel. Should be odd. Affect performance linearly: greater searchWindowsSize - greater
|
||||
denoising time. Recommended value 21 pixels
|
||||
@param h Parameter regulating filter strength. Big h value perfectly removes noise but also
|
||||
removes image details, smaller h value preserves details but also preserves some noise
|
||||
|
||||
This function expected to be applied to grayscale images. For colored images look at
|
||||
fastNlMeansDenoisingColored. Advanced usage of this functions can be manual denoising of colored
|
||||
image in different colorspaces. Such approach is used in fastNlMeansDenoisingColored by converting
|
||||
image to CIELAB colorspace and then separately denoise L and AB components with different h
|
||||
parameter.
|
||||
*/
|
||||
CV_EXPORTS_W void fastNlMeansDenoising( InputArray src, OutputArray dst, float h = 3,
|
||||
int templateWindowSize = 7, int searchWindowSize = 21);
|
||||
|
||||
/** @brief Perform image denoising using Non-local Means Denoising algorithm
|
||||
<http://www.ipol.im/pub/algo/bcm_non_local_means_denoising/> with several computational
|
||||
optimizations. Noise expected to be a gaussian white noise
|
||||
|
||||
@param src Input 8-bit or 16-bit (only with NORM_L1) 1-channel,
|
||||
2-channel, 3-channel or 4-channel image.
|
||||
@param dst Output image with the same size and type as src .
|
||||
@param templateWindowSize Size in pixels of the template patch that is used to compute weights.
|
||||
Should be odd. Recommended value 7 pixels
|
||||
@param searchWindowSize Size in pixels of the window that is used to compute weighted average for
|
||||
given pixel. Should be odd. Affect performance linearly: greater searchWindowsSize - greater
|
||||
denoising time. Recommended value 21 pixels
|
||||
@param h Array of parameters regulating filter strength, either one
|
||||
parameter applied to all channels or one per channel in dst. Big h value
|
||||
perfectly removes noise but also removes image details, smaller h
|
||||
value preserves details but also preserves some noise
|
||||
@param normType Type of norm used for weight calculation. Can be either NORM_L2 or NORM_L1
|
||||
|
||||
This function expected to be applied to grayscale images. For colored images look at
|
||||
fastNlMeansDenoisingColored. Advanced usage of this functions can be manual denoising of colored
|
||||
image in different colorspaces. Such approach is used in fastNlMeansDenoisingColored by converting
|
||||
image to CIELAB colorspace and then separately denoise L and AB components with different h
|
||||
parameter.
|
||||
*/
|
||||
CV_EXPORTS_W void fastNlMeansDenoising( InputArray src, OutputArray dst,
|
||||
const std::vector<float>& h,
|
||||
int templateWindowSize = 7, int searchWindowSize = 21,
|
||||
int normType = NORM_L2);
|
||||
|
||||
/** @brief Modification of fastNlMeansDenoising function for colored images
|
||||
|
||||
@param src Input 8-bit 3-channel image.
|
||||
@param dst Output image with the same size and type as src .
|
||||
@param templateWindowSize Size in pixels of the template patch that is used to compute weights.
|
||||
Should be odd. Recommended value 7 pixels
|
||||
@param searchWindowSize Size in pixels of the window that is used to compute weighted average for
|
||||
given pixel. Should be odd. Affect performance linearly: greater searchWindowsSize - greater
|
||||
denoising time. Recommended value 21 pixels
|
||||
@param h Parameter regulating filter strength for luminance component. Bigger h value perfectly
|
||||
removes noise but also removes image details, smaller h value preserves details but also preserves
|
||||
some noise
|
||||
@param hColor The same as h but for color components. For most images value equals 10
|
||||
will be enough to remove colored noise and do not distort colors
|
||||
|
||||
The function converts image to CIELAB colorspace and then separately denoise L and AB components
|
||||
with given h parameters using fastNlMeansDenoising function.
|
||||
*/
|
||||
CV_EXPORTS_W void fastNlMeansDenoisingColored( InputArray src, OutputArray dst,
|
||||
float h = 3, float hColor = 3,
|
||||
int templateWindowSize = 7, int searchWindowSize = 21);
|
||||
|
||||
/** @brief Modification of fastNlMeansDenoising function for images sequence where consecutive images have been
|
||||
captured in small period of time. For example video. This version of the function is for grayscale
|
||||
images or for manual manipulation with colorspaces. See @cite Buades2005DenoisingIS for more details
|
||||
(open access [here](https://static.aminer.org/pdf/PDF/000/317/196/spatio_temporal_wiener_filtering_of_image_sequences_using_a_parametric.pdf)).
|
||||
|
||||
@param srcImgs Input 8-bit 1-channel, 2-channel, 3-channel or
|
||||
4-channel images sequence. All images should have the same type and
|
||||
size.
|
||||
@param imgToDenoiseIndex Target image to denoise index in srcImgs sequence
|
||||
@param temporalWindowSize Number of surrounding images to use for target image denoising. Should
|
||||
be odd. Images from imgToDenoiseIndex - temporalWindowSize / 2 to
|
||||
imgToDenoiseIndex + temporalWindowSize / 2 from srcImgs will be used to denoise
|
||||
srcImgs[imgToDenoiseIndex] image.
|
||||
@param dst Output image with the same size and type as srcImgs images.
|
||||
@param templateWindowSize Size in pixels of the template patch that is used to compute weights.
|
||||
Should be odd. Recommended value 7 pixels
|
||||
@param searchWindowSize Size in pixels of the window that is used to compute weighted average for
|
||||
given pixel. Should be odd. Affect performance linearly: greater searchWindowsSize - greater
|
||||
denoising time. Recommended value 21 pixels
|
||||
@param h Parameter regulating filter strength. Bigger h value
|
||||
perfectly removes noise but also removes image details, smaller h
|
||||
value preserves details but also preserves some noise
|
||||
*/
|
||||
CV_EXPORTS_W void fastNlMeansDenoisingMulti( InputArrayOfArrays srcImgs, OutputArray dst,
|
||||
int imgToDenoiseIndex, int temporalWindowSize,
|
||||
float h = 3, int templateWindowSize = 7, int searchWindowSize = 21);
|
||||
|
||||
/** @brief Modification of fastNlMeansDenoising function for images sequence where consecutive images have been
|
||||
captured in small period of time. For example video. This version of the function is for grayscale
|
||||
images or for manual manipulation with colorspaces. See @cite Buades2005DenoisingIS for more details
|
||||
(open access [here](https://static.aminer.org/pdf/PDF/000/317/196/spatio_temporal_wiener_filtering_of_image_sequences_using_a_parametric.pdf)).
|
||||
|
||||
@param srcImgs Input 8-bit or 16-bit (only with NORM_L1) 1-channel,
|
||||
2-channel, 3-channel or 4-channel images sequence. All images should
|
||||
have the same type and size.
|
||||
@param imgToDenoiseIndex Target image to denoise index in srcImgs sequence
|
||||
@param temporalWindowSize Number of surrounding images to use for target image denoising. Should
|
||||
be odd. Images from imgToDenoiseIndex - temporalWindowSize / 2 to
|
||||
imgToDenoiseIndex + temporalWindowSize / 2 from srcImgs will be used to denoise
|
||||
srcImgs[imgToDenoiseIndex] image.
|
||||
@param dst Output image with the same size and type as srcImgs images.
|
||||
@param templateWindowSize Size in pixels of the template patch that is used to compute weights.
|
||||
Should be odd. Recommended value 7 pixels
|
||||
@param searchWindowSize Size in pixels of the window that is used to compute weighted average for
|
||||
given pixel. Should be odd. Affect performance linearly: greater searchWindowsSize - greater
|
||||
denoising time. Recommended value 21 pixels
|
||||
@param h Array of parameters regulating filter strength, either one
|
||||
parameter applied to all channels or one per channel in dst. Big h value
|
||||
perfectly removes noise but also removes image details, smaller h
|
||||
value preserves details but also preserves some noise
|
||||
@param normType Type of norm used for weight calculation. Can be either NORM_L2 or NORM_L1
|
||||
*/
|
||||
CV_EXPORTS_W void fastNlMeansDenoisingMulti( InputArrayOfArrays srcImgs, OutputArray dst,
|
||||
int imgToDenoiseIndex, int temporalWindowSize,
|
||||
const std::vector<float>& h,
|
||||
int templateWindowSize = 7, int searchWindowSize = 21,
|
||||
int normType = NORM_L2);
|
||||
|
||||
/** @brief Modification of fastNlMeansDenoisingMulti function for colored images sequences
|
||||
|
||||
@param srcImgs Input 8-bit 3-channel images sequence. All images should have the same type and
|
||||
size.
|
||||
@param imgToDenoiseIndex Target image to denoise index in srcImgs sequence
|
||||
@param temporalWindowSize Number of surrounding images to use for target image denoising. Should
|
||||
be odd. Images from imgToDenoiseIndex - temporalWindowSize / 2 to
|
||||
imgToDenoiseIndex + temporalWindowSize / 2 from srcImgs will be used to denoise
|
||||
srcImgs[imgToDenoiseIndex] image.
|
||||
@param dst Output image with the same size and type as srcImgs images.
|
||||
@param templateWindowSize Size in pixels of the template patch that is used to compute weights.
|
||||
Should be odd. Recommended value 7 pixels
|
||||
@param searchWindowSize Size in pixels of the window that is used to compute weighted average for
|
||||
given pixel. Should be odd. Affect performance linearly: greater searchWindowsSize - greater
|
||||
denoising time. Recommended value 21 pixels
|
||||
@param h Parameter regulating filter strength for luminance component. Bigger h value perfectly
|
||||
removes noise but also removes image details, smaller h value preserves details but also preserves
|
||||
some noise.
|
||||
@param hColor The same as h but for color components.
|
||||
|
||||
The function converts images to CIELAB colorspace and then separately denoise L and AB components
|
||||
with given h parameters using fastNlMeansDenoisingMulti function.
|
||||
*/
|
||||
CV_EXPORTS_W void fastNlMeansDenoisingColoredMulti( InputArrayOfArrays srcImgs, OutputArray dst,
|
||||
int imgToDenoiseIndex, int temporalWindowSize,
|
||||
float h = 3, float hColor = 3,
|
||||
int templateWindowSize = 7, int searchWindowSize = 21);
|
||||
|
||||
/** @brief Primal-dual algorithm is an algorithm for solving special types of variational problems (that is,
|
||||
finding a function to minimize some functional). As the image denoising, in particular, may be seen
|
||||
as the variational problem, primal-dual algorithm then can be used to perform denoising and this is
|
||||
exactly what is implemented.
|
||||
|
||||
It should be noted, that this implementation was taken from the July 2013 blog entry
|
||||
@cite MA13 , which also contained (slightly more general) ready-to-use source code on Python.
|
||||
Subsequently, that code was rewritten on C++ with the usage of openCV by Vadim Pisarevsky at the end
|
||||
of July 2013 and finally it was slightly adapted by later authors.
|
||||
|
||||
Although the thorough discussion and justification of the algorithm involved may be found in
|
||||
@cite ChambolleEtAl, it might make sense to skim over it here, following @cite MA13 . To begin
|
||||
with, we consider the 1-byte gray-level images as the functions from the rectangular domain of
|
||||
pixels (it may be seen as set
|
||||
\f$\left\{(x,y)\in\mathbb{N}\times\mathbb{N}\mid 1\leq x\leq n,\;1\leq y\leq m\right\}\f$ for some
|
||||
\f$m,\;n\in\mathbb{N}\f$) into \f$\{0,1,\dots,255\}\f$. We shall denote the noised images as \f$f_i\f$ and with
|
||||
this view, given some image \f$x\f$ of the same size, we may measure how bad it is by the formula
|
||||
|
||||
\f[\left\|\left\|\nabla x\right\|\right\| + \lambda\sum_i\left\|\left\|x-f_i\right\|\right\|\f]
|
||||
|
||||
\f$\|\|\cdot\|\|\f$ here denotes \f$L_2\f$-norm and as you see, the first addend states that we want our
|
||||
image to be smooth (ideally, having zero gradient, thus being constant) and the second states that
|
||||
we want our result to be close to the observations we've got. If we treat \f$x\f$ as a function, this is
|
||||
exactly the functional what we seek to minimize and here the Primal-Dual algorithm comes into play.
|
||||
|
||||
@param observations This array should contain one or more noised versions of the image that is to
|
||||
be restored.
|
||||
@param result Here the denoised image will be stored. There is no need to do pre-allocation of
|
||||
storage space, as it will be automatically allocated, if necessary.
|
||||
@param lambda Corresponds to \f$\lambda\f$ in the formulas above. As it is enlarged, the smooth
|
||||
(blurred) images are treated more favorably than detailed (but maybe more noised) ones. Roughly
|
||||
speaking, as it becomes smaller, the result will be more blur but more sever outliers will be
|
||||
removed.
|
||||
@param niters Number of iterations that the algorithm will run. Of course, as more iterations as
|
||||
better, but it is hard to quantitatively refine this statement, so just use the default and
|
||||
increase it if the results are poor.
|
||||
*/
|
||||
CV_EXPORTS_W void denoise_TVL1(const std::vector<Mat>& observations,Mat& result, double lambda=1.0, int niters=30);
|
||||
|
||||
//! @} photo_denoise
|
||||
|
||||
//! @addtogroup photo_hdr
|
||||
//! @{
|
||||
|
||||
enum { LDR_SIZE = 256 };
|
||||
|
||||
/** @brief Base class for tonemapping algorithms - tools that are used to map HDR image to 8-bit range.
|
||||
*/
|
||||
class CV_EXPORTS_W Tonemap : public Algorithm
|
||||
{
|
||||
public:
|
||||
/** @brief Tonemaps image
|
||||
|
||||
@param src source image - CV_32FC3 Mat (float 32 bits 3 channels)
|
||||
@param dst destination image - CV_32FC3 Mat with values in [0, 1] range
|
||||
*/
|
||||
CV_WRAP virtual void process(InputArray src, OutputArray dst) = 0;
|
||||
|
||||
CV_WRAP virtual float getGamma() const = 0;
|
||||
CV_WRAP virtual void setGamma(float gamma) = 0;
|
||||
};
|
||||
|
||||
/** @brief Creates simple linear mapper with gamma correction
|
||||
|
||||
@param gamma positive value for gamma correction. Gamma value of 1.0 implies no correction, gamma
|
||||
equal to 2.2f is suitable for most displays.
|
||||
Generally gamma \> 1 brightens the image and gamma \< 1 darkens it.
|
||||
*/
|
||||
CV_EXPORTS_W Ptr<Tonemap> createTonemap(float gamma = 1.0f);
|
||||
|
||||
/** @brief Adaptive logarithmic mapping is a fast global tonemapping algorithm that scales the image in
|
||||
logarithmic domain.
|
||||
|
||||
Since it's a global operator the same function is applied to all the pixels, it is controlled by the
|
||||
bias parameter.
|
||||
|
||||
Optional saturation enhancement is possible as described in @cite FL02 .
|
||||
|
||||
For more information see @cite DM03 .
|
||||
*/
|
||||
class CV_EXPORTS_W TonemapDrago : public Tonemap
|
||||
{
|
||||
public:
|
||||
|
||||
CV_WRAP virtual float getSaturation() const = 0;
|
||||
CV_WRAP virtual void setSaturation(float saturation) = 0;
|
||||
|
||||
CV_WRAP virtual float getBias() const = 0;
|
||||
CV_WRAP virtual void setBias(float bias) = 0;
|
||||
};
|
||||
|
||||
/** @brief Creates TonemapDrago object
|
||||
|
||||
@param gamma gamma value for gamma correction. See createTonemap
|
||||
@param saturation positive saturation enhancement value. 1.0 preserves saturation, values greater
|
||||
than 1 increase saturation and values less than 1 decrease it.
|
||||
@param bias value for bias function in [0, 1] range. Values from 0.7 to 0.9 usually give best
|
||||
results, default value is 0.85.
|
||||
*/
|
||||
CV_EXPORTS_W Ptr<TonemapDrago> createTonemapDrago(float gamma = 1.0f, float saturation = 1.0f, float bias = 0.85f);
|
||||
|
||||
|
||||
/** @brief This is a global tonemapping operator that models human visual system.
|
||||
|
||||
Mapping function is controlled by adaptation parameter, that is computed using light adaptation and
|
||||
color adaptation.
|
||||
|
||||
For more information see @cite RD05 .
|
||||
*/
|
||||
class CV_EXPORTS_W TonemapReinhard : public Tonemap
|
||||
{
|
||||
public:
|
||||
CV_WRAP virtual float getIntensity() const = 0;
|
||||
CV_WRAP virtual void setIntensity(float intensity) = 0;
|
||||
|
||||
CV_WRAP virtual float getLightAdaptation() const = 0;
|
||||
CV_WRAP virtual void setLightAdaptation(float light_adapt) = 0;
|
||||
|
||||
CV_WRAP virtual float getColorAdaptation() const = 0;
|
||||
CV_WRAP virtual void setColorAdaptation(float color_adapt) = 0;
|
||||
};
|
||||
|
||||
/** @brief Creates TonemapReinhard object
|
||||
|
||||
@param gamma gamma value for gamma correction. See createTonemap
|
||||
@param intensity result intensity in [-8, 8] range. Greater intensity produces brighter results.
|
||||
@param light_adapt light adaptation in [0, 1] range. If 1 adaptation is based only on pixel
|
||||
value, if 0 it's global, otherwise it's a weighted mean of this two cases.
|
||||
@param color_adapt chromatic adaptation in [0, 1] range. If 1 channels are treated independently,
|
||||
if 0 adaptation level is the same for each channel.
|
||||
*/
|
||||
CV_EXPORTS_W Ptr<TonemapReinhard>
|
||||
createTonemapReinhard(float gamma = 1.0f, float intensity = 0.0f, float light_adapt = 1.0f, float color_adapt = 0.0f);
|
||||
|
||||
/** @brief This algorithm transforms image to contrast using gradients on all levels of gaussian pyramid,
|
||||
transforms contrast values to HVS response and scales the response. After this the image is
|
||||
reconstructed from new contrast values.
|
||||
|
||||
For more information see @cite MM06 .
|
||||
*/
|
||||
class CV_EXPORTS_W TonemapMantiuk : public Tonemap
|
||||
{
|
||||
public:
|
||||
CV_WRAP virtual float getScale() const = 0;
|
||||
CV_WRAP virtual void setScale(float scale) = 0;
|
||||
|
||||
CV_WRAP virtual float getSaturation() const = 0;
|
||||
CV_WRAP virtual void setSaturation(float saturation) = 0;
|
||||
};
|
||||
|
||||
/** @brief Creates TonemapMantiuk object
|
||||
|
||||
@param gamma gamma value for gamma correction. See createTonemap
|
||||
@param scale contrast scale factor. HVS response is multiplied by this parameter, thus compressing
|
||||
dynamic range. Values from 0.6 to 0.9 produce best results.
|
||||
@param saturation saturation enhancement value. See createTonemapDrago
|
||||
*/
|
||||
CV_EXPORTS_W Ptr<TonemapMantiuk>
|
||||
createTonemapMantiuk(float gamma = 1.0f, float scale = 0.7f, float saturation = 1.0f);
|
||||
|
||||
/** @brief The base class for algorithms that align images of the same scene with different exposures
|
||||
*/
|
||||
class CV_EXPORTS_W AlignExposures : public Algorithm
|
||||
{
|
||||
public:
|
||||
/** @brief Aligns images
|
||||
|
||||
@param src vector of input images
|
||||
@param dst vector of aligned images
|
||||
@param times vector of exposure time values for each image
|
||||
@param response 256x1 matrix with inverse camera response function for each pixel value, it should
|
||||
have the same number of channels as images.
|
||||
*/
|
||||
CV_WRAP virtual void process(InputArrayOfArrays src, std::vector<Mat>& dst,
|
||||
InputArray times, InputArray response) = 0;
|
||||
};
|
||||
|
||||
/** @brief This algorithm converts images to median threshold bitmaps (1 for pixels brighter than median
|
||||
luminance and 0 otherwise) and than aligns the resulting bitmaps using bit operations.
|
||||
|
||||
It is invariant to exposure, so exposure values and camera response are not necessary.
|
||||
|
||||
In this implementation new image regions are filled with zeros.
|
||||
|
||||
For more information see @cite GW03 .
|
||||
*/
|
||||
class CV_EXPORTS_W AlignMTB : public AlignExposures
|
||||
{
|
||||
public:
|
||||
CV_WRAP virtual void process(InputArrayOfArrays src, std::vector<Mat>& dst,
|
||||
InputArray times, InputArray response) CV_OVERRIDE = 0;
|
||||
|
||||
/** @brief Short version of process, that doesn't take extra arguments.
|
||||
|
||||
@param src vector of input images
|
||||
@param dst vector of aligned images
|
||||
*/
|
||||
CV_WRAP virtual void process(InputArrayOfArrays src, std::vector<Mat>& dst) = 0;
|
||||
|
||||
/** @brief Calculates shift between two images, i. e. how to shift the second image to correspond it with the
|
||||
first.
|
||||
|
||||
@param img0 first image
|
||||
@param img1 second image
|
||||
*/
|
||||
CV_WRAP virtual Point calculateShift(InputArray img0, InputArray img1) = 0;
|
||||
/** @brief Helper function, that shift Mat filling new regions with zeros.
|
||||
|
||||
@param src input image
|
||||
@param dst result image
|
||||
@param shift shift value
|
||||
*/
|
||||
CV_WRAP virtual void shiftMat(InputArray src, OutputArray dst, const Point shift) = 0;
|
||||
/** @brief Computes median threshold and exclude bitmaps of given image.
|
||||
|
||||
@param img input image
|
||||
@param tb median threshold bitmap
|
||||
@param eb exclude bitmap
|
||||
*/
|
||||
CV_WRAP virtual void computeBitmaps(InputArray img, OutputArray tb, OutputArray eb) = 0;
|
||||
|
||||
CV_WRAP virtual int getMaxBits() const = 0;
|
||||
CV_WRAP virtual void setMaxBits(int max_bits) = 0;
|
||||
|
||||
CV_WRAP virtual int getExcludeRange() const = 0;
|
||||
CV_WRAP virtual void setExcludeRange(int exclude_range) = 0;
|
||||
|
||||
CV_WRAP virtual bool getCut() const = 0;
|
||||
CV_WRAP virtual void setCut(bool value) = 0;
|
||||
};
|
||||
|
||||
/** @brief Creates AlignMTB object
|
||||
|
||||
@param max_bits logarithm to the base 2 of maximal shift in each dimension. Values of 5 and 6 are
|
||||
usually good enough (31 and 63 pixels shift respectively).
|
||||
@param exclude_range range for exclusion bitmap that is constructed to suppress noise around the
|
||||
median value.
|
||||
@param cut if true cuts images, otherwise fills the new regions with zeros.
|
||||
*/
|
||||
CV_EXPORTS_W Ptr<AlignMTB> createAlignMTB(int max_bits = 6, int exclude_range = 4, bool cut = true);
|
||||
|
||||
/** @brief The base class for camera response calibration algorithms.
|
||||
*/
|
||||
class CV_EXPORTS_W CalibrateCRF : public Algorithm
|
||||
{
|
||||
public:
|
||||
/** @brief Recovers inverse camera response.
|
||||
|
||||
@param src vector of input images
|
||||
@param dst 256x1 matrix with inverse camera response function
|
||||
@param times vector of exposure time values for each image
|
||||
*/
|
||||
CV_WRAP virtual void process(InputArrayOfArrays src, OutputArray dst, InputArray times) = 0;
|
||||
};
|
||||
|
||||
/** @brief Inverse camera response function is extracted for each brightness value by minimizing an objective
|
||||
function as linear system. Objective function is constructed using pixel values on the same position
|
||||
in all images, extra term is added to make the result smoother.
|
||||
|
||||
For more information see @cite DM97 .
|
||||
*/
|
||||
class CV_EXPORTS_W CalibrateDebevec : public CalibrateCRF
|
||||
{
|
||||
public:
|
||||
CV_WRAP virtual float getLambda() const = 0;
|
||||
CV_WRAP virtual void setLambda(float lambda) = 0;
|
||||
|
||||
CV_WRAP virtual int getSamples() const = 0;
|
||||
CV_WRAP virtual void setSamples(int samples) = 0;
|
||||
|
||||
CV_WRAP virtual bool getRandom() const = 0;
|
||||
CV_WRAP virtual void setRandom(bool random) = 0;
|
||||
};
|
||||
|
||||
/** @brief Creates CalibrateDebevec object
|
||||
|
||||
@param samples number of pixel locations to use
|
||||
@param lambda smoothness term weight. Greater values produce smoother results, but can alter the
|
||||
response.
|
||||
@param random if true sample pixel locations are chosen at random, otherwise they form a
|
||||
rectangular grid.
|
||||
*/
|
||||
CV_EXPORTS_W Ptr<CalibrateDebevec> createCalibrateDebevec(int samples = 70, float lambda = 10.0f, bool random = false);
|
||||
|
||||
/** @brief Inverse camera response function is extracted for each brightness value by minimizing an objective
|
||||
function as linear system. This algorithm uses all image pixels.
|
||||
|
||||
For more information see @cite RB99 .
|
||||
*/
|
||||
class CV_EXPORTS_W CalibrateRobertson : public CalibrateCRF
|
||||
{
|
||||
public:
|
||||
CV_WRAP virtual int getMaxIter() const = 0;
|
||||
CV_WRAP virtual void setMaxIter(int max_iter) = 0;
|
||||
|
||||
CV_WRAP virtual float getThreshold() const = 0;
|
||||
CV_WRAP virtual void setThreshold(float threshold) = 0;
|
||||
|
||||
CV_WRAP virtual Mat getRadiance() const = 0;
|
||||
};
|
||||
|
||||
/** @brief Creates CalibrateRobertson object
|
||||
|
||||
@param max_iter maximal number of Gauss-Seidel solver iterations.
|
||||
@param threshold target difference between results of two successive steps of the minimization.
|
||||
*/
|
||||
CV_EXPORTS_W Ptr<CalibrateRobertson> createCalibrateRobertson(int max_iter = 30, float threshold = 0.01f);
|
||||
|
||||
/** @brief The base class algorithms that can merge exposure sequence to a single image.
|
||||
*/
|
||||
class CV_EXPORTS_W MergeExposures : public Algorithm
|
||||
{
|
||||
public:
|
||||
/** @brief Merges images.
|
||||
|
||||
@param src vector of input images
|
||||
@param dst result image
|
||||
@param times vector of exposure time values for each image
|
||||
@param response 256x1 matrix with inverse camera response function for each pixel value, it should
|
||||
have the same number of channels as images.
|
||||
*/
|
||||
CV_WRAP virtual void process(InputArrayOfArrays src, OutputArray dst,
|
||||
InputArray times, InputArray response) = 0;
|
||||
};
|
||||
|
||||
/** @brief The resulting HDR image is calculated as weighted average of the exposures considering exposure
|
||||
values and camera response.
|
||||
|
||||
For more information see @cite DM97 .
|
||||
*/
|
||||
class CV_EXPORTS_W MergeDebevec : public MergeExposures
|
||||
{
|
||||
public:
|
||||
CV_WRAP virtual void process(InputArrayOfArrays src, OutputArray dst,
|
||||
InputArray times, InputArray response) CV_OVERRIDE = 0;
|
||||
CV_WRAP virtual void process(InputArrayOfArrays src, OutputArray dst, InputArray times) = 0;
|
||||
};
|
||||
|
||||
/** @brief Creates MergeDebevec object
|
||||
*/
|
||||
CV_EXPORTS_W Ptr<MergeDebevec> createMergeDebevec();
|
||||
|
||||
/** @brief Pixels are weighted using contrast, saturation and well-exposedness measures, than images are
|
||||
combined using laplacian pyramids.
|
||||
|
||||
The resulting image weight is constructed as weighted average of contrast, saturation and
|
||||
well-exposedness measures.
|
||||
|
||||
The resulting image doesn't require tonemapping and can be converted to 8-bit image by multiplying
|
||||
by 255, but it's recommended to apply gamma correction and/or linear tonemapping.
|
||||
|
||||
For more information see @cite MK07 .
|
||||
*/
|
||||
class CV_EXPORTS_W MergeMertens : public MergeExposures
|
||||
{
|
||||
public:
|
||||
CV_WRAP virtual void process(InputArrayOfArrays src, OutputArray dst,
|
||||
InputArray times, InputArray response) CV_OVERRIDE = 0;
|
||||
/** @brief Short version of process, that doesn't take extra arguments.
|
||||
|
||||
@param src vector of input images
|
||||
@param dst result image
|
||||
*/
|
||||
CV_WRAP virtual void process(InputArrayOfArrays src, OutputArray dst) = 0;
|
||||
|
||||
CV_WRAP virtual float getContrastWeight() const = 0;
|
||||
CV_WRAP virtual void setContrastWeight(float contrast_weiht) = 0;
|
||||
|
||||
CV_WRAP virtual float getSaturationWeight() const = 0;
|
||||
CV_WRAP virtual void setSaturationWeight(float saturation_weight) = 0;
|
||||
|
||||
CV_WRAP virtual float getExposureWeight() const = 0;
|
||||
CV_WRAP virtual void setExposureWeight(float exposure_weight) = 0;
|
||||
};
|
||||
|
||||
/** @brief Creates MergeMertens object
|
||||
|
||||
@param contrast_weight contrast measure weight. See MergeMertens.
|
||||
@param saturation_weight saturation measure weight
|
||||
@param exposure_weight well-exposedness measure weight
|
||||
*/
|
||||
CV_EXPORTS_W Ptr<MergeMertens>
|
||||
createMergeMertens(float contrast_weight = 1.0f, float saturation_weight = 1.0f, float exposure_weight = 0.0f);
|
||||
|
||||
/** @brief The resulting HDR image is calculated as weighted average of the exposures considering exposure
|
||||
values and camera response.
|
||||
|
||||
For more information see @cite RB99 .
|
||||
*/
|
||||
class CV_EXPORTS_W MergeRobertson : public MergeExposures
|
||||
{
|
||||
public:
|
||||
CV_WRAP virtual void process(InputArrayOfArrays src, OutputArray dst,
|
||||
InputArray times, InputArray response) CV_OVERRIDE = 0;
|
||||
CV_WRAP virtual void process(InputArrayOfArrays src, OutputArray dst, InputArray times) = 0;
|
||||
};
|
||||
|
||||
/** @brief Creates MergeRobertson object
|
||||
*/
|
||||
CV_EXPORTS_W Ptr<MergeRobertson> createMergeRobertson();
|
||||
|
||||
//! @} photo_hdr
|
||||
|
||||
//! @addtogroup photo_decolor
|
||||
//! @{
|
||||
|
||||
/** @brief Transforms a color image to a grayscale image. It is a basic tool in digital printing, stylized
|
||||
black-and-white photograph rendering, and in many single channel image processing applications
|
||||
@cite CL12 .
|
||||
|
||||
@param src Input 8-bit 3-channel image.
|
||||
@param grayscale Output 8-bit 1-channel image.
|
||||
@param color_boost Output 8-bit 3-channel image.
|
||||
|
||||
This function is to be applied on color images.
|
||||
*/
|
||||
CV_EXPORTS_W void decolor( InputArray src, OutputArray grayscale, OutputArray color_boost);
|
||||
|
||||
//! @} photo_decolor
|
||||
|
||||
//! @addtogroup photo_clone
|
||||
//! @{
|
||||
|
||||
|
||||
//! Flags for the seamlessClone algorithm
|
||||
enum SeamlessCloneFlags
|
||||
{
|
||||
/**
|
||||
@brief Normal seamless cloning.
|
||||
This method is ideal for inserting objects with complex outlines into a new background.
|
||||
It preserves the original appearance and lighting of the inserted object, ensuring a natural blend.
|
||||
*/
|
||||
NORMAL_CLONE = 1,
|
||||
|
||||
/**
|
||||
@brief Mixed seamless cloning.
|
||||
This method addresses cases where simple color-based selection or alpha masking is time-consuming
|
||||
and may result in undesirable halos. By combining structure from the source and texture from the
|
||||
destination, mixed seamless cloning is highly effective, even with loosely defined selections.
|
||||
*/
|
||||
MIXED_CLONE = 2,
|
||||
|
||||
/**
|
||||
@brief Monochrome transfer cloning.
|
||||
This method allows users to replace specific features of an object, such as grayscale textures
|
||||
or patterns, with alternative features. It is particularly useful for artistic effects or
|
||||
targeted object modifications.
|
||||
*/
|
||||
MONOCHROME_TRANSFER = 3,
|
||||
|
||||
/**
|
||||
@brief Enhanced normal seamless cloning.
|
||||
Similar to `NORMAL_CLONE`, but with an advanced approach to ROI (Region of Interest) calculation.
|
||||
This mode processes a larger source region by considering the entire mask area instead of only
|
||||
the bounding rectangle of non-zero pixels.
|
||||
*/
|
||||
NORMAL_CLONE_WIDE = 9,
|
||||
|
||||
/**
|
||||
@brief Enhanced mixed seamless cloning.
|
||||
Similar to `MIXED_CLONE`, but with an advanced approach to ROI (Region of Interest) calculation.
|
||||
This mode processes a larger source region by considering the entire mask area instead of only
|
||||
the bounding rectangle of non-zero pixels.
|
||||
*/
|
||||
MIXED_CLONE_WIDE = 10,
|
||||
|
||||
/**
|
||||
@brief Enhanced monochrome transfer cloning.
|
||||
Similar to `MONOCHROME_TRANSFER`, but with an advanced approach to ROI (Region of Interest) calculation.
|
||||
This mode processes a larger source region by considering the entire mask area instead of only
|
||||
the bounding rectangle of non-zero pixels.
|
||||
*/
|
||||
MONOCHROME_TRANSFER_WIDE = 11
|
||||
};
|
||||
|
||||
|
||||
/** @example samples/cpp/tutorial_code/photo/seamless_cloning/cloning_demo.cpp
|
||||
An example using seamlessClone function
|
||||
*/
|
||||
/** @example samples/cpp/snippets/cloning_demo.cpp
|
||||
An example using illuminationChange, colorChange, seamlessClone, textureFlattening functions
|
||||
*/
|
||||
/** @brief Performs seamless cloning to blend a region from a source image into a destination image.
|
||||
This function is designed for local image editing, allowing changes restricted to a region
|
||||
(manually selected as the ROI) to be applied effortlessly and seamlessly. These changes can
|
||||
range from slight distortions to complete replacement by novel content @cite PM03.
|
||||
|
||||
@param src The source image (8-bit 3-channel), from which a region will be blended into the destination.
|
||||
@param dst The destination image (8-bit 3-channel), where the src image will be blended.
|
||||
@param mask A binary mask (8-bit, 1, 3, or 4-channel) specifying the region in the source image to blend.
|
||||
Non-zero pixels indicate the region to be blended. If an empty Mat is provided, a mask with
|
||||
all non-zero pixels is created internally.
|
||||
@param p The point where the center of the src image is placed in the dst image.
|
||||
@param blend The output image that stores the result of the seamless cloning. It has the same size and type as `dst`.
|
||||
@param flags Flags that control the type of cloning method, can take values of `cv::SeamlessCloneFlags`.
|
||||
*/
|
||||
CV_EXPORTS_W void seamlessClone( InputArray src, InputArray dst, InputArray mask, Point p,
|
||||
OutputArray blend, int flags);
|
||||
|
||||
/** @brief Given an original color image, two differently colored versions of this image can be mixed
|
||||
seamlessly.
|
||||
|
||||
@param src Input 8-bit 3-channel image.
|
||||
@param mask Input 8-bit 1 or 3-channel image.
|
||||
@param dst Output image with the same size and type as src .
|
||||
@param red_mul R-channel multiply factor.
|
||||
@param green_mul G-channel multiply factor.
|
||||
@param blue_mul B-channel multiply factor.
|
||||
|
||||
Multiplication factor is between .5 to 2.5.
|
||||
*/
|
||||
CV_EXPORTS_W void colorChange(InputArray src, InputArray mask, OutputArray dst, float red_mul = 1.0f,
|
||||
float green_mul = 1.0f, float blue_mul = 1.0f);
|
||||
|
||||
/** @brief Applying an appropriate non-linear transformation to the gradient field inside the selection and
|
||||
then integrating back with a Poisson solver, modifies locally the apparent illumination of an image.
|
||||
|
||||
@param src Input 8-bit 3-channel image.
|
||||
@param mask Input 8-bit 1 or 3-channel image.
|
||||
@param dst Output image with the same size and type as src.
|
||||
@param alpha Value ranges between 0-2.
|
||||
@param beta Value ranges between 0-2.
|
||||
|
||||
This is useful to highlight under-exposed foreground objects or to reduce specular reflections.
|
||||
*/
|
||||
CV_EXPORTS_W void illuminationChange(InputArray src, InputArray mask, OutputArray dst,
|
||||
float alpha = 0.2f, float beta = 0.4f);
|
||||
|
||||
/** @brief By retaining only the gradients at edge locations, before integrating with the Poisson solver, one
|
||||
washes out the texture of the selected region, giving its contents a flat aspect. Here Canny Edge %Detector is used.
|
||||
|
||||
@param src Input 8-bit 3-channel image.
|
||||
@param mask Input 8-bit 1 or 3-channel image.
|
||||
@param dst Output image with the same size and type as src.
|
||||
@param low_threshold %Range from 0 to 100.
|
||||
@param high_threshold Value \> 100.
|
||||
@param kernel_size The size of the Sobel kernel to be used.
|
||||
|
||||
@note
|
||||
The algorithm assumes that the color of the source image is close to that of the destination. This
|
||||
assumption means that when the colors don't match, the source image color gets tinted toward the
|
||||
color of the destination image.
|
||||
*/
|
||||
CV_EXPORTS_W void textureFlattening(InputArray src, InputArray mask, OutputArray dst,
|
||||
float low_threshold = 30, float high_threshold = 45,
|
||||
int kernel_size = 3);
|
||||
|
||||
//! @} photo_clone
|
||||
|
||||
//! @addtogroup photo_render
|
||||
//! @{
|
||||
|
||||
//! Edge preserving filters
|
||||
enum
|
||||
{
|
||||
RECURS_FILTER = 1, //!< Recursive Filtering
|
||||
NORMCONV_FILTER = 2 //!< Normalized Convolution Filtering
|
||||
};
|
||||
|
||||
/** @brief Filtering is the fundamental operation in image and video processing. Edge-preserving smoothing
|
||||
filters are used in many different applications @cite EM11 .
|
||||
|
||||
@param src Input 8-bit 3-channel image.
|
||||
@param dst Output 8-bit 3-channel image.
|
||||
@param flags Edge preserving filters: cv::RECURS_FILTER or cv::NORMCONV_FILTER
|
||||
@param sigma_s %Range between 0 to 200.
|
||||
@param sigma_r %Range between 0 to 1.
|
||||
*/
|
||||
CV_EXPORTS_W void edgePreservingFilter(InputArray src, OutputArray dst, int flags = 1,
|
||||
float sigma_s = 60, float sigma_r = 0.4f);
|
||||
|
||||
/** @brief This filter enhances the details of a particular image.
|
||||
|
||||
@param src Input 8-bit 3-channel image.
|
||||
@param dst Output image with the same size and type as src.
|
||||
@param sigma_s %Range between 0 to 200.
|
||||
@param sigma_r %Range between 0 to 1.
|
||||
*/
|
||||
CV_EXPORTS_W void detailEnhance(InputArray src, OutputArray dst, float sigma_s = 10,
|
||||
float sigma_r = 0.15f);
|
||||
|
||||
/** @example samples/cpp/tutorial_code/photo/non_photorealistic_rendering/npr_demo.cpp
|
||||
An example using non-photorealistic line drawing functions
|
||||
*/
|
||||
/** @brief Pencil-like non-photorealistic line drawing
|
||||
|
||||
@param src Input 8-bit 3-channel image.
|
||||
@param dst1 Output 8-bit 1-channel image.
|
||||
@param dst2 Output image with the same size and type as src.
|
||||
@param sigma_s %Range between 0 to 200.
|
||||
@param sigma_r %Range between 0 to 1.
|
||||
@param shade_factor %Range between 0 to 0.1.
|
||||
*/
|
||||
CV_EXPORTS_W void pencilSketch(InputArray src, OutputArray dst1, OutputArray dst2,
|
||||
float sigma_s = 60, float sigma_r = 0.07f, float shade_factor = 0.02f);
|
||||
|
||||
/** @brief Stylization aims to produce digital imagery with a wide variety of effects not focused on
|
||||
photorealism. Edge-aware filters are ideal for stylization, as they can abstract regions of low
|
||||
contrast while preserving, or enhancing, high-contrast features.
|
||||
|
||||
@param src Input 8-bit 3-channel image.
|
||||
@param dst Output image with the same size and type as src.
|
||||
@param sigma_s %Range between 0 to 200.
|
||||
@param sigma_r %Range between 0 to 1.
|
||||
*/
|
||||
CV_EXPORTS_W void stylization(InputArray src, OutputArray dst, float sigma_s = 60,
|
||||
float sigma_r = 0.45f);
|
||||
|
||||
//! @} photo_render
|
||||
|
||||
//! @addtogroup photo_ca_correction Chromatic Aberration Correction
|
||||
//! @{
|
||||
|
||||
/** @example samples/cpp/snippets/chromatic_aberration_correction.cpp
|
||||
An example correcting chromatic aberration with C++
|
||||
*/
|
||||
/** @example samples/python/snippets/chromatic_aberration_correction.py
|
||||
* An example correcting chromatic aberration with Python
|
||||
*/
|
||||
/** @brief Corrects lateral chromatic aberration in an image using polynomial distortion model.
|
||||
|
||||
This function loads polynomial calibration data from the specified file and applies
|
||||
a channel‐specific warp to remove chromatic aberration.
|
||||
If @p input_image has one channel, it is assumed to be a raw Bayer image and is
|
||||
first demosaiced using @p bayer_pattern. If it has three channels, it is treated
|
||||
as a BGR image and @p bayer_pattern is ignored.
|
||||
|
||||
Firstly, calibration needs to be done using apps/chromatic-aberration-calibration/ca_calibration.py on a photo of
|
||||
a pattern of black discs on white background, included in opencv_extra/testdata/cv/cameracalibration/chromatic_aberration/chromatic_aberration_pattern_a3.png
|
||||
|
||||
Calibration and correction are based on the algorithm described in @cite rudakova2013precise.
|
||||
The chromatic aberration is modeled as a polynomial of some degree in red and blue channels compared to green.
|
||||
In calibration, a photo of many black discs on white background is used, and the displacements
|
||||
between the centres of discs in red and blue channels compared to green are minimized. The coefficients
|
||||
are then saved in a yaml file which can be used with this function to correct lateral chromatic aberration.
|
||||
|
||||
@param input_image Input BGR image to correct
|
||||
@param coefficients Coefficient model
|
||||
@param output_image Corrected BGR image
|
||||
@param image_size Size of images for the calibration coefficient model
|
||||
@param calib_degree Degree of the calibration coefficient model
|
||||
@param bayer_pattern Bayer pattern code (e.g. cv::COLOR_BayerBG2BGR) used for
|
||||
demosaicing when @p input_image has one channel; ignored otherwise.
|
||||
|
||||
@sa loadChromaticAberrationParams, demosaicing
|
||||
*/
|
||||
CV_EXPORTS_W void correctChromaticAberration(InputArray input_image, InputArray coefficients, OutputArray output_image,
|
||||
const Size& image_size, int calib_degree, int bayer_pattern = -1);
|
||||
|
||||
/** @brief Load chromatic-aberration calibration parameters from opened FileStorage.
|
||||
*
|
||||
R e*ads the red and blue polynomial coefficients from the specified file and
|
||||
packs them into a 4×N CV_32F matrix:
|
||||
row 0 = blue dx coefficients
|
||||
row 1 = blue dy coefficients
|
||||
row 2 = red dx coefficients
|
||||
row 3 = red dy coefficients
|
||||
|
||||
@param node Node of opened cv::FileStorage object.
|
||||
@param coeffMat Output 4xN coefficient matrix (CV_32F).
|
||||
@param degree Polynomial degree inferred from N.
|
||||
@param calib_size Calibration image size read from file.
|
||||
|
||||
@sa correctChromaticAberration
|
||||
*/
|
||||
CV_EXPORTS_W void loadChromaticAberrationParams(
|
||||
const FileNode& node,
|
||||
OutputArray coeffMat,
|
||||
CV_OUT Size& calib_size,
|
||||
CV_OUT int& degree);
|
||||
|
||||
//! @} photo_ca_correction
|
||||
|
||||
//! @} photo
|
||||
|
||||
} // cv
|
||||
|
||||
#include "./photo/segmentation.hpp"
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,322 @@
|
||||
// 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.
|
||||
//
|
||||
// Author: Longbu Wang <wanglongbu@huawei.com.com>
|
||||
// Jinheng Zhang <zhangjinheng1@huawei.com>
|
||||
// Chenqi Shan <shanchenqi@huawei.com>
|
||||
|
||||
#ifndef OPENCV_PHOTO_CCM_HPP
|
||||
#define OPENCV_PHOTO_CCM_HPP
|
||||
|
||||
#include <opencv2/core.hpp>
|
||||
#include <opencv2/imgproc.hpp>
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace ccm
|
||||
{
|
||||
|
||||
/** @defgroup ccm Color Correction module
|
||||
@{
|
||||
*/
|
||||
|
||||
/** @brief Enum of the possible types of ccm.
|
||||
*/
|
||||
enum CcmType
|
||||
{
|
||||
CCM_LINEAR, ///< Uses a \f$3\times3\f$ matrix to linearly transform RGB values without offsets.
|
||||
CCM_AFFINE, ///< Uses a \f$4\times3\f$ matrix to affine transform RGB values with both scaling and offset terms.
|
||||
};
|
||||
|
||||
/** @brief Enum of the possible types of initial method.
|
||||
*/
|
||||
enum InitialMethodType
|
||||
{
|
||||
INITIAL_METHOD_WHITE_BALANCE, ///< The white balance method. The initial value is:\n
|
||||
/// \f$
|
||||
/// M_{CCM}=
|
||||
/// \begin{bmatrix}
|
||||
/// k_R & 0 & 0\\
|
||||
/// 0 & k_G & 0\\
|
||||
/// 0 & 0 & k_B\\
|
||||
/// \end{bmatrix}
|
||||
/// \f$\n
|
||||
/// where\n
|
||||
/// \f$
|
||||
/// k_R=mean(R_{li}')/mean(R_{li})\\
|
||||
/// k_G=mean(G_{li}')/mean(G_{li})\\
|
||||
/// k_B=mean(B_{li}')/mean(B_{li})
|
||||
/// \f$
|
||||
INITIAL_METHOD_LEAST_SQUARE, ///< The least square method is an optimal solution under the linear RGB distance function
|
||||
};
|
||||
/** @brief Macbeth and Vinyl ColorChecker with 2deg D50
|
||||
*/
|
||||
enum ColorCheckerType {
|
||||
COLORCHECKER_MACBETH, ///< Macbeth ColorChecker
|
||||
COLORCHECKER_VINYL, ///< DKK ColorChecker
|
||||
COLORCHECKER_DIGITAL_SG, ///< DigitalSG ColorChecker with 140 squares
|
||||
};
|
||||
enum ColorSpace {
|
||||
COLOR_SPACE_SRGB, ///< https://en.wikipedia.org/wiki/SRGB , RGB color space
|
||||
COLOR_SPACE_SRGBL, ///< https://en.wikipedia.org/wiki/SRGB , linear RGB color space
|
||||
COLOR_SPACE_ADOBE_RGB, ///< https://en.wikipedia.org/wiki/Adobe_RGB_color_space , RGB color space
|
||||
COLOR_SPACE_ADOBE_RGBL, ///< https://en.wikipedia.org/wiki/Adobe_RGB_color_space , linear RGB color space
|
||||
COLOR_SPACE_WIDE_GAMUT_RGB, ///< https://en.wikipedia.org/wiki/Wide-gamut_RGB_color_space , RGB color space
|
||||
COLOR_SPACE_WIDE_GAMUT_RGBL, ///< https://en.wikipedia.org/wiki/Wide-gamut_RGB_color_space , linear RGB color space
|
||||
COLOR_SPACE_PRO_PHOTO_RGB, ///< https://en.wikipedia.org/wiki/ProPhoto_RGB_color_space , RGB color space
|
||||
COLOR_SPACE_PRO_PHOTO_RGBL, ///< https://en.wikipedia.org/wiki/ProPhoto_RGB_color_space , linear RGB color space
|
||||
COLOR_SPACE_DCI_P3_RGB, ///< https://en.wikipedia.org/wiki/DCI-P3 , RGB color space
|
||||
COLOR_SPACE_DCI_P3_RGBL, ///< https://en.wikipedia.org/wiki/DCI-P3 , linear RGB color space
|
||||
COLOR_SPACE_APPLE_RGB, ///< http://www.brucelindbloom.com/index.html?WorkingSpaceInfo.html , RGB color space
|
||||
COLOR_SPACE_APPLE_RGBL, ///< http://www.brucelindbloom.com/index.html?WorkingSpaceInfo.html , linear RGB color space
|
||||
COLOR_SPACE_REC_709_RGB, ///< https://en.wikipedia.org/wiki/Rec._709 , RGB color space
|
||||
COLOR_SPACE_REC_709_RGBL, ///< https://en.wikipedia.org/wiki/Rec._709 , linear RGB color space
|
||||
COLOR_SPACE_REC_2020_RGB, ///< https://en.wikipedia.org/wiki/Rec._2020 , RGB color space
|
||||
COLOR_SPACE_REC_2020_RGBL, ///< https://en.wikipedia.org/wiki/Rec._2020 , linear RGB color space
|
||||
COLOR_SPACE_XYZ_D65_2, ///< https://en.wikipedia.org/wiki/CIE_1931_color_space , XYZ color space, D65 illuminant, 2 degree
|
||||
COLOR_SPACE_XYZ_D50_2, ///< https://en.wikipedia.org/wiki/CIE_1931_color_space , XYZ color space, D50 illuminant, 2 degree
|
||||
COLOR_SPACE_XYZ_D65_10, ///< https://en.wikipedia.org/wiki/CIE_1931_color_space , XYZ color space, D65 illuminant, 10 degree
|
||||
COLOR_SPACE_XYZ_D50_10, ///< https://en.wikipedia.org/wiki/CIE_1931_color_space , XYZ color space, D50 illuminant, 10 degree
|
||||
COLOR_SPACE_XYZ_A_2, ///< https://en.wikipedia.org/wiki/CIE_1931_color_space , XYZ color space, A illuminant, 2 degree
|
||||
COLOR_SPACE_XYZ_A_10, ///< https://en.wikipedia.org/wiki/CIE_1931_color_space , XYZ color space, A illuminant, 10 degree
|
||||
COLOR_SPACE_XYZ_D55_2, ///< https://en.wikipedia.org/wiki/CIE_1931_color_space , XYZ color space, D55 illuminant, 2 degree
|
||||
COLOR_SPACE_XYZ_D55_10, ///< https://en.wikipedia.org/wiki/CIE_1931_color_space , XYZ color space, D55 illuminant, 10 degree
|
||||
COLOR_SPACE_XYZ_D75_2, ///< https://en.wikipedia.org/wiki/CIE_1931_color_space , XYZ color space, D75 illuminant, 2 degree
|
||||
COLOR_SPACE_XYZ_D75_10, ///< https://en.wikipedia.org/wiki/CIE_1931_color_space , XYZ color space, D75 illuminant, 10 degree
|
||||
COLOR_SPACE_XYZ_E_2, ///< https://en.wikipedia.org/wiki/CIE_1931_color_space , XYZ color space, E illuminant, 2 degree
|
||||
COLOR_SPACE_XYZ_E_10, ///< https://en.wikipedia.org/wiki/CIE_1931_color_space , XYZ color space, E illuminant, 10 degree
|
||||
COLOR_SPACE_LAB_D65_2, ///< https://en.wikipedia.org/wiki/CIELAB_color_space , Lab color space, D65 illuminant, 2 degree
|
||||
COLOR_SPACE_LAB_D50_2, ///< https://en.wikipedia.org/wiki/CIELAB_color_space , Lab color space, D50 illuminant, 2 degree
|
||||
COLOR_SPACE_LAB_D65_10, ///< https://en.wikipedia.org/wiki/CIELAB_color_space , Lab color space, D65 illuminant, 10 degree
|
||||
COLOR_SPACE_LAB_D50_10, ///< https://en.wikipedia.org/wiki/CIELAB_color_space , Lab color space, D50 illuminant, 10 degree
|
||||
COLOR_SPACE_LAB_A_2, ///< https://en.wikipedia.org/wiki/CIELAB_color_space , Lab color space, A illuminant, 2 degree
|
||||
COLOR_SPACE_LAB_A_10, ///< https://en.wikipedia.org/wiki/CIELAB_color_space , Lab color space, A illuminant, 10 degree
|
||||
COLOR_SPACE_LAB_D55_2, ///< https://en.wikipedia.org/wiki/CIELAB_color_space , Lab color space, D55 illuminant, 2 degree
|
||||
COLOR_SPACE_LAB_D55_10, ///< https://en.wikipedia.org/wiki/CIELAB_color_space , Lab color space, D55 illuminant, 10 degree
|
||||
COLOR_SPACE_LAB_D75_2, ///< https://en.wikipedia.org/wiki/CIELAB_color_space , Lab color space, D75 illuminant, 2 degree
|
||||
COLOR_SPACE_LAB_D75_10, ///< https://en.wikipedia.org/wiki/CIELAB_color_space , Lab color space, D75 illuminant, 10 degree
|
||||
COLOR_SPACE_LAB_E_2, ///< https://en.wikipedia.org/wiki/CIELAB_color_space , Lab color space, E illuminant, 2 degree
|
||||
COLOR_SPACE_LAB_E_10 ///< https://en.wikipedia.org/wiki/CIELAB_color_space , Lab color space, E illuminant, 10 degree
|
||||
};
|
||||
|
||||
/** @brief Linearization transformation type
|
||||
*/
|
||||
enum LinearizationType
|
||||
{
|
||||
|
||||
LINEARIZATION_IDENTITY, ///<no change is made
|
||||
LINEARIZATION_GAMMA, ///<gamma correction; Need assign a value to gamma simultaneously
|
||||
LINEARIZATION_COLORPOLYFIT, ///<polynomial fitting channels respectively; Need assign a value to deg simultaneously
|
||||
LINEARIZATION_COLORLOGPOLYFIT, ///<logarithmic polynomial fitting channels respectively; Need assign a value to deg simultaneously
|
||||
LINEARIZATION_GRAYPOLYFIT, ///<grayscale polynomial fitting; Need assign a value to deg and dst_whites simultaneously
|
||||
LINEARIZATION_GRAYLOGPOLYFIT ///<grayscale Logarithmic polynomial fitting; Need assign a value to deg and dst_whites simultaneously
|
||||
};
|
||||
|
||||
/** @brief Enum of possible functions to calculate the distance between colors.
|
||||
|
||||
See https://en.wikipedia.org/wiki/Color_difference for details
|
||||
*/
|
||||
enum DistanceType
|
||||
{
|
||||
DISTANCE_CIE76, ///<The 1976 formula is the first formula that related a measured color difference to a known set of CIELAB coordinates.
|
||||
DISTANCE_CIE94_GRAPHIC_ARTS, ///<The 1976 definition was extended to address perceptual non-uniformities.
|
||||
DISTANCE_CIE94_TEXTILES,
|
||||
DISTANCE_CIE2000,
|
||||
DISTANCE_CMC_1TO1, ///<In 1984, the Colour Measurement Committee of the Society of Dyers and Colourists defined a difference measure, also based on the L*C*h color model.
|
||||
DISTANCE_CMC_2TO1,
|
||||
DISTANCE_RGB, ///<Euclidean distance of rgb color space
|
||||
DISTANCE_RGBL ///<Euclidean distance of rgbl color space
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Applies gamma correction to the input image.
|
||||
* @param src Input image.
|
||||
* @param dst Output image.
|
||||
* @param gamma Gamma correction greater than zero.
|
||||
*/
|
||||
CV_EXPORTS_W void gammaCorrection(InputArray src, OutputArray dst, double gamma);
|
||||
|
||||
/** @brief Core class of ccm model
|
||||
|
||||
Produce a ColorCorrectionModel instance for inference
|
||||
*/
|
||||
class CV_EXPORTS_W ColorCorrectionModel
|
||||
{
|
||||
public:
|
||||
CV_WRAP ColorCorrectionModel();
|
||||
|
||||
/** @brief Color Correction Model
|
||||
|
||||
Supported list of color cards:
|
||||
- @ref COLORCHECKER_MACBETH, the Macbeth ColorChecker
|
||||
- @ref COLORCHECKER_VINYL, the DKK ColorChecker
|
||||
- @ref COLORCHECKER_DIGITAL_SG, the DigitalSG ColorChecker with 140 squares
|
||||
|
||||
@param src detected colors of ColorChecker patches;
|
||||
the color type is RGB not BGR, and the color values are in [0, 1];
|
||||
@param constColor the Built-in color card
|
||||
*/
|
||||
CV_WRAP ColorCorrectionModel(InputArray src, int constColor);
|
||||
|
||||
/** @brief Color Correction Model
|
||||
@param src detected colors of ColorChecker patches;
|
||||
the color type is RGB not BGR, and the color values are in [0, 1];
|
||||
@param colors the reference color values, the color values are in [0, 1].
|
||||
@param refColorSpace the corresponding color space
|
||||
If the color type is some RGB, the format is RGB not BGR;
|
||||
*/
|
||||
CV_WRAP ColorCorrectionModel(InputArray src, InputArray colors, ColorSpace refColorSpace);
|
||||
|
||||
/** @brief Color Correction Model
|
||||
@param src detected colors of ColorChecker patches;
|
||||
the color type is RGB not BGR, and the color values are in [0, 1];
|
||||
@param colors the reference color values, the color values are in [0, 1].
|
||||
@param refColorSpace the corresponding color space
|
||||
If the color type is some RGB, the format is RGB not BGR;
|
||||
@param coloredPatchesMask binary mask indicating which patches are colored (non-gray) patches
|
||||
*/
|
||||
CV_WRAP ColorCorrectionModel(InputArray src, InputArray colors, ColorSpace refColorSpace, InputArray coloredPatchesMask);
|
||||
|
||||
/** @brief set ColorSpace
|
||||
@note It should be some RGB color space;
|
||||
Supported list of color cards:
|
||||
- @ref COLOR_SPACE_SRGB
|
||||
- @ref COLOR_SPACE_ADOBE_RGB
|
||||
- @ref COLOR_SPACE_WIDE_GAMUT_RGB
|
||||
- @ref COLOR_SPACE_PRO_PHOTO_RGB
|
||||
- @ref COLOR_SPACE_DCI_P3_RGB
|
||||
- @ref COLOR_SPACE_APPLE_RGB
|
||||
- @ref COLOR_SPACE_REC_709_RGB
|
||||
- @ref COLOR_SPACE_REC_2020_RGB
|
||||
@param cs the absolute color space that detected colors convert to;
|
||||
default: @ref COLOR_SPACE_SRGB
|
||||
*/
|
||||
CV_WRAP void setColorSpace(ColorSpace cs);
|
||||
|
||||
/** @brief set ccmType
|
||||
@param ccmType the shape of color correction matrix(CCM);
|
||||
default: @ref CCM_LINEAR
|
||||
*/
|
||||
CV_WRAP void setCcmType(CcmType ccmType);
|
||||
|
||||
/** @brief set Distance
|
||||
@param distance the type of color distance;
|
||||
default: @ref DISTANCE_CIE2000
|
||||
*/
|
||||
CV_WRAP void setDistance(DistanceType distance);
|
||||
|
||||
/** @brief set Linear
|
||||
@param linearizationType the method of linearization;
|
||||
default: @ref LINEARIZATION_GAMMA
|
||||
*/
|
||||
CV_WRAP void setLinearization(LinearizationType linearizationType);
|
||||
|
||||
/** @brief set Gamma
|
||||
|
||||
@note only valid when linear is set to "gamma";
|
||||
|
||||
@param gamma the gamma value of gamma correction;
|
||||
default: 2.2;
|
||||
*/
|
||||
CV_WRAP void setLinearizationGamma(double gamma);
|
||||
|
||||
/** @brief set degree
|
||||
@note only valid when linear is set to
|
||||
- @ref LINEARIZATION_COLORPOLYFIT
|
||||
- @ref LINEARIZATION_GRAYPOLYFIT
|
||||
- @ref LINEARIZATION_COLORLOGPOLYFIT
|
||||
- @ref LINEARIZATION_GRAYLOGPOLYFIT
|
||||
|
||||
@param deg the degree of linearization polynomial
|
||||
default: 3
|
||||
|
||||
*/
|
||||
CV_WRAP void setLinearizationDegree(int deg);
|
||||
|
||||
/** @brief set SaturatedThreshold.
|
||||
The colors in the closed interval [lower, upper] are reserved to participate
|
||||
in the calculation of the loss function and initialization parameters
|
||||
@param lower the lower threshold to determine saturation;
|
||||
default: 0;
|
||||
@param upper the upper threshold to determine saturation;
|
||||
default: 0
|
||||
*/
|
||||
CV_WRAP void setSaturatedThreshold(double lower, double upper);
|
||||
|
||||
/** @brief set WeightsList
|
||||
@param weightsList the list of weight of each color;
|
||||
default: empty array
|
||||
*/
|
||||
CV_WRAP void setWeightsList(const Mat& weightsList);
|
||||
|
||||
/** @brief set WeightCoeff
|
||||
@param weightsCoeff the exponent number of L* component of the reference color in CIE Lab color space;
|
||||
default: 0
|
||||
*/
|
||||
CV_WRAP void setWeightCoeff(double weightsCoeff);
|
||||
|
||||
/** @brief set InitialMethod
|
||||
@param initialMethodType the method of calculating CCM initial value;
|
||||
default: INITIAL_METHOD_LEAST_SQUARE
|
||||
*/
|
||||
CV_WRAP void setInitialMethod(InitialMethodType initialMethodType);
|
||||
|
||||
/** @brief set MaxCount
|
||||
@param maxCount used in MinProblemSolver-DownhillSolver;
|
||||
Terminal criteria to the algorithm;
|
||||
default: 5000;
|
||||
*/
|
||||
CV_WRAP void setMaxCount(int maxCount);
|
||||
|
||||
/** @brief set Epsilon
|
||||
@param epsilon used in MinProblemSolver-DownhillSolver;
|
||||
Terminal criteria to the algorithm;
|
||||
default: 1e-4;
|
||||
*/
|
||||
CV_WRAP void setEpsilon(double epsilon);
|
||||
|
||||
/** @brief Set whether the input image is in RGB color space
|
||||
@param rgb If true, the model expects input images in RGB format.
|
||||
If false, input is assumed to be in BGR (default).
|
||||
*/
|
||||
CV_WRAP void setRGB(bool rgb);
|
||||
|
||||
/** @brief make color correction */
|
||||
CV_WRAP Mat compute();
|
||||
|
||||
CV_WRAP Mat getColorCorrectionMatrix() const;
|
||||
CV_WRAP double getLoss() const;
|
||||
CV_WRAP Mat getSrcLinearRGB() const;
|
||||
CV_WRAP Mat getRefLinearRGB() const;
|
||||
CV_WRAP Mat getMask() const;
|
||||
CV_WRAP Mat getWeights() const;
|
||||
|
||||
/** @brief Applies color correction to the input image using a fitted color correction matrix.
|
||||
*
|
||||
* The conventional ranges for R, G, and B channel values are:
|
||||
- 0 to 255 for CV_8U images
|
||||
- 0 to 65535 for CV_16U images
|
||||
- 0 to 1 for CV_32F images
|
||||
@param src Input 8-bit, 16-bit unsigned or 32-bit float 3-channel image..
|
||||
@param dst Output image of the same size and datatype as src.
|
||||
@param islinear default false.
|
||||
*/
|
||||
CV_WRAP void correctImage(InputArray src, OutputArray dst, bool islinear = false);
|
||||
|
||||
CV_WRAP void write(cv::FileStorage& fs) const;
|
||||
CV_WRAP void read(const cv::FileNode& node);
|
||||
|
||||
class Impl;
|
||||
private:
|
||||
std::shared_ptr<Impl> p;
|
||||
};
|
||||
|
||||
CV_EXPORTS void write(cv::FileStorage& fs, const std::string&, const ColorCorrectionModel& ccm);
|
||||
CV_EXPORTS void read(const cv::FileNode& node, ColorCorrectionModel& ccm, const ColorCorrectionModel& defaultValue = ColorCorrectionModel());
|
||||
|
||||
//! @} ccm
|
||||
} // namespace ccm
|
||||
} // namespace cv
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,157 @@
|
||||
/*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) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2008-2012, Willow Garage Inc., 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_PHOTO_CUDA_HPP
|
||||
#define OPENCV_PHOTO_CUDA_HPP
|
||||
|
||||
#include "opencv2/core/cuda.hpp"
|
||||
|
||||
namespace cv { namespace cuda {
|
||||
|
||||
//! @addtogroup photo_denoise
|
||||
//! @{
|
||||
|
||||
/** @brief Performs pure non local means denoising without any simplification, and thus it is not fast.
|
||||
|
||||
@param src Source image. Supports only CV_8UC1, CV_8UC2 and CV_8UC3.
|
||||
@param dst Destination image.
|
||||
@param h Filter sigma regulating filter strength for color.
|
||||
@param search_window Size of search window.
|
||||
@param block_size Size of block used for computing weights.
|
||||
@param borderMode Border type. See borderInterpolate for details. BORDER_REFLECT101 ,
|
||||
BORDER_REPLICATE , BORDER_CONSTANT , BORDER_REFLECT and BORDER_WRAP are supported for now.
|
||||
@param stream Stream for the asynchronous version.
|
||||
|
||||
@sa
|
||||
fastNlMeansDenoising
|
||||
*/
|
||||
CV_EXPORTS void nonLocalMeans(InputArray src, OutputArray dst,
|
||||
float h,
|
||||
int search_window = 21,
|
||||
int block_size = 7,
|
||||
int borderMode = BORDER_DEFAULT,
|
||||
Stream& stream = Stream::Null());
|
||||
CV_WRAP inline void nonLocalMeans(const GpuMat& src, CV_OUT GpuMat& dst,
|
||||
float h,
|
||||
int search_window = 21,
|
||||
int block_size = 7,
|
||||
int borderMode = BORDER_DEFAULT,
|
||||
Stream& stream = Stream::Null())
|
||||
{
|
||||
nonLocalMeans(InputArray(src), OutputArray(dst), h, search_window, block_size, borderMode, stream);
|
||||
}
|
||||
|
||||
/** @brief Perform image denoising using Non-local Means Denoising algorithm
|
||||
<http://www.ipol.im/pub/algo/bcm_non_local_means_denoising> with several computational
|
||||
optimizations. Noise expected to be a gaussian white noise
|
||||
|
||||
@param src Input 8-bit 1-channel, 2-channel or 3-channel image.
|
||||
@param dst Output image with the same size and type as src .
|
||||
@param h Parameter regulating filter strength. Big h value perfectly removes noise but also
|
||||
removes image details, smaller h value preserves details but also preserves some noise
|
||||
@param search_window Size in pixels of the window that is used to compute weighted average for
|
||||
given pixel. Should be odd. Affect performance linearly: greater search_window - greater
|
||||
denoising time. Recommended value 21 pixels
|
||||
@param block_size Size in pixels of the template patch that is used to compute weights. Should be
|
||||
odd. Recommended value 7 pixels
|
||||
@param stream Stream for the asynchronous invocations.
|
||||
|
||||
This function expected to be applied to grayscale images. For colored images look at
|
||||
FastNonLocalMeansDenoising::labMethod.
|
||||
|
||||
@sa
|
||||
fastNlMeansDenoising
|
||||
*/
|
||||
CV_EXPORTS void fastNlMeansDenoising(InputArray src, OutputArray dst,
|
||||
float h,
|
||||
int search_window = 21,
|
||||
int block_size = 7,
|
||||
Stream& stream = Stream::Null());
|
||||
CV_WRAP inline void fastNlMeansDenoising(const GpuMat& src, CV_OUT GpuMat& dst,
|
||||
float h,
|
||||
int search_window = 21,
|
||||
int block_size = 7,
|
||||
Stream& stream = Stream::Null())
|
||||
{
|
||||
fastNlMeansDenoising(InputArray(src), OutputArray(dst), h, search_window, block_size, stream);
|
||||
}
|
||||
|
||||
/** @brief Modification of fastNlMeansDenoising function for colored images
|
||||
|
||||
@param src Input 8-bit 3-channel image.
|
||||
@param dst Output image with the same size and type as src .
|
||||
@param h_luminance Parameter regulating filter strength. Big h value perfectly removes noise but
|
||||
also removes image details, smaller h value preserves details but also preserves some noise
|
||||
@param photo_render float The same as h but for color components. For most images value equals 10 will be
|
||||
enough to remove colored noise and do not distort colors
|
||||
@param search_window Size in pixels of the window that is used to compute weighted average for
|
||||
given pixel. Should be odd. Affect performance linearly: greater search_window - greater
|
||||
denoising time. Recommended value 21 pixels
|
||||
@param block_size Size in pixels of the template patch that is used to compute weights. Should be
|
||||
odd. Recommended value 7 pixels
|
||||
@param stream Stream for the asynchronous invocations.
|
||||
|
||||
The function converts image to CIELAB colorspace and then separately denoise L and AB components
|
||||
with given h parameters using FastNonLocalMeansDenoising::simpleMethod function.
|
||||
|
||||
@sa
|
||||
fastNlMeansDenoisingColored
|
||||
*/
|
||||
CV_EXPORTS void fastNlMeansDenoisingColored(InputArray src, OutputArray dst,
|
||||
float h_luminance, float photo_render,
|
||||
int search_window = 21,
|
||||
int block_size = 7,
|
||||
Stream& stream = Stream::Null());
|
||||
CV_WRAP inline void fastNlMeansDenoisingColored(const GpuMat& src, CV_OUT GpuMat& dst,
|
||||
float h_luminance, float photo_render,
|
||||
int search_window = 21,
|
||||
int block_size = 7,
|
||||
Stream& stream = Stream::Null())
|
||||
{
|
||||
fastNlMeansDenoisingColored(InputArray(src), OutputArray(dst), h_luminance, photo_render, search_window, block_size, stream);
|
||||
}
|
||||
|
||||
//! @} photo
|
||||
|
||||
}} // namespace cv { namespace cuda {
|
||||
|
||||
#endif /* OPENCV_PHOTO_CUDA_HPP */
|
||||
@@ -0,0 +1,14 @@
|
||||
// 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_PHOTO_LEGACY_CONSTANTS_H
|
||||
#define OPENCV_PHOTO_LEGACY_CONSTANTS_H
|
||||
|
||||
enum InpaintingModes
|
||||
{
|
||||
CV_INPAINT_NS =0,
|
||||
CV_INPAINT_TELEA =1
|
||||
};
|
||||
|
||||
#endif // OPENCV_PHOTO_LEGACY_CONSTANTS_H
|
||||
@@ -0,0 +1,48 @@
|
||||
/*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) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Copyright (C) 2013, OpenCV Foundation, 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*/
|
||||
|
||||
#ifdef __OPENCV_BUILD
|
||||
#error this is a compatibility header which should not be used inside the OpenCV library
|
||||
#endif
|
||||
|
||||
#include "opencv2/photo.hpp"
|
||||
@@ -0,0 +1,141 @@
|
||||
// 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_PHOTO_SEGMENTATION_HPP
|
||||
#define OPENCV_PHOTO_SEGMENTATION_HPP
|
||||
|
||||
#include "opencv2/photo.hpp"
|
||||
|
||||
namespace cv {
|
||||
|
||||
namespace segmentation {
|
||||
|
||||
//! @addtogroup photo_segmentation
|
||||
//! @{
|
||||
|
||||
|
||||
/** @brief Intelligent Scissors image segmentation
|
||||
*
|
||||
* This class is used to find the path (contour) between two points
|
||||
* which can be used for image segmentation.
|
||||
*
|
||||
* Usage example:
|
||||
* @snippet snippets/photo_segmentation.cpp usage_example_intelligent_scissors
|
||||
*
|
||||
* Reference: <a href="http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.138.3811&rep=rep1&type=pdf">"Intelligent Scissors for Image Composition"</a>
|
||||
* algorithm designed by Eric N. Mortensen and William A. Barrett, Brigham Young University
|
||||
* @cite Mortensen95intelligentscissors
|
||||
*/
|
||||
class CV_EXPORTS_W_SIMPLE IntelligentScissorsMB
|
||||
{
|
||||
public:
|
||||
CV_WRAP
|
||||
IntelligentScissorsMB();
|
||||
|
||||
/** @brief Specify weights of feature functions
|
||||
*
|
||||
* Consider keeping weights normalized (sum of weights equals to 1.0)
|
||||
* Discrete dynamic programming (DP) goal is minimization of costs between pixels.
|
||||
*
|
||||
* @param weight_non_edge Specify cost of non-edge pixels (default: 0.43f)
|
||||
* @param weight_gradient_direction Specify cost of gradient direction function (default: 0.43f)
|
||||
* @param weight_gradient_magnitude Specify cost of gradient magnitude function (default: 0.14f)
|
||||
*/
|
||||
CV_WRAP
|
||||
IntelligentScissorsMB& setWeights(float weight_non_edge, float weight_gradient_direction, float weight_gradient_magnitude);
|
||||
|
||||
/** @brief Specify gradient magnitude max value threshold
|
||||
*
|
||||
* Zero limit value is used to disable gradient magnitude thresholding (default behavior, as described in original article).
|
||||
* Otherwize pixels with `gradient magnitude >= threshold` have zero cost.
|
||||
*
|
||||
* @note Thresholding should be used for images with irregular regions (to avoid stuck on parameters from high-contract areas, like embedded logos).
|
||||
*
|
||||
* @param gradient_magnitude_threshold_max Specify gradient magnitude max value threshold (default: 0, disabled)
|
||||
*/
|
||||
CV_WRAP
|
||||
IntelligentScissorsMB& setGradientMagnitudeMaxLimit(float gradient_magnitude_threshold_max = 0.0f);
|
||||
|
||||
/** @brief Switch to "Laplacian Zero-Crossing" edge feature extractor and specify its parameters
|
||||
*
|
||||
* This feature extractor is used by default according to article.
|
||||
*
|
||||
* Implementation has additional filtering for regions with low-amplitude noise.
|
||||
* This filtering is enabled through parameter of minimal gradient amplitude (use some small value 4, 8, 16).
|
||||
*
|
||||
* @note Current implementation of this feature extractor is based on processing of grayscale images (color image is converted to grayscale image first).
|
||||
*
|
||||
* @note Canny edge detector is a bit slower, but provides better results (especially on color images): use setEdgeFeatureCannyParameters().
|
||||
*
|
||||
* @param gradient_magnitude_min_value Minimal gradient magnitude value for edge pixels (default: 0, check is disabled)
|
||||
*/
|
||||
CV_WRAP
|
||||
IntelligentScissorsMB& setEdgeFeatureZeroCrossingParameters(float gradient_magnitude_min_value = 0.0f);
|
||||
|
||||
/** @brief Switch edge feature extractor to use Canny edge detector
|
||||
*
|
||||
* @note "Laplacian Zero-Crossing" feature extractor is used by default (following to original article)
|
||||
*
|
||||
* @sa Canny
|
||||
*/
|
||||
CV_WRAP
|
||||
IntelligentScissorsMB& setEdgeFeatureCannyParameters(
|
||||
double threshold1, double threshold2,
|
||||
int apertureSize = 3, bool L2gradient = false
|
||||
);
|
||||
|
||||
/** @brief Specify input image and extract image features
|
||||
*
|
||||
* @param image input image. Type is #CV_8UC1 / #CV_8UC3
|
||||
*/
|
||||
CV_WRAP
|
||||
IntelligentScissorsMB& applyImage(InputArray image);
|
||||
|
||||
/** @brief Specify custom features of input image
|
||||
*
|
||||
* Customized advanced variant of applyImage() call.
|
||||
*
|
||||
* @param non_edge Specify cost of non-edge pixels. Type is CV_8UC1. Expected values are `{0, 1}`.
|
||||
* @param gradient_direction Specify gradient direction feature. Type is CV_32FC2. Values are expected to be normalized: `x^2 + y^2 == 1`
|
||||
* @param gradient_magnitude Specify cost of gradient magnitude function: Type is CV_32FC1. Values should be in range `[0, 1]`.
|
||||
* @param image **Optional parameter**. Must be specified if subset of features is specified (non-specified features are calculated internally)
|
||||
*/
|
||||
CV_WRAP
|
||||
IntelligentScissorsMB& applyImageFeatures(
|
||||
InputArray non_edge, InputArray gradient_direction, InputArray gradient_magnitude,
|
||||
InputArray image = noArray()
|
||||
);
|
||||
|
||||
/** @brief Prepares a map of optimal paths for the given source point on the image
|
||||
*
|
||||
* @note applyImage() / applyImageFeatures() must be called before this call
|
||||
*
|
||||
* @param sourcePt The source point used to find the paths
|
||||
*/
|
||||
CV_WRAP void buildMap(const Point& sourcePt);
|
||||
|
||||
/** @brief Extracts optimal contour for the given target point on the image
|
||||
*
|
||||
* @note buildMap() must be called before this call
|
||||
*
|
||||
* @param targetPt The target point
|
||||
* @param[out] contour The list of pixels which contains optimal path between the source and the target points of the image. Type is CV_32SC2 (compatible with `std::vector<Point>`)
|
||||
* @param backward Flag to indicate reverse order of retrieved pixels (use "true" value to fetch points from the target to the source point)
|
||||
*/
|
||||
CV_WRAP void getContour(const Point& targetPt, OutputArray contour, bool backward = false) const;
|
||||
|
||||
#ifndef CV_DOXYGEN
|
||||
struct Impl;
|
||||
inline Impl* getImpl() const { return impl.get(); }
|
||||
protected:
|
||||
std::shared_ptr<Impl> impl;
|
||||
#endif
|
||||
};
|
||||
|
||||
//! @}
|
||||
|
||||
} // namespace segmentation
|
||||
} // namespace cv
|
||||
|
||||
#endif // OPENCV_PHOTO_SEGMENTATION_HPP
|
||||
Reference in New Issue
Block a user