as a startup i suggest this simple code
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
int main(int argc, char** argv)
{
cv::Mat bgr_image = cv::imread("14349796948124829.png");
cv::Mat brightened_image = bgr_image*1.25; // multiple image means brigthness
cv::imshow("image", bgr_image);
cv::imshow("brightened image", brightened_image);
cv::imwrite("brightened.png",brightened_image);
cv::waitKey();
}
the result image is like this but we can improve the code if it is not what you want
and the second try improving your code
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui/highgui.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("14349796948124829.png");
bgr_image*=1.3;
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(2); // changed parameter 4 to 2
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::imwrite("image_clahe.png",image_clahe);
cv::waitKey();
}
the result image
and the last
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
int main(int argc, char** argv)
{
cv::Mat bgr_image = cv::imread("14349796948124829.png");
cv::Mat brightened_image = bgr_image*1.3;
cv::addWeighted(brightened_image,0.8,bgr_image,0.2,0,brightened_image);
cv::imshow("image", bgr_image);
cv::imshow("brightened image", brightened_image);
cv::imwrite("brightened2.png",brightened_image);
cv::waitKey();
}
the result image
for comparison source and result images
try some histogram equalization approach in order to fix the contrast of the image. Have a look in the following examples. 1, 2, 3
If i use Histogram equalization document is converted to gray color. My document have somany color of text . I am tried with 3rd solution, it's changed the actual color of text. Please give me any other suggestions.
i think, if you provide sample image and what you tried as code then you can get more information
@ashok, can we close your other question then ? it's bad to have duplicates