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

using namespace std;
using namespace cv;

void noise_gaussian() {
	Mat src = imread("..\\..\\resources\\images\\lenna.bmp", IMREAD_GRAYSCALE);

	imshow("src", src);

	for (int stddev = 10; stddev <= 100; stddev+=10) {
		Mat noise(src.size(), CV_32SC1);
		randn(noise, 0, stddev);

		Mat dst;
		add(src, noise, dst, Mat(), CV_8U);

		string text = format("stddev = %d", stddev);
		putText(dst, text, Point(10, 30), FONT_HERSHEY_SIMPLEX, 1.0, Scalar(255), 1, LINE_AA);

		imshow(text, dst);
		waitKey(0);
	}
	destroyAllWindows();
}

void filter_bilateral() {
	Mat src = imread("..\\..\\resources\\images\\lenna.bmp", IMREAD_GRAYSCALE);

	Mat noise(src.size(), CV_32SC1);
	randn(noise, 0, 5);
	add(src, noise, src, Mat(), CV_8U);

	Mat dst1;
	GaussianBlur(src, dst1, Size(), 5);

	Mat dst2;
	bilateralFilter(src, dst2, -1, 10, 5);

	imshow("src", src);
	imshow("dst1", dst1);
	imshow("dst2", dst2);

	waitKey(0);
	destroyAllWindows();
}

int main() {
	filter_bilateral();
	return EXIT_SUCCESS;
}