How to make intensity attenuated image or defocused image

12 views (last 30 days)
when an image is imaged through a lens, if the screen is on the imaging point then focused image would be shown. But the screen is on the wrong distance then blurred image should be shown. I want a know how to make this situation respect to the distance between the lens and the screen. Actually to make focused image is easy cause it can be solved just pixel mapping but I want to know how to make blurred image when it is defocused. Moreover when two images, which are located different location from a lens, are imaged through a lens then one image is focused and the other is defocused on the fixed screen position. (the pixel on the original image will be magnified respect to the magnification of the lens. I can handel the magnification thing.)

Accepted Answer

David Young
David Young on 11 Dec 2011
Your question is not very clear, but I think you want to know how to take a focused image and generate a new image that simulates the situation when the camera's lens is defocused.
The basic approach is to convolve the focused image with the point spread function of the lens. What you use for the PSF depends on how accurate you want to be, but a simple approximation might be OK. Thus you might approximate the PSF with a circular disk, whose radius depends on the amount of defocusing needed, like this:
% some data - focused image, grey levels in range 0 to 1
focused_image = double(rgb2gray(imread('saturn.png')))/256;
% approximate psf as a disk
r = 10; % defocusing parameter - radius of psf
[x, y] = meshgrid(-r:r);
disk = double(x.^2 + y.^2 <= r.^2);
disk = disk./sum(disk(:));
defocused_image = conv2(focused_image, disk, 'valid');
imshow(defocused_image);
Another possible PSF is a Gaussian function. An easy way to apply that is to use gsmooth2 from this FEX contribution.
  1 Comment
David Young
David Young on 2 Jan 2015
I've been asked about papers dealing with this area.
The idea that an observed image is modelled as the convolution of a perfectly sharp image with the PSF of the imaging system is an old one, and is textbook material rather than something to be found in research papers.
Many image processing and analysis textbooks have something relating to the core idea. Examples include the following, which all have sections setting out the basic result (look up point-spread function or restoration in the indexes):
  • Computer Vision: A Modern Approach by Forsyth and Ponce
  • Image Based Measurement Systems by van der Heijden
  • Digital Image Processing by Gonzalez and Wintz
  • Digital Image Processing using MATLAB by Gonzalez, Woods and Eddins
Of these, van der Heijden gives the most rigorous account (p. 20).
The Wikipedia articles on point spread function and circle of confusion are relevant and may also be helpful to some extent.

Sign in to comment.

More Answers (2)

Bjorn Gustavsson
Bjorn Gustavsson on 11 Dec 2011
If you want to do real optical ray-tracing through the imaging lens, there are a couple of submissions in the file exchange:
Otherwise you might get away with simply estimating the spot-size as a function of screen displacement from the ideal focal distance, and then simply convolve your image with a 2-D low-pass filter with the corresponding point-spread-size.
HTH

Image Analyst
Image Analyst on 11 Dec 2011
You need to convolve your perfectly focused image with the point spread function. You can do the optical math to figure it out exactly, or you can just guess.
blurredImage = conv2(focusedImage, psf);

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!