Ask Your Question

Revision history [back]

There may be two reasons for the results you got:

  • The noise matrix and the image are not normalized in the same range of [0,1].
  • The stddev value you used (5) was too large.

The code following works for me:

// imGray is the grayscale of the input image
cv::Mat noise = Mat(imGray.size(),CV_64F);
normalize(imGray, result, 0.0, 1.0, CV_MINMAX, CV_64F);
cv::randn(noise, 0, 0.05);
result = result + noise;
normalize(result, result, 0.0, 1.0, CV_MINMAX, CV_64F);
cv::imshow("OUTPUT",result);

And here is the illustration (an input image and Gaussian noise version with stddev=0.05 and 0.1, respectively): image descriptionimage descriptionimage description

There may be two reasons for the results you got:

  • The noise matrix and the image are not normalized in the same range of [0,1].
  • The stddev value you used (5) was too large.

The code following works for me:

// imGray is the grayscale of the input image
cv::Mat noise = Mat(imGray.size(),CV_64F);
normalize(imGray, result, 0.0, 1.0, CV_MINMAX, CV_64F);
cv::randn(noise, 0, 0.05);
result = result + noise;
normalize(result, result, 0.0, 1.0, CV_MINMAX, CV_64F);
cv::imshow("OUTPUT",result);

And here is the illustration (an input image and Gaussian noise version with stddev=0.05 and 0.1, respectively): respectively):

image descriptionimage descriptionimage description

There may be two reasons for the results you got:

  • The noise matrix and the image are not normalized in the same range of [0,1].
  • The stddev value you used (5) was too large.

The code following works for me:

// imGray is the grayscale of the input image
cv::Mat noise = Mat(imGray.size(),CV_64F);
normalize(imGray, result, 0.0, 1.0, CV_MINMAX, CV_64F);
cv::randn(noise, 0, 0.05);
result = result + noise;
normalize(result, result, 0.0, 1.0, CV_MINMAX, CV_64F);
cv::imshow("OUTPUT",result);

And here is the illustration (an input image and Gaussian noise version versions with stddev=0.05 and 0.1, respectively):

image descriptionimage descriptionimage description