simple illumination correction in images openCV c++ -



simple illumination correction in images openCV c++ -

i have color photos , illumination not regular in photos.

on 1 side of image brighter other side. solve problem correcting illumination. think local contrast help me don't know how :( please help me piece of code or pipeline??

convert rgb image lab color-space (e.g., color-space luminance channel work fine), apply adaptive histogram equalization l channel. convert resulting lab rgb.

what want opencv's clahe (contrast limited adaptive histogram equalization) algorithm. however, far know not documented. there an illustration in python. can read clahe in graphics gems iv, pp474-485

here illustration of clahe in action:

and here c++ produced above image, based on http://answers.opencv.org/question/12024/use-of-clahe/, extended color.

#include <opencv2/core/core.hpp> #include <vector> // std::vector int main(int argc, char** argv) { // read rgb color image , convert lab cv::mat bgr_image = cv::imread("image.png"); cv::mat lab_image; cv::cvtcolor(bgr_image, lab_image, cv_bgr2lab); // extract l channel std::vector<cv::mat> lab_planes(3); cv::split(lab_image, lab_planes); // have l image in lab_planes[0] // apply clahe algorithm l channel cv::ptr<cv::clahe> clahe = cv::createclahe(); clahe->setcliplimit(4); cv::mat dst; clahe->apply(lab_planes[0], dst); // merge the color planes lab image dst.copyto(lab_planes[0]); cv::merge(lab_planes, lab_image); // convert rgb cv::mat image_clahe; cv::cvtcolor(lab_image, image_clahe, cv_lab2bgr); // display results (you might want see lab_planes[0] before , after). cv::imshow("image original", bgr_image); cv::imshow("image clahe", image_clahe); cv::waitkey(); }

c++ opencv contrast

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -