De-blurring revisited with Wiener filter using OpenCV

In this post I continue to experiment with the de-blurring of images using the Wiener filter. For details on the Wiener filter, please look at my earlier post “Dabbling with Wiener filter using OpenCV”. Thanks to Egli Simon, Switzerland for pointing out a bug in the earlier post which I have now fixed. The Wiener filter attempts to de-blur by assuming that the source signal is convolved with a blur kernel in the presence of noise. I have also included the blur kernel as estimated by E. Simon in the code. I am including the de-blurring with 3 different blur kernel radii and different values for the Wiener constant K. While the de-blurring is still a long way off there is some success.

One of the reasons I have assumed a non-blind blur kernel and try to de-convolve with that. The Wiener filter tries to minimize the Mean Square Error (MSE) which can be expressed as
e(f) = E[X(f) – X1(f)]^2 – (1)

where e(f) is the Mean Square Error(MSE) in the frequency domain, X(f) is the original image and X1(f) is the estimated signal which we get by de-convolving the Wiener filter with the observed blurred image i.e. and E[] is the expectation

Sai – 1. I remember seeing somewhere that a Gaussian smooth needs to be applied after the noise function is performed.
2. I think it should be im->height + rowLength -1 . We need to add the size of the blur kernel. The im->height + 3 -1 ( is code that was there with 3 x 3 blur kernl and was not removed. Will correct it.
Do let me know your thoughts. Thanks for your comments.

val_noise[383*i+j] = rand() % 128; implies..you are adding a value between 0 and 128 to each point, which makes your image more luminant, but shouldn’t you add AND/OR substract value to have a real noise ? im afraid you induce a bias on luminance there…

furthermore…is this really the noise we should use ? shouldnt we add random points in the image instead of adding random values to each pixel ?