Chuyển đổi hình ảnh RGB để Lab màu không gian (ví dụ , bất kỳ không gian màu nào với kênh độ sáng sẽ hoạt động tốt), sau đó áp dụng adaptive histogram equalization cho kênh L. Cuối cùng, chuyển đổi kết quả Lab trở lại thành RGB.
Điều bạn muốn là thuật toán CLAHE của OpenCV (Tương phản hạn chế biểu thức tương đương). Tuy nhiên, theo như tôi biết, nó không được ghi lại. Có an example in python. Bạn có thể đọc về CLAHE trong Graphics Gems IV, pp474-485
Dưới đây là một ví dụ về CLAHE trong hành động:
Và đây là C++ mà sản xuất hình trên, dựa trên http://answers.opencv.org/question/12024/use-of-clahe/, nhưng mở rộng cho màu sắc.
#include <opencv2/core.hpp>
#include <vector> // std::vector
int main(int argc, char** argv)
{
// READ RGB color image and convert it to Lab
cv::Mat bgr_image = cv::imread("image.png");
cv::Mat lab_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();
clahe->setClipLimit(4);
cv::Mat dst;
clahe->apply(lab_planes[0], dst);
// Merge the the color planes back into an Lab image
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("image original", bgr_image);
cv::imshow("image CLAHE", image_clahe);
cv::waitKey();
}
thank you very much – user3762718
Tôi sẽ cố gắng bây giờ và tôi sẽ nồi kết quả của tôi. cảm ơn bạn đã hỗ trợ của bạn vui lòng – user3762718
ví dụ python đã di chuyển. đây là liên kết mới: https://opencv-python-tutroals.readthedocs.org/en/latest/py_tutorials/py_imgproc/py_histograms/py_histogram_equalization/py_histogram_equalization.html –