Ask Your Question

Revision history [back]

    Mat input = imread("inputImage.png");
    Mat imGray;
    cvtColor(input,imGray,CV_BGR2GRAY);
    cv::Mat noise = Mat(imGray.size(),CV_64F);
    Mat result;
    normalize(imGray, result, 0.0, 1.0, CV_MINMAX, CV_64F);
    cv::randn(noise, 0, 0.1);
    result = result + noise;
    normalize(result, result, 0.0, 1.0, CV_MINMAX, CV_64F);
    result.convertTo(result, CV_32F, 255, 0);
    cv::imwrite("result.png",result);
    cv::waitKey(0);