- #1
kaashmonee
- 7
- 1
Homework Statement
[/B]
This problem is from Mark Newman's Computational Physics, problem 7.9, found at
http://www-personal.umich.edu/~mejn/cp/exercises.html. The problem gives us a blurry convolved image, according to a Gaussian point spread function and our objective is to deconvolve it to obtain a non-blurry image. The blurry image is given to us in a text file that we read into a numpy array, and the Gaussian point spread function is as follows: $$f(x, y) = e^{-\frac{x^2 + y^2}{2 \sigma^2}},$$ where ##\sigma = 25##.
In part a), we are given a 1024 x 1024 image that we read into a numpy array. In part b), we create a density plot, of the same dimensions as the original photo, (1024 x 1024) using the Gaussian point spread function. We imagine a mesh where the ##x## and ##y## axes both go from [-512, 511], which is what we use to create our density plot.
The third part requests that we perform the Fourier transforms using the rfft2 and irfft2 numpy functions by reading in the blurred photo, calculating the point spread function, Fourier transforming both, dividing one by the other, and finally performing an inverse transform to get the unblurred photo and displaying it on the screen.
Homework Equations
The Gaussian point spread function: $$f(x, y) = \text{exp}\Big(- \frac{x^2 + y^2}{2 \sigma^2}\Big), \sigma = 25.$$
The Attempt at a Solution
I'm attaching my GitHub repo with my solution here: (https://github.com/kaashmonee/image-deconvolution/blob/master/decon.ipynb) I've solved most parts of the problem so far. But, for some reason, the deconvolved image seems to not show anything very useful. Since my deconvolved image only really depends on my density plot and the blurred image, I have to guess that there is an issue with the way I've made my density plot since the blurred image seems to look okay.
In order to create my density plot, I've constructed a mesh that goes from [-512, 511] on the x and y axes. I then, for each location in the mesh, save the result of applying the point spread function, and get the pattern that we are supposed to see, according to the book. The function is not very complicated, so I am failing to see where I would be going wrong. I set up the axes correctly and the density plot correctly (or so it seems), so I am guessing that there is perhaps a more nuanced error within either my density plot or my blurred image which I am unable to identify at the moment.
Thank you very much.