Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

simulate out-of-focus

2 views
Skip to first unread message

fireman

unread,
Nov 21, 2009, 12:27:56 PM11/21/09
to
Hi everyone:

I am trying to do some simulation of out-of-focus images. I have a
perfect high defination PDF or Jpeg file of a book page with black-
white picture in it. Now image we print it out and use a camera to
capture a picture of it. The camera is out of focus. I would like to
simulation the photo I am going to get with some image processing
technologes.

I tried just blur the image with a gaussian filter. But the result
does not seem to be good.

Could anyone tell me how to do the simulation and what is the
mathematics behine out-of-focus?

Thanks you very much.

FF

Helmut Wabnig

unread,
Nov 21, 2009, 1:10:40 PM11/21/09
to
On Sat, 21 Nov 2009 09:27:56 -0800 (PST), fireman <gec...@gmail.com>
wrote:


You may want to google for "bokeh" and how to simulate it.
http://www.flarg.com/bokeh.html

w.

Helpful person

unread,
Nov 21, 2009, 8:06:58 PM11/21/09
to

The dificulty with such a simulation is that the result depends on the
aberrations of the camera lens. Unless you know the aberration I
don't see how you can obtain accurate results.

www.richardfisher.com

Michael Koch

unread,
Nov 22, 2009, 11:11:33 AM11/22/09
to
Hi,

> I tried just blur the image with a gaussian filter. But the result
> does not seem to be good.

It's better to use a rectangular filter.

Michael

Don Stauffer

unread,
Nov 22, 2009, 12:00:02 PM11/22/09
to


Depends on exactly what you mean. If you want the same blur everywere in
the photo, the blur due to defocus isn't that complex.

However, in a real scene with various depths of objects in different
places in the scene, and it is very hard to do a realistic defocus,
since in a 2D image one does not have real depth information to work
with. There are some editors with "filters" that claim to do this, but
the results I have seen are not great.

In many of these, the results are almost the same as if you select an
object, reverse the selection, and do a gaussian blur on this reversed
selection. But this again gives you the same blur for everything "not
the subject".

Helpful person

unread,
Nov 22, 2009, 4:22:03 PM11/22/09
to
On Nov 22, 12:00 pm, Don Stauffer <stauf...@usfamily.net> wrote:
>
> Depends on exactly what you mean. If you want the same blur everywere in
> the photo, the blur due to defocus isn't that complex.
>
Yes it is. You need to know the lens aberrations. A simple example
is spherical aberration which will blur very differently either side
of the best focus.

www.richardfisher.com

Bob May

unread,
Nov 22, 2009, 6:13:40 PM11/22/09
to
A good first pass would be to use a circular filter that takes the sampled
pixel and spreads it into a much larger round dot. When you sum all of
these dots together you geet the defocxused image. To test the validity of
this, look through the camera finder or screen and see what a distnt light
looks like when defocused. Most lenses will spread the light out into a
round blur evenly but some fancy lenses using reflective optics will also
prouce a black spot in the middle.
Please note that this is a simplistic version of hat happens with a
deefocused image but for your application, it will be quite perfect. Real
scenes with differing focus requirements as things are at different
distances will act a little differently.

--
Bob May

rmay at nethere.com
http: slash /nav.to slash bobmay
http: slash /bobmay dot astronomy.net

fireman

unread,
Nov 22, 2009, 7:23:40 PM11/22/09
to

Thank you very much for all your response.

I found that my problem may be more difficulty. Since you guys are
experts on optics, I would post more. Here is one image taken by a
relative good focus:

http://farm3.static.flickr.com/2561/4125766595_cd165c1755.jpg

As you can see, the barcode has two bars on the very left. If I take
it with a out-of-focus camera, it looks like this:

http://farm3.static.flickr.com/2751/4125766469_2b38892356.jpg

The very left two bars merge into one and looks not symetric on the x
direction.

My question is how to simulate the second imgae (bad focus). what
terms should I consider? Only out of focus or other aberration terms
also? What is the mathematically fomula for other aberration terms?

Thank you very much.

ff

Helmut Wabnig

unread,
Nov 22, 2009, 10:56:30 PM11/22/09
to
On Sun, 22 Nov 2009 16:23:40 -0800 (PST), fireman <gec...@gmail.com>
wrote:

>
>


>Thank you very much for all your response.
>
>I found that my problem may be more difficulty. Since you guys are
>experts on optics, I would post more. Here is one image taken by a
>relative good focus:
>
>http://farm3.static.flickr.com/2561/4125766595_cd165c1755.jpg
>
>As you can see, the barcode has two bars on the very left. If I take
>it with a out-of-focus camera, it looks like this:
>
>http://farm3.static.flickr.com/2751/4125766469_2b38892356.jpg
>
>The very left two bars merge into one and looks not symetric on the x
>direction.
>
>My question is how to simulate the second imgae (bad focus). what
>terms should I consider? Only out of focus or other aberration terms
>also? What is the mathematically fomula for other aberration terms?
>
>Thank you very much.
>
>ff

"ringing"
by the sinc function wherever there is a step
in illuminance.

http://tinyurl.com/yzqznvn

w.

Helmut Wabnig

unread,
Nov 22, 2009, 11:19:19 PM11/22/09
to

Note how sinc is related to the Cornu spiral and bessel functions
http://www.valdostamuseum.org/hamsmith/FrsCrnu.gif
which depicts the actual light distribution after a spatial density
step. This is due to diffraction

http://en.wikipedia.org/wiki/Diffraction
Note the term "Airy disc" which depicts the actual limit
of resolution of any optical instrument.

which is also color dependent
http://tinyurl.com/yhdfjbx

The actual light distribution after a 0 to 100% intensity step
is depicted here (further down the page)
http://tinyurl.com/y8o4sqh

Note that there are regions of more brightness than the original
source. Same applies to "black" but there is of course no
blacker than black and the sinc function appears "rectified"
at the bottom.
Stepping from e.g. 70% brightness to e.g. 30% brightness
will see the full swing of course.

w.

Helmut Wabnig

unread,
Nov 22, 2009, 11:28:02 PM11/22/09
to
On Mon, 23 Nov 2009 05:19:19 +0100, Helmut Wabnig <hwabnig@ .- --- -.
dotat> wrote:


usually one goes the other way round,
restoring sharpness from washed images,
but your search term anyway then would be
"defocus blur" or "defocusing blur"

w.

Helmut Wabnig

unread,
Nov 22, 2009, 11:41:10 PM11/22/09
to
On Mon, 23 Nov 2009 05:19:19 +0100, Helmut Wabnig <hwabnig@ .- --- -.
dotat> wrote:


usually one goes the other way round,
restoring sharpness from washed images,
but your search term anyway then would be
"defocus blur" or "defocusing blur"

http://tinyurl.com/yfet9qe

google: >simulate "defocus blur"<
has some hits too.
http://tinyurl.com/ydpg3c6
around page 300, use the search function.


Me is leaving this topic now, me wants sharp images.
:-)
w.

Helmut Wabnig

unread,
Nov 22, 2009, 11:50:17 PM11/22/09
to
On Mon, 23 Nov 2009 05:41:10 +0100, Helmut Wabnig <hwabnig@ .- --- -.
dotat> wrote:

One last word: focus blur effects ain't symmetrical
because astigmatism comes into play.

w.

Helmut Wabnig

unread,
Nov 22, 2009, 11:58:51 PM11/22/09
to
On Mon, 23 Nov 2009 05:50:17 +0100, Helmut Wabnig <hwabnig@ .- --- -.
dotat> wrote:


hehe, the Linux folks
http://sudakyo.hp.infoseek.co.jp/gimp/fblur/focusblur_e.html

w.

Phil Hobbs

unread,
Nov 23, 2009, 12:11:54 AM11/23/09
to
Helmut Wabnig wrote:
> On Mon, 23 Nov 2009 05:50:17 +0100, Helmut Wabnig<hwabnig@ .- --- -.
> dotat> wrote:
>
>> >On Mon, 23 Nov 2009 05:41:10 +0100, Helmut Wabnig<hwabnig@ .- --- -.
>> >dotat> wrote:
>> >
>>> >>On Mon, 23 Nov 2009 05:19:19 +0100, Helmut Wabnig<hwabnig@ .- --- -.
>>> >>dotat> wrote:

Wow, 5 fups to yourself. Reminds me of Stan Freberg: "The only man in
radio who has to sponsor his own show."

;)

Phil Hobbs

--
Dr Philip C D Hobbs
Principal
ElectroOptical Innovations
55 Orchard Rd
Briarcliff Manor NY 10510
845-480-2058
hobbs at electrooptical dot net
http://electrooptical.net

Helpful person

unread,
Nov 23, 2009, 12:50:59 AM11/23/09
to
On Nov 23, 12:11 am, Phil Hobbs

<pcdhSpamMeSensel...@electrooptical.net> wrote:
>
> Wow, 5 fups to yourself.  Reminds me of Stan Freberg: "The only man in
> radio who has to sponsor his own show."
>
> ;)
>
> Phil Hobbs
>
And most of the posts are either irrelevent or incorrect.

www.richardfisher.com

Helmut Wabnig

unread,
Nov 23, 2009, 1:20:23 AM11/23/09
to

Your opinion.

(One starts with diffraction to help the OP.)

Waiting for your correct posts now.

w.

Helpful person

unread,
Nov 23, 2009, 7:15:46 AM11/23/09
to
On Nov 23, 1:20 am, Helmut Wabnig <hwabnig@ .- --- -. dotat> wrote:
>
> >And most of the posts are either irrelevent or incorrect.
>
> >www.richardfisher.com
>
> Your opinion.
>
> (One starts with diffraction to help the OP.)
>
> Waiting for your correct posts now.
>
> w.

Try reading my previous ones.

www.richardfisher.com

Don Stauffer

unread,
Nov 23, 2009, 9:18:20 AM11/23/09
to

But defocus assumes first order optics- in a simple model all defocus is
the same. Many geometrical aberrations have a pretty simple form. You
need to know the size but the shape is pretty easily modeled. But for
defocus you can even calculate the size of the defocus spot.

Helpful person

unread,
Nov 23, 2009, 11:03:13 AM11/23/09
to

Consider the simple case of spherical aberration. I've put a few
pictures on the web at www.temp.richardfisher.com (I'll keep them
there for about a month.) The first diagram shows the transverse
aberration of almost pure S1 (spherial aberration) at best focus. The
second plot shows spot diagrams at 100 micron focal separations for
the same lens. As you can see there is considerable difference inside
and outside focus. This becomes even more noticable as one adds other
aberrations into the mix.

www.richardfisher.com

Brian

unread,
Nov 24, 2009, 7:08:50 AM11/24/09
to
On Nov 23, 4:03 pm, Helpful person <rrl...@yahoo.com> wrote:
<snip>

You need to know the lens aberrations.  
<snip>

Richard you are right, but surely in a practical photographic
objective the aberrations may be considered sufficiently small, and
diffraction negligible, for the point spread function to be just a top
hat (or a ring, for a reflecting objective). The main difficulty then
becomes one of allocating different PSF diameters to diffferent parts
of the image according to the range of the corresponding object.

While we are on the topic, does anyone know whether the freeware
AbePSF program, written in C ages ago by Nelson Wallace, is available
anywhere on the net? I downloaded it at the time, and still have a
copy but I can't find anyone hosting it now. It is a wonderful
teaching tool, where you define a pupil shape and apodisation, plug in
your Seidel or Zernike terms and get out plots of the point spread
function. Magic!

Brian
Ancient and Modern Optics

Helpful person

unread,
Nov 24, 2009, 7:43:06 AM11/24/09
to

Brian,

I fairly recently was evaluating lenses for CCD cameras for a machine
vision application. You would be amazed at how poor some of the
"standard" lenses are, even those claimed to be superior. These are
often the lenses of choice for users with limited optical knowledge.
Cheap photographic lenses are also questionable. (I wish Nikon still
supported a full range of OEM lenses.)

However, I agree that for good semi professional cameras one would
expect the aberrations to be fairly small, although it doesn't take
much spherical aberration to result in assymetry inside and outside
focus. A more difficult problem (as you pointed out) is variation of
aberration across the field.

www.richardfisher.com

krokodyle

unread,
Nov 25, 2009, 11:22:01 PM11/25/09
to

"Helpful person" <rrl...@yahoo.com> wrote

And most of the posts are either irrelevant or incorrect.
----------------------------------------------------------------
But interesting nonetheless. :-)


0 new messages