CLAHE has obvious grid artifacts

asked 2019-04-30 01:44:01 -0500

gino0717 gravatar image

I get a camera with a gray surrounding circular shadow and it affects the result of my other function. I consider doing some to reduce the effect of the shadow.

I find CLAHE function may somehow help me so I copy the code from here

        video >> bgr_image;     
        cv::cvtColor(bgr_image, lab_image, CV_BGR2Lab);

        // Extract the L channel
        std::vector<cv::Mat> lab_planes(3);
        cv::split(lab_image, lab_planes);  // now we have the L image in lab_planes[0]

        // apply the CLAHE algorithm to the L channel
        cv::Ptr<cv::CLAHE> clahe = cv::createCLAHE(3,Size(8,8));

        cv::Mat dst;
        clahe->apply(lab_planes[0], dst);

        dst.copyTo(lab_planes[0]);
        cv::merge(lab_planes, lab_image);

        // convert back to RGB
        cv::Mat image_clahe;
        cv::cvtColor(lab_image, image_clahe, CV_Lab2BGR);

        // display the results  (you might also want to see lab_planes[0] before and after).
        cv::imshow("imageoriginal", bgr_image);
        cv::imshow("image CLAHE", image_clahe);

CLAHE looks good in all of the examples on the internet, however, I find it always results in very obvious grid artifacts everywhere. I can get rid of it by reducing the parameter but the shadow would be still there.

Is it normal? I can do some bilateral filter to smooth it but I still prefer a more smooth equalization method.

before CLAHE image description

after CLAHE image description

edit retag flag offensive close merge delete