// 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. // // // License Agreement // For Open Source Computer Vision Library // // Copyright(C) 2020, Huawei Technologies Co.,Ltd. All rights reserved. // Third party copyrights are property of their respective owners. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // Author: Longbu Wang // Jinheng Zhang // Chenqi Shan #ifndef __OPENCV_MCC_CCM_HPP__ #define __OPENCV_MCC_CCM_HPP__ #include #include namespace cv { namespace ccm { /** @addtogroup color_correction @{ Introduction ------------ The purpose of color correction is to adjust the color response of input and output devices to a known state. The device being calibrated is sometimes called the calibration source; the color space used as the standard is sometimes called the calibration target. Color calibration has been used in many industries, such as television production, games, photography, engineering, chemistry, medicine, etc. Due to the manufacturing process of the input and output equipment, the channel response has nonlinear distortion. In order to correct the picture output of the equipment, it is nessary to calibrate the captured color and the actual color. */ /** @brief Enum of the possible types of ccm. */ enum CCM_TYPE { CCM_3x3, ///< The CCM with the shape \f$3\times3\f$ performs linear transformation on color values. CCM_4x3, ///< The CCM with the shape \f$4\times3\f$ performs affine transformation. }; /** @brief Enum of the possible types of initial method. */ enum INITIAL_METHOD_TYPE { 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_R=mean(G_{li}')/mean(G_{li})\\ /// k_R=mean(B_{li}')/mean(B_{li}) /// \f$ INITIAL_METHOD_LEAST_SQUARE, ///0\\ C_{sl}=0, \qquad C_s=0 \f] Because \f$exp(ln(0))\to\infty \f$, the channel whose component is 0 is directly mapped to 0 in the formula above. For fitting channels respectively, we have: \f[ r=polyfit(ln(R_s),ln(R_{dl}))\\ g=polyfit(ln(G_s),ln(G_{dl}))\\ b=polyfit(ln(B_s),ln(B_{dl}))\\ \f] Note that the parameter of \f$ln(*) \f$ cannot be 0. Therefore, we need to delete the channels whose values are 0 from \f$R_s \f$ and \f$R_{dl} \f$, \f$G_s\f$ and \f$G_{dl}\f$, \f$B_s\f$ and \f$B_{dl}\f$. Therefore: \f[ ln(R_{sl})=r(ln(R_s)), \qquad R_s>0\\ R_{sl}=0, \qquad R_s=0\\ ln(G_{sl})=g(ln(G_s)),\qquad G_s>0\\ G_{sl}=0, \qquad G_s=0\\ ln(B_{sl})=b(ln(B_s)),\qquad B_s>0\\ B_{sl}=0, \qquad B_s=0\\ \f] For grayscale polynomials, there are also: \f[ f=polyfit(ln(G_{sl}),ln(G_{dl})) \f] and: \f[ ln(C_{sl})=f(ln(C_s)), \qquad C_s>0\\ C_sl=0, \qquad C_s=0 \f] */ enum LINEAR_TYPE { LINEARIZATION_IDENTITY, /// p; }; //! @} ccm } // namespace ccm } // namespace cv #endif