# 附加相片处理算法

## 类

class cv::xphoto::GrayworldWB
Gray-world white balance algorithm. 更多...
class cv::xphoto::LearningBasedWB
More sophisticated learning-based automatic white balance algorithm. 更多...
class cv::xphoto::SimpleWB
A simple white balance algorithm that works by independently stretching each of the input image channels to the specified range. For increased robustness it ignores the top and bottom $$p\%$$ of pixel values. 更多...
class cv::xphoto::TonemapDurand
This algorithm decomposes image into two layers: base layer and detail layer using bilateral filter and compresses contrast of the base layer thus preserving all the details. 更多...
class cv::xphoto::WhiteBalancer
The base class for auto white balance algorithms. 更多...

## 枚举

enum cv::xphoto::Bm3dSteps {
cv::xphoto::BM3D_STEPALL = 0,
cv::xphoto::BM3D_STEP1 = 1,
cv::xphoto::BM3D_STEP2 = 2
}
BM3D algorithm steps. 更多...
enum cv::xphoto::InpaintTypes {
cv::xphoto::INPAINT_SHIFTMAP = 0,
cv::xphoto::INPAINT_FSR_BEST = 1,
cv::xphoto::INPAINT_FSR_FAST = 2
}
Various inpainting algorithms. 更多...
enum cv::xphoto::TransformTypes { cv::xphoto::HAAR = 0 }
BM3D transform types. 更多...

## 函数

void cv::xphoto::applyChannelGains ( InputArray src, OutputArray dst, float gainB, float gainG, float gainR)
Implements an efficient fixed-point approximation for applying channel gains, which is the last step of multiple white balance algorithms. 更多...
void cv::xphoto::bm3dDenoising ( InputArray src, InputOutputArray dstStep1, OutputArray dstStep2, float h=1, int templateWindowSize=4, int searchWindowSize=16, int blockMatchingStep1=2500, int blockMatchingStep2=400, int groupSize=8, int slidingStep=1, float beta=2.0f, int normType=cv::NORM_L2, int step=cv::xphoto::BM3D_STEPALL, int transformType=cv::xphoto::HAAR)
Performs image denoising using the Block-Matching and 3D-filtering algorithm http://www.cs.tut.fi/~foi/GCF-BM3D/BM3D_TIP_2007.pdf with several computational optimizations. Noise expected to be a gaussian white noise. 更多...
void cv::xphoto::bm3dDenoising ( InputArray src, OutputArray dst, float h=1, int templateWindowSize=4, int searchWindowSize=16, int blockMatchingStep1=2500, int blockMatchingStep2=400, int groupSize=8, int slidingStep=1, float beta=2.0f, int normType=cv::NORM_L2, int step=cv::xphoto::BM3D_STEPALL, int transformType=cv::xphoto::HAAR)
Performs image denoising using the Block-Matching and 3D-filtering algorithm http://www.cs.tut.fi/~foi/GCF-BM3D/BM3D_TIP_2007.pdf with several computational optimizations. Noise expected to be a gaussian white noise. 更多...
Ptr < GrayworldWB > cv::xphoto::createGrayworldWB ()
Creates an instance of GrayworldWB . 更多...
Ptr < LearningBasedWB > cv::xphoto::createLearningBasedWB (const String &path_to_model= String ())
Creates an instance of LearningBasedWB . 更多...
Ptr < SimpleWB > cv::xphoto::createSimpleWB ()
Creates an instance of SimpleWB . 更多...
Ptr < TonemapDurand > cv::xphoto::createTonemapDurand (float gamma=1.0f, float contrast=4.0f, float saturation=1.0f, float sigma_space=2.0f, float sigma_color=2.0f)
Creates TonemapDurand 对象。 更多...
void cv::xphoto::dctDenoising (const Mat &src, Mat &dst, const double sigma, const int psize=16)
The function implements simple dct-based denoising. 更多...
virtual float cv::xphoto::TonemapDurand::getContrast () const =0
virtual float cv::xphoto::TonemapDurand::getSaturation () const =0
virtual float cv::xphoto::TonemapDurand::getSigmaColor () const =0
virtual float cv::xphoto::TonemapDurand::getSigmaSpace () const =0
void cv::xphoto::inpaint (const Mat &src, const Mat &mask, Mat &dst, const int algorithmType)
The function implements different single-image inpainting algorithms. 更多...
void cv::xphoto::oilPainting ( InputArray src, OutputArray dst, int size, int dynRatio, int code)
oilPainting See the book [33] for details. 更多...
void cv::xphoto::oilPainting ( InputArray src, OutputArray dst, int size, int dynRatio)
oilPainting See the book [33] for details. 更多...
virtual void cv::xphoto::TonemapDurand::setContrast (float contrast)=0
virtual void cv::xphoto::TonemapDurand::setSaturation (float saturation)=0
virtual void cv::xphoto::TonemapDurand::setSigmaColor (float sigma_color)=0
virtual void cv::xphoto::TonemapDurand::setSigmaSpace (float sigma_space)=0

## ◆ Bm3dSteps

 enum cv::xphoto::Bm3dSteps

 #include < opencv2/xphoto/bm3d_image_denoising.hpp > 

BM3D algorithm steps.

BM3D_STEPALL
Python: cv.xphoto.BM3D_STEPALL

Execute all steps of the algorithm

BM3D_STEP1
Python: cv.xphoto.BM3D_STEP1

Execute only first step of the algorithm

BM3D_STEP2
Python: cv.xphoto.BM3D_STEP2

Execute only second step of the algorithm

## ◆ InpaintTypes

 enum cv::xphoto::InpaintTypes

 #include < opencv2/xphoto/inpainting.hpp > 

Various inpainting algorithms.

inpaint

INPAINT_SHIFTMAP
Python: cv.xphoto.INPAINT_SHIFTMAP

This algorithm searches for dominant correspondences (transformations) of image patches and tries to seamlessly fill-in the area to be inpainted using this transformations

INPAINT_FSR_BEST
Python: cv.xphoto.INPAINT_FSR_BEST

Performs Frequency Selective Reconstruction (FSR). One of the two quality profiles BEST and FAST can be chosen, depending on the time available for reconstruction. See [82] and [201] for details.

The algorithm may be utilized for the following areas of application:

1. Error Concealment (Inpainting). The sampling mask indicates the missing pixels of the distorted input image to be reconstructed.

1-channel grayscale or 3-channel BGR image are accepted.

Conventional accepted ranges:

• 0-255 for CV_8U
• 0-65535 for CV_16U
• 0-1 for CV_32F/CV_64F.
INPAINT_FSR_FAST
Python: cv.xphoto.INPAINT_FSR_FAST

## ◆ TransformTypes

 enum cv::xphoto::TransformTypes

 #include < opencv2/xphoto/bm3d_image_denoising.hpp > 

BM3D transform types.

HAAR
Python: cv.xphoto.HAAR

Un-normalized Haar transform

## ◆ applyChannelGains()

 void cv::xphoto::applyChannelGains ( InputArray src , OutputArray dst , float gainB , float gainG , float gainR )
Python:
dst = cv.xphoto.applyChannelGains( src, gainB, gainG, gainR[, dst] )

 #include < opencv2/xphoto/white_balance.hpp > 

Implements an efficient fixed-point approximation for applying channel gains, which is the last step of multiple white balance algorithms.

Parameters
 src Input three-channel image in the BGR color space (either CV_8UC3 or CV_16UC3) dst Output image of the same size and type as src. gainB gain for the B channel gainG gain for the G channel gainR gain for the R channel

## ◆ bm3dDenoising() [1/2]

 void cv::xphoto::bm3dDenoising ( InputArray src , InputOutputArray dstStep1 , OutputArray dstStep2 , float h =  1  , int templateWindowSize =  4  , int searchWindowSize =  16  , int blockMatchingStep1 =  2500  , int blockMatchingStep2 =  400  , int groupSize =  8  , int slidingStep =  1  , float beta =  2.0f  , int normType =  cv::NORM_L2  , int step =  cv::xphoto::BM3D_STEPALL  , int transformType =  cv::xphoto::HAAR  )
Python:
dstStep1, dstStep2 = cv.xphoto.bm3dDenoising( src, dstStep1[, dstStep2[, h[, templateWindowSize[, searchWindowSize[, blockMatchingStep1[, blockMatchingStep2[, groupSize[, slidingStep[, beta[, normType[, step[, transformType]]]]]]]]]]]] )
dst = cv.xphoto.bm3dDenoising( src[, dst[, h[, templateWindowSize[, searchWindowSize[, blockMatchingStep1[, blockMatchingStep2[, groupSize[, slidingStep[, beta[, normType[, step[, transformType]]]]]]]]]]]] )

 #include < opencv2/xphoto/bm3d_image_denoising.hpp > 

Performs image denoising using the Block-Matching and 3D-filtering algorithm http://www.cs.tut.fi/~foi/GCF-BM3D/BM3D_TIP_2007.pdf with several computational optimizations. Noise expected to be a gaussian white noise.

Parameters
 src Input 8-bit or 16-bit 1-channel image. dstStep1 Output image of the first step of BM3D with the same size and type as src. dstStep2 Output image of the second step of BM3D with the same size and type as src. 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. templateWindowSize Size in pixels of the template patch that is used for block-matching. Should be power of 2. searchWindowSize Size in pixels of the window that is used to perform block-matching. Affect performance linearly: greater searchWindowsSize - greater denoising time. Must be larger than templateWindowSize. blockMatchingStep1 Block matching threshold for the first step of BM3D (hard thresholding), i.e. maximum distance for which two blocks are considered similar. Value expressed in euclidean distance. blockMatchingStep2 Block matching threshold for the second step of BM3D (Wiener filtering), i.e. maximum distance for which two blocks are considered similar. Value expressed in euclidean distance. groupSize Maximum size of the 3D group for collaborative filtering. slidingStep Sliding step to process every next reference block. beta Kaiser window parameter that affects the sidelobe attenuation of the transform of the window. Kaiser window is used in order to reduce border effects. To prevent usage of the window, set beta to zero. normType Norm used to calculate distance between blocks. L2 is slower than L1 but yields more accurate results. step Step of BM3D to be executed. Possible variants are: step 1, step 2, both steps. transformType Type of the orthogonal transform used in collaborative filtering step. Currently only Haar transform is supported.

This function expected to be applied to grayscale images. Advanced usage of this function can be manual denoising of colored image in different colorspaces.

fastNlMeansDenoising

## ◆ bm3dDenoising() [2/2]

 void cv::xphoto::bm3dDenoising ( InputArray src , OutputArray dst , float h =  1  , int templateWindowSize =  4  , int searchWindowSize =  16  , int blockMatchingStep1 =  2500  , int blockMatchingStep2 =  400  , int groupSize =  8  , int slidingStep =  1  , float beta =  2.0f  , int normType =  cv::NORM_L2  , int step =  cv::xphoto::BM3D_STEPALL  , int transformType =  cv::xphoto::HAAR  )
Python:
dstStep1, dstStep2 = cv.xphoto.bm3dDenoising( src, dstStep1[, dstStep2[, h[, templateWindowSize[, searchWindowSize[, blockMatchingStep1[, blockMatchingStep2[, groupSize[, slidingStep[, beta[, normType[, step[, transformType]]]]]]]]]]]] )
dst = cv.xphoto.bm3dDenoising( src[, dst[, h[, templateWindowSize[, searchWindowSize[, blockMatchingStep1[, blockMatchingStep2[, groupSize[, slidingStep[, beta[, normType[, step[, transformType]]]]]]]]]]]] )

 #include < opencv2/xphoto/bm3d_image_denoising.hpp > 

Performs image denoising using the Block-Matching and 3D-filtering algorithm http://www.cs.tut.fi/~foi/GCF-BM3D/BM3D_TIP_2007.pdf with several computational optimizations. Noise expected to be a gaussian white noise.

Parameters
 src Input 8-bit or 16-bit 1-channel image. dst Output image with the same size and type as src. 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. templateWindowSize Size in pixels of the template patch that is used for block-matching. Should be power of 2. searchWindowSize Size in pixels of the window that is used to perform block-matching. Affect performance linearly: greater searchWindowsSize - greater denoising time. Must be larger than templateWindowSize. blockMatchingStep1 Block matching threshold for the first step of BM3D (hard thresholding), i.e. maximum distance for which two blocks are considered similar. Value expressed in euclidean distance. blockMatchingStep2 Block matching threshold for the second step of BM3D (Wiener filtering), i.e. maximum distance for which two blocks are considered similar. Value expressed in euclidean distance. groupSize Maximum size of the 3D group for collaborative filtering. slidingStep Sliding step to process every next reference block. beta Kaiser window parameter that affects the sidelobe attenuation of the transform of the window. Kaiser window is used in order to reduce border effects. To prevent usage of the window, set beta to zero. normType Norm used to calculate distance between blocks. L2 is slower than L1 but yields more accurate results. step Step of BM3D to be executed. Allowed are only BM3D_STEP1 and BM3D_STEPALL. BM3D_STEP2 is not allowed as it requires basic estimate to be present. transformType Type of the orthogonal transform used in collaborative filtering step. Currently only Haar transform is supported.

This function expected to be applied to grayscale images. Advanced usage of this function can be manual denoising of colored image in different colorspaces.

fastNlMeansDenoising

## ◆ createGrayworldWB()

 Ptr < GrayworldWB > cv::xphoto::createGrayworldWB ( )
Python:
retval = cv.xphoto.createGrayworldWB( )

 #include < opencv2/xphoto/white_balance.hpp > 

Creates an instance of GrayworldWB .

## ◆ createLearningBasedWB()

 Ptr < LearningBasedWB > cv::xphoto::createLearningBasedWB ( const String & path_to_model =  String ()  )
Python:
retval = cv.xphoto.createLearningBasedWB( [, path_to_model] )

 #include < opencv2/xphoto/white_balance.hpp > 

Creates an instance of LearningBasedWB .

Parameters
 path_to_model Path to a .yml file with the model. If not specified, the default model is used

## ◆ createSimpleWB()

 Ptr < SimpleWB > cv::xphoto::createSimpleWB ( )
Python:
retval = cv.xphoto.createSimpleWB( )

 #include < opencv2/xphoto/white_balance.hpp > 

Creates an instance of SimpleWB .

## ◆ createTonemapDurand()

 Ptr < TonemapDurand > cv::xphoto::createTonemapDurand ( float gamma =  1.0f  , float contrast =  4.0f  , float saturation =  1.0f  , float sigma_space =  2.0f  , float sigma_color =  2.0f  )
Python:
retval = cv.xphoto.createTonemapDurand( [, gamma[, contrast[, saturation[, sigma_space[, sigma_color]]]]] )

 #include < opencv2/xphoto/tonemap.hpp > 

Creates TonemapDurand 对象。

You need to set the OPENCV_ENABLE_NONFREE option in cmake to use those. Use them at your own risk.

Parameters
 gamma gamma value for gamma correction. See createTonemap contrast resulting contrast on logarithmic scale, i. e. log(max / min), where max and min are maximum and minimum luminance values of the resulting image. saturation saturation enhancement value. See createTonemapDrago sigma_space bilateral filter sigma in color space sigma_color bilateral filter sigma in coordinate space

## ◆ dctDenoising()

 void cv::xphoto::dctDenoising ( const Mat & src , Mat & dst , const double sigma , const int psize =  16  )
Python:
None = cv.xphoto.dctDenoising( src, dst, sigma[, psize] )

 #include < opencv2/xphoto/dct_image_denoising.hpp > 

The function implements simple dct-based denoising.

Parameters
 src source image dst destination image sigma expected noise standard deviation psize size of block side where dct is computed

fastNlMeansDenoising

## ◆ getContrast()

 virtual float cv::xphoto::TonemapDurand::getContrast ( ) const
pure virtual
Python:
retval = cv.xphoto_TonemapDurand.getContrast( )

 #include < opencv2/xphoto/tonemap.hpp > 

## ◆ getSaturation()

 virtual float cv::xphoto::TonemapDurand::getSaturation ( ) const
pure virtual
Python:
retval = cv.xphoto_TonemapDurand.getSaturation( )

 #include < opencv2/xphoto/tonemap.hpp > 

## ◆ getSigmaColor()

 virtual float cv::xphoto::TonemapDurand::getSigmaColor ( ) const
pure virtual
Python:
retval = cv.xphoto_TonemapDurand.getSigmaColor( )

 #include < opencv2/xphoto/tonemap.hpp > 

## ◆ getSigmaSpace()

 virtual float cv::xphoto::TonemapDurand::getSigmaSpace ( ) const
pure virtual
Python:
retval = cv.xphoto_TonemapDurand.getSigmaSpace( )

 #include < opencv2/xphoto/tonemap.hpp > 

## ◆ inpaint()

 void cv::xphoto::inpaint ( const Mat & src , const Mat & mask , Mat & dst , const int algorithmType )
Python:
None = cv.xphoto.inpaint( src, mask, dst, algorithmType )

 #include < opencv2/xphoto/inpainting.hpp > 

The function implements different single-image inpainting algorithms.

See the original papers [95] (Shiftmap) or [82] and [201] (FSR) for details.

Parameters
 src source image INPAINT_SHIFTMAP : it could be of any type and any number of channels from 1 to 4. In case of 3- and 4-channels images the function expect them in CIELab colorspace or similar one, where first color component shows intensity, while second and third shows colors. Nonetheless you can try any colorspaces. INPAINT_FSR_BEST 或 INPAINT_FSR_FAST : 1-channel grayscale or 3-channel BGR image. mask mask ( CV_8UC1 ), where non-zero pixels indicate valid image area, while zero pixels indicate area to be inpainted dst destination image algorithmType see xphoto::InpaintTypes

## ◆ oilPainting() [1/2]

 void cv::xphoto::oilPainting ( InputArray src , OutputArray dst , int size , int dynRatio , int code )
Python:
dst = cv.xphoto.oilPainting( src, size, dynRatio, code[, dst] )
dst = cv.xphoto.oilPainting( src, size, dynRatio[, dst] )

 #include < opencv2/xphoto/oilpainting.hpp > 

oilPainting See the book [33] for details.

Parameters
 src Input three-channel or one channel image (either CV_8UC3 or CV_8UC1) dst Output image of the same size and type as src. size neighbouring size is 2-size+1 dynRatio image is divided by dynRatio before histogram processing code color space conversion code(see ColorConversionCodes). Histogram will used only first plane

## ◆ oilPainting() [2/2]

 void cv::xphoto::oilPainting ( InputArray src , OutputArray dst , int size , int dynRatio )
Python:
dst = cv.xphoto.oilPainting( src, size, dynRatio, code[, dst] )
dst = cv.xphoto.oilPainting( src, size, dynRatio[, dst] )

 #include < opencv2/xphoto/oilpainting.hpp > 

oilPainting See the book [33] for details.

Parameters
 src Input three-channel or one channel image (either CV_8UC3 or CV_8UC1) dst Output image of the same size and type as src. size neighbouring size is 2-size+1 dynRatio image is divided by dynRatio before histogram processing

## ◆ setContrast()

 virtual void cv::xphoto::TonemapDurand::setContrast ( float contrast )
pure virtual
Python:
None = cv.xphoto_TonemapDurand.setContrast( contrast )

 #include < opencv2/xphoto/tonemap.hpp > 

## ◆ setSaturation()

 virtual void cv::xphoto::TonemapDurand::setSaturation ( float saturation )
pure virtual
Python:
None = cv.xphoto_TonemapDurand.setSaturation( saturation )

 #include < opencv2/xphoto/tonemap.hpp > 

## ◆ setSigmaColor()

 virtual void cv::xphoto::TonemapDurand::setSigmaColor ( float sigma_color )
pure virtual
Python:
None = cv.xphoto_TonemapDurand.setSigmaColor( sigma_color )

 #include < opencv2/xphoto/tonemap.hpp > 

## ◆ setSigmaSpace()

 virtual void cv::xphoto::TonemapDurand::setSigmaSpace ( float sigma_space )
pure virtual
Python:
None = cv.xphoto_TonemapDurand.setSigmaSpace( sigma_space )

 #include < opencv2/xphoto/tonemap.hpp >