#include <iostream>
#include "opencv2/opencv.hpp"

using namespace std;
using namespace cv;

int contrast0();
int contrast1();
int contrast2();

Mat sigmoid(const Mat& input) {
	Mat output;
	exp(-1 * input, output);  // e^(-x)
	output = 1.0 / (1.0 + output);  // sigmoid(x) = 1 / (1 + e^(-x))
	return output;
}

int main() {
	return contrast0();
}

int contrast0() {
	Mat src = imread("..\\..\\resources\\images\\lenna.bmp", IMREAD_GRAYSCALE);
	if (src.empty()) {
		cerr << "imread()" << endl;
		return 1;
	}
	float alpha = 1.f;
	Mat dst = (sigmoid(src * alpha) * 128);

	imshow("src", src);
	imshow("dst", dst);

	waitKey();
	destroyAllWindows();
}

int contrast1() {
	Mat src = imread("..\\..\\resources\\images\\lenna.bmp", IMREAD_GRAYSCALE);
	if (src.empty()) {
		cerr << "imread()" << endl;
		return 1;
	}
	float s = 2.f;
	Mat dst = s * src;

	imshow("src", src);
	imshow("dst", dst);

	waitKey();
	destroyAllWindows();
}

int contrast2() {
	Mat src = imread("..\\..\\resources\\images\\lenna.bmp", IMREAD_GRAYSCALE);
	if (src.empty()) {
		cerr << "imread()" << endl;
		return 1;
	}
	float alpha = 1.f;
	Mat dst = src + (src - 128) * alpha;

	imshow("src", src);
	imshow("dst", dst);

	waitKey();
	destroyAllWindows();
}