Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yellowish color on color corrector with COLORCHECKER_Macbeth #3856

Open
FrankEscobar opened this issue Dec 21, 2024 · 0 comments
Open

Yellowish color on color corrector with COLORCHECKER_Macbeth #3856

FrankEscobar opened this issue Dec 21, 2024 · 0 comments
Labels
category: mcc color calibration module

Comments

@FrankEscobar
Copy link

System information (version)
  • OpenCV => 4.10

  • Operating System / Platform => Windows 64 Bit

  • Compiler => Visual Studio 2022

  • OpenCV => 4.10

  • Operating System / Platform => Windows 64 Bit

  • Compiler => Visual Studio 2022

Detailed description

Following the tutorial I manage to make color correction over the image and the result is not totally weird but for away from others like DaVinci Resolve implementation.


bool getRGBChartsFromImage(const string& imagePath,const TYPECHART chartType, Mat &mat)
{
    Mat imageWithCheck = imread(imagePath, IMREAD_COLOR);
    if (!imageWithCheck.data) {
        cout << "Invalid Image Check!" << endl;
        return false;
    }
    Ptr<CCheckerDetector> detector = CCheckerDetector::create();
    if (!detector->process(imageWithCheck, chartType, 1)) {
        printf("ChartColor not detected \n");
        return false;
    }
    vector<Ptr<mcc::CChecker>> checkers = detector->getListColorChecker();
    if (checkers.size() != 1)
    {
        printf("Invalid amount of charts %i\n", (int)checkers.size());
    }
    Ptr<mcc::CChecker> checker = checkers[0];
    Mat chartsRGB = checker->getChartsRGB();
    mat = chartsRGB.col(1).clone().reshape(3, chartsRGB.rows / 3);
    mat /= 255.0;
}
bool calibrateImage(const Mat& uncalibradedMat, const TYPECHART chartType, const Mat &chartMat, Mat& calibratedMat)
{
    CONST_COLOR destColor;
    switch (chartType) {
    case cv::mcc::MCC24:
        destColor = COLORCHECKER_Macbeth;
        break;
    case cv::mcc::SG140:
        destColor = COLORCHECKER_DigitalSG;
        break;
    case cv::mcc::VINYL18:
        destColor = COLORCHECKER_Vinyl;
        break;
    default:
        printf("Invalid chart type. Exiting.\n");
        return false;
    }
    ColorCorrectionModel model(chartMat, destColor);
    //model.setInitialMethod(INITIAL_METHOD_WHITE_BALANCE);
    model.setColorSpace(COLOR_SPACE_sRGB);
    model.setDistance(DISTANCE_CIE2000);
    model.setLinear(LINEARIZATION_GAMMA);
    model.setLinearGamma(2.0);
    model.setLinearDegree(3);
    model.setCCM_TYPE(CCM_3x3);
    model.setMaxCount(5000);
    model.setEpsilon(1e-7);
    model.setSaturatedThreshold(0, 0.98);
    model.run();
    Mat ccm = model.getCCM();
    std::cout << "ccm:\n" << ccm << std::endl;
    double loss = model.getLoss();
    std::cout << "loss: " << loss << std::endl;
    // Aplicar el modelo a imageMod
    Mat img_;
    cvtColor(uncalibradedMat, img_, COLOR_BGR2RGB);
    img_.convertTo(img_, CV_64F, 1.0 / 255.0);
    Mat calibratedImage = model.infer(img_);
    Mat out_ = calibratedImage * 255.0;
    out_.convertTo(out_, CV_8UC3);
    Mat img_out = min(max(out_, 0), 255);
    cvtColor(img_out, calibratedMat, COLOR_RGB2BGR);
    return true;
}

You can notice that the result is too warm.

Input
calibb

calibrated
calibb_calibrated

Thank you in advance

@opencv-alalek opencv-alalek added the category: mcc color calibration module label Dec 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: mcc color calibration module
Projects
None yet
Development

No branches or pull requests

2 participants