#include "opencv2/core/utility.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/imgcodecs.hpp"
#include "opencv2/highgui.hpp"
#include <iostream>
int _brightness = 100;
int _contrast = 100;
static void updateBrightnessContrast( int , void* )
{
int histSize = 64;
int brightness = _brightness - 100;
int contrast = _contrast - 100;
double a, b;
if( contrast > 0 )
{
double delta = 127.*contrast/100;
a = 255./(255. - delta*2);
b = a*(brightness - delta);
}
else
{
double delta = -128.*contrast/100;
a = (256.-delta*2)/255.;
b = a*brightness + delta;
}
for( int i = 0; i < histSize; i++ )
imshow(
"histogram", histImage);
}
static void help()
{
std::cout << "\nThis program demonstrates the use of calcHist() -- histogram creation.\n"
<< "Usage: \n" << "demhist [image_name -- Defaults to baboon.jpg]" << std::endl;
}
const char* keys =
{
"{help h||}{@image|baboon.jpg|input image file}"
};
int main( int argc, const char** argv )
{
{
help();
return 0;
}
string inputImage = parser.
get<
string>(0);
if(image.empty())
{
std::cerr << "Cannot read image file: " << inputImage << std::endl;
return -1;
}
createTrackbar(
"brightness",
"image", &_brightness, 200, updateBrightnessContrast);
createTrackbar(
"contrast",
"image", &_contrast, 200, updateBrightnessContrast);
updateBrightnessContrast(0, 0);
return 0;
}