1 | initial version |
first of all, GaussianBlur is the wrong one, (it reduces noise by interpolating).
if i assume SNR to be the ratio of original(S) and noise(N) pixel counts, my guess is, that the distribution of the noise values to add is adjusted respective to that.
(e.g., if you fill a whole image with noise, you can use the whole[0..255] range for the value, if you only add a few pixels, you should restrict it to a small range about the mean image value)
you could do this with cv::randn(), and 'a' would be 0, and 'b' would be the std-dev calculated according to the SNR. (just don't ask me how to do that.)
let's just try it on lena:
Mat im = imread("lena.jpg", 0);
Mat noise = Mat(im.size(), CV_8U);
Scalar a(0);
Scalar b(20) ;
randn(noise,a,b);
imshow("noise",noise);
imshow("add",im + noise);
waitKey();
2 | No.2 Revision |
first of all, GaussianBlur is the wrong one, (it reduces noise by interpolating).
if i assume SNR to be the ratio of original(S) and noise(N) pixel counts, my guess is, that the distribution of the noise values to add is adjusted respective to that.
(e.g., if you fill a whole image with noise, you can use the whole[0..255] range for the value, if you only add a few pixels, you should restrict it to a small range about the mean image value)
you could do this with cv::randn(), and 'a' would be 0, and 'b' would be the std-dev calculated according to the SNR. (just don't ask me how to do that.)( for a SNR of 90 (10% noise), you want 255 * 10/100 for b.)
let's just try it on lena:
Mat im = imread("lena.jpg", 0);
Mat noise = Mat(im.size(), CV_8U);
Scalar a(0);
Scalar b(20) ;
randn(noise,a,b);
imshow("noise",noise);
imshow("add",im + noise);
waitKey();
3 | No.3 Revision |
first of all, GaussianBlur is the wrong one, (it reduces noise by interpolating).
if i assume SNR to be the ratio of original(S) and noise(N) pixel counts, my guess is, that the distribution of the noise values to add is adjusted respective to that.interpolating).
(e.g., if also i'd guess, that you fill a whole image with noise, you can use don't 'calculate' the whole[0..255] range for the SNR, but valueset, if you only add a few pixels, you should restrict it to a small range about the mean image value)couple of fixed values, like: we'going to test with 10%, 20%, 50%, 80% noise.
you could do this with cv::randn(), and 'a' would be 0, and 'b' would be the std-dev calculated according to the desired SNR. ( for a SNR of 90 (10% noise), you want 255 * 10/100 for b.)
let's just try it on lena:
Mat im = imread("lena.jpg", 0);
Mat noise = Mat(im.size(), CV_8U);
Scalar a(0);
Scalar b(20) ;
randn(noise,a,b);
imshow("noise",noise);
imshow("add",im + noise);
waitKey();