Forums

"Repairing" an out-of- focus picture

Started by Nitram May 29, 2010
Hi, 

My question might be simplistic as neither optics nor image processing is
my field. 

Firstly, I was wondering if it is possible to compensate for a picture
taken by an out-of-focus digital camera by doing a 2D deconvolution on it
(MMSE filtering or something like that), in order to recover  the in-focus
picture

Secondly, can the optical transfer function between a properly focused
picture and an out of focus picture be parameterized in such a way that a
user could recover the image by gradually varying that parameter until the
image is in focus?  If this is indeed possible, what is that transfer
function? (any references to existing literature would be welcome).

Thank you for your help.

On 5/28/2010 11:52 PM, Nitram wrote:
> Hi, > > My question might be simplistic as neither optics nor image processing is > my field. > > Firstly, I was wondering if it is possible to compensate for a picture > taken by an out-of-focus digital camera by doing a 2D deconvolution on it > (MMSE filtering or something like that), in order to recover the in-focus > picture
Yes, but not perfectly. Do you remember how the Hubble telescope started out?
> Secondly, can the optical transfer function between a properly focused > picture and an out of focus picture be parameterized in such a way that a > user could recover the image by gradually varying that parameter until the > image is in focus? If this is indeed possible, what is that transfer > function? (any references to existing literature would be welcome).
I think you need to start with the blurred image of a point somewhere in the frame. It is certainly easiest to get the point-spread function that way.
> Thank you for your help.
Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������
Nitram <morris.vian@n_o_s_p_a_m.gmail.com> wrote:

>Firstly, I was wondering if it is possible to compensate for a picture >taken by an out-of-focus digital camera by doing a 2D deconvolution on it >(MMSE filtering or something like that), in order to recover the in-focus >picture
Sure, that's what they did with the Hubble before they had a chance to physically correct the out-of-focus objects. It only works on a bright clean picture though, as you are amplifying noise. That's about all I know. Steve
Jerry Avins <jya@ieee.org> wrote:
> On 5/28/2010 11:52 PM, Nitram wrote:
>> My question might be simplistic as neither optics nor image processing is >> my field.
>> Firstly, I was wondering if it is possible to compensate for a picture >> taken by an out-of-focus digital camera by doing a 2D deconvolution on it >> (MMSE filtering or something like that), in order to recover the in-focus >> picture
> Yes, but not perfectly. Do you remember how the Hubble > telescope started out?
Specifically, the transfer function of Hubble was known extrememly accurately. They knew exactly what (wrong) curve had been applied to the mirror.
>> Secondly, can the optical transfer function between a properly focused >> picture and an out of focus picture be parameterized in such a way that a >> user could recover the image by gradually varying that parameter until the >> image is in focus? If this is indeed possible, what is that transfer >> function? (any references to existing literature would be welcome).
Get the book "Deconvolution of Images and Spectra" which has a good explanation of non-linear deconvolution. As the intensity can't go below zero, the non-linear techniques are probably best. Also, you need a really good signal to noise ratio. The early hubble pictures were of bright objects for that reason.
> I think you need to start with the blurred image of a point somewhere in > the frame. It is certainly easiest to get the point-spread function that > way.
-- glen
On May 28, 11:52&#2013266080;pm, "Nitram" <morris.vian@n_o_s_p_a_m.gmail.com>
wrote:
> > Firstly, I was wondering if it is possible to compensate for a picture > taken by an out-of-focus digital camera by doing a 2D deconvolution on it > (MMSE filtering or something like that), in order to recover &#2013266080;the in-focus > picture >
my understanding is that the in-focus image is run through a sorta low- pass filter in 2D which blurs it. maybe the 2D deconvolution can be run through a compensating high-pass filter, if you knew the characteristics of the blurring filter closely.
> Secondly, can the optical transfer function between a properly focused > picture and an out of focus picture be parameterized in such a way that a > user could recover the image by gradually varying that parameter until the > image is in focus? &#2013266080;If this is indeed possible, what is that transfer > function? (any references to existing literature would be welcome).
i really don't know what the LPF characteristics of blurring would be if a well-shaped lens in the camera is just moved away from the correct focal length. it seems like i should be able to figure that out (as a function of the deviation from the correct focal position) but i don't know where to begin to set up the problem. maybe someone else (like Clay or Glen or some other physiker) would know. you guys, if it's a good lens, just bumped away from the correct position by a little, does it change the impulse response (in 2D) from an impulse (nice sharp image) to a rect() function? the farther the lens is outa focus, the wider the rect() function? deconvolving a rect() function is a sorta bitch because of dividing by zero in the frequency domain. just a guess. r b-j
robert bristow-johnson  <rbj@audioimagination.com> wrote:

>On May 28, 11:52&#2013266080;pm, "Nitram" <morris.vian@n_o_s_p_a_m.gmail.com>
>> Firstly, I was wondering if it is possible to compensate for a picture >> taken by an out-of-focus digital camera by doing a 2D deconvolution on it >> (MMSE filtering or something like that), in order to recover &#2013266080;the in-focus >> picture
>my understanding is that the in-focus image is run through a sorta low- >pass filter in 2D which blurs it. maybe the 2D deconvolution can be >run through a compensating high-pass filter, if you knew the >characteristics of the blurring filter closely.
Yes. In the simplest case I believe the blur of defocusing is like a 2-D sinc function. Steve
>> Secondly, can the optical transfer function between a properly focused >> picture and an out of focus picture be parameterized in such a way that a >> user could recover the image by gradually varying that parameter until the >> image is in focus? &#2013266080;If this is indeed possible, what is that transfer >> function? (any references to existing literature would be welcome). > >i really don't know what the LPF characteristics of blurring would be >if a well-shaped lens in the camera is just moved away from the >correct focal length. it seems like i should be able to figure that >out (as a function of the deviation from the correct focal position) >but i don't know where to begin to set up the problem. > >maybe someone else (like Clay or Glen or some other physiker) would >know. you guys, if it's a good lens, just bumped away from the >correct position by a little, does it change the impulse response (in >2D) from an impulse (nice sharp image) to a rect() function? the >farther the lens is outa focus, the wider the rect() function? >deconvolving a rect() function is a sorta bitch because of dividing by >zero in the frequency domain. > >just a guess. > >r b-j >
On 5/29/2010 3:04 PM, robert bristow-johnson wrote:
> On May 28, 11:52 pm, "Nitram"<morris.vian@n_o_s_p_a_m.gmail.com> > wrote: >> >> Firstly, I was wondering if it is possible to compensate for a picture >> taken by an out-of-focus digital camera by doing a 2D deconvolution on it >> (MMSE filtering or something like that), in order to recover the in-focus >> picture >> > > my understanding is that the in-focus image is run through a sorta low- > pass filter in 2D which blurs it. maybe the 2D deconvolution can be > run through a compensating high-pass filter, if you knew the > characteristics of the blurring filter closely. > >> Secondly, can the optical transfer function between a properly focused >> picture and an out of focus picture be parameterized in such a way that a >> user could recover the image by gradually varying that parameter until the >> image is in focus? If this is indeed possible, what is that transfer >> function? (any references to existing literature would be welcome). > > i really don't know what the LPF characteristics of blurring would be > if a well-shaped lens in the camera is just moved away from the > correct focal length. it seems like i should be able to figure that > out (as a function of the deviation from the correct focal position) > but i don't know where to begin to set up the problem.
It depends in part on the shape of the aperture. A mirror lens makes donut-shaped "circles" of confusion. With ordinary lenses, you can count the number of blades in the diaphragm if they're few enough. All of that is summed up as "bokeh" See http://en.wikipedia.org/wiki/Bokeh for etymology and more.
> maybe someone else (like Clay or Glen or some other physiker) would > know. you guys, if it's a good lens, just bumped away from the > correct position by a little, does it change the impulse response (in > 2D) from an impulse (nice sharp image) to a rect() function? the > farther the lens is outa focus, the wider the rect() function? > deconvolving a rect() function is a sorta bitch because of dividing by > zero in the frequency domain.
Not quite. Which is to say, that the point-turned-disc isn't necessarily illuminated uniformly. Jerry -- Engineering is the art of making what you want from things you can get. &#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;
On 05/29/10 15:04, robert bristow-johnson wrote:
> On May 28, 11:52 pm, "Nitram" <morris.vian@n_o_s_p_a_m.gmail.com> > wrote: >> >> Firstly, I was wondering if it is possible to compensate for a picture >> taken by an out-of-focus digital camera by doing a 2D deconvolution on it >> (MMSE filtering or something like that), in order to recover the in-focus >> picture >> > > my understanding is that the in-focus image is run through a sorta low- > pass filter in 2D which blurs it. maybe the 2D deconvolution can be > run through a compensating high-pass filter, if you knew the > characteristics of the blurring filter closely. > >> Secondly, can the optical transfer function between a properly focused >> picture and an out of focus picture be parameterized in such a way that a >> user could recover the image by gradually varying that parameter until the >> image is in focus? If this is indeed possible, what is that transfer >> function? (any references to existing literature would be welcome). > > i really don't know what the LPF characteristics of blurring would be > if a well-shaped lens in the camera is just moved away from the > correct focal length. it seems like i should be able to figure that > out (as a function of the deviation from the correct focal position) > but i don't know where to begin to set up the problem. > > maybe someone else (like Clay or Glen or some other physiker) would > know. you guys, if it's a good lens, just bumped away from the > correct position by a little, does it change the impulse response (in > 2D) from an impulse (nice sharp image) to a rect() function? the > farther the lens is outa focus, the wider the rect() function? > deconvolving a rect() function is a sorta bitch because of dividing by > zero in the frequency domain. > > just a guess. > > r b-j >
A decent reference is Goodman's _Introduction to Fourier Optics_. (You can see chunks of it in Google books.) He derives the OTF of of an out-of-focus imager with a square pupil (because the calculations are harder for the more realistic case of a circular pupil); for sufficiently large defocussing the result is approximately a 2D sinc (the Fourier transform of your rect), but for smaller focusing errors this approximation (which ignores diffraction effects) breaks down. For a circular pupil and large defocussing I guess one should expect the PSF to look like a disk, which will result in an OTF involving Bessel functions. I believe it is not unusual for people to (try to) deconvolve the resulting blur by using Wiener filtering, which at least attempts to account for the zeros in the frequency domain. How well this will work will probably depend on any number of factors (SNR in the images, amount of focusing error, etc.). Robert E. Beaudoin
On May 29, 1:51&#2013266080;pm, spop...@speedymail.org (Steve Pope) wrote:
>
...
> > Yes. &#2013266080;In the simplest case I believe the blur of defocusing is > like a 2-D sinc function. > > Steve >
Sinc functions go negative in the first sidelobe. None of my blurred pictures have negative values. Dale B. Dalrymple
dbd  <dbd@ieee.org> wrote:

>On May 29, 1:51&#2013266080;pm, spop...@speedymail.org (Steve Pope) wrote:
>> Yes. &#2013266080;In the simplest case I believe the blur of defocusing is >> like a 2-D sinc function.
>Sinc functions go negative in the first sidelobe. None of my blurred >pictures have negative values.
Funny how negative audio sounds just the same as positive audio too. S.