Perform an image deconvolution using FFTs and Python

In summary, the objective of this problem is to deconvolve a blurry image to obtain a non-blurry image. The blurred image is given to us in a text file, and the Gaussian point spread function is as follows: $$f(x, y) = e^{-\frac{x^2 + y^2}{2 \sigma^2}},$$ where ##\sigma = 25##. Parts a) and b) are where we read in the image into a numpy array and create a density plot, respectively. In part c), we imagine a mesh where the ##x## and ##y## axes both go from [-512, 511], which is what we use to create our density
  • #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.
 
Technology news on Phys.org
  • #2
I visited your github link, but I don't have time at the moment to review all of your code. This definitely looks like an interesting problem.
Perhaps you could get another 1024 x 1024 known image then try to convolve it with the function, to make sure you are doing it right, then try to reconstruct the image back to what you originally had. Or try a small Numpy array of numbers, something like a 16x16, or even smaller. This may reveal something.
 
  • Like
Likes kaashmonee

1. What is image deconvolution?

Image deconvolution is a technique used in image processing to remove blur or distortion from an image. It involves reversing the effects of a convolution, which is a mathematical operation used to blur an image. By deconvolving an image, we can obtain a sharper and more detailed version of the original image.

2. What is the role of FFTs in image deconvolution?

FFT stands for Fast Fourier Transform, which is a mathematical algorithm used to transform an image from its spatial domain to its frequency domain. In image deconvolution, FFTs are used to analyze and manipulate the frequency components of an image, allowing us to remove blur and improve the overall quality of the image.

3. How is Python used in image deconvolution?

Python is a popular programming language that offers a wide range of libraries and tools for scientific computing and image processing. In image deconvolution, Python is used to implement the algorithms and techniques required for the deconvolution process, such as FFTs, filtering, and optimization.

4. What are the advantages of using FFTs and Python for image deconvolution?

FFT-based deconvolution techniques are faster and more accurate compared to traditional methods, which is why they are commonly used in image processing. Python, on the other hand, is a versatile and user-friendly language that allows for efficient and customizable implementation of deconvolution algorithms.

5. Are there any limitations to using FFTs and Python for image deconvolution?

Although FFT-based deconvolution is a powerful technique, it is not suitable for all types of image blur or distortion. In some cases, other methods such as blind deconvolution may be more effective. Additionally, while Python offers a wide range of tools for image processing, it may not be the best choice for real-time or high-performance applications.

Similar threads

Replies
13
Views
1K
  • Programming and Computer Science
Replies
1
Views
1K
  • Programming and Computer Science
Replies
7
Views
3K
  • Programming and Computer Science
Replies
5
Views
2K
  • Programming and Computer Science
Replies
1
Views
3K
  • Programming and Computer Science
Replies
4
Views
4K
Replies
2
Views
286
  • Programming and Computer Science
Replies
3
Views
2K
  • Programming and Computer Science
Replies
5
Views
1K
  • Programming and Computer Science
Replies
2
Views
16K
Back
Top