1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-28 23:03:03 +04:00
Files
Gursimar Singh 425d5cfcf0 Merge pull request #27051 from gursimarsingh:move_ccm_to_photo_module
Adding color correction module to photo module from opencv_contrib #27051

This PR moved color correction module from opencv_contrib to main repo inside photo module.

### Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch
- [x] There is a reference to the original bug report and related work
- [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [x] The feature is well documented and sample code can be built with the project CMake
2025-06-12 17:07:16 +03:00

104 lines
3.0 KiB
C++

// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "perf_precomp.hpp"
#include "opencv2/photo.hpp"
namespace opencv_test {
namespace {
using namespace cv;
using namespace std;
PERF_TEST(CV_ccm_perf_480_640, correctImage)
{
string path = cvtest::findDataFile("cv/mcc/mcc_ccm_test.yml");
FileStorage fs(path, FileStorage::READ);
Mat chartsRGB;
fs["chartsRGB"] >> chartsRGB;
fs.release();
ASSERT_FALSE(chartsRGB.empty()) << "chartsRGB is empty after loading from: " << path;
cv::ccm::ColorCorrectionModel model(
chartsRGB.col(1).clone().reshape(3, chartsRGB.rows/3) / 255.0,
cv::ccm::COLORCHECKER_MACBETH
);
model.compute();
Mat img(480, 640, CV_8UC3);
randu(img, 0, 255);
Mat correctedImage;
TEST_CYCLE() { model.correctImage(img, correctedImage); }
SANITY_CHECK_NOTHING();
}
PERF_TEST(CV_ccm_perf_720_1280, correctImage)
{
string path = cvtest::findDataFile("cv/mcc/mcc_ccm_test.yml");
FileStorage fs(path, FileStorage::READ);
Mat chartsRGB;
fs["chartsRGB"] >> chartsRGB;
fs.release();
ASSERT_FALSE(chartsRGB.empty()) << "chartsRGB is empty after loading from: " << path;
cv::ccm::ColorCorrectionModel model(
chartsRGB.col(1).clone().reshape(3, chartsRGB.rows/3) / 255.0,
cv::ccm::COLORCHECKER_MACBETH
);
model.compute();
Mat img(720, 1280, CV_8UC3);
randu(img, 0, 255);
Mat correctedImage;
TEST_CYCLE() { model.correctImage(img, correctedImage); }
SANITY_CHECK_NOTHING();
}
PERF_TEST(CV_ccm_perf_1080_1920, correctImage)
{
string path = cvtest::findDataFile("cv/mcc/mcc_ccm_test.yml");
FileStorage fs(path, FileStorage::READ);
Mat chartsRGB;
fs["chartsRGB"] >> chartsRGB;
fs.release();
ASSERT_FALSE(chartsRGB.empty()) << "chartsRGB is empty after loading from: " << path;
cv::ccm::ColorCorrectionModel model(
chartsRGB.col(1).clone().reshape(3, chartsRGB.rows/3) / 255.0,
cv::ccm::COLORCHECKER_MACBETH
);
model.compute();
Mat img(1080, 1920, CV_8UC3);
randu(img, 0, 255);
Mat correctedImage;
TEST_CYCLE() { model.correctImage(img, correctedImage); }
SANITY_CHECK_NOTHING();
}
PERF_TEST(CV_ccm_perf_2160_3840, correctImage)
{
string path = cvtest::findDataFile("cv/mcc/mcc_ccm_test.yml");
FileStorage fs(path, FileStorage::READ);
Mat chartsRGB;
fs["chartsRGB"] >> chartsRGB;
fs.release();
ASSERT_FALSE(chartsRGB.empty()) << "chartsRGB is empty after loading from: " << path;
cv::ccm::ColorCorrectionModel model(
chartsRGB.col(1).clone().reshape(3, chartsRGB.rows/3) / 255.0,
cv::ccm::COLORCHECKER_MACBETH
);
model.compute();
Mat img(2160, 3840, CV_8UC3);
randu(img, 0, 255);
Mat correctedImage;
TEST_CYCLE() { model.correctImage(img, correctedImage); }
SANITY_CHECK_NOTHING();
}
} // namespace
} // namespace opencv_test