# 0.5 Focus detection

 Page 1 / 1

Focus detection

Focus Detection:

One important aspect of images is focus. While qualitatively deciding whether an image is in focus or not is relatively easy, quantitatively it can be quite difficult. One way to detect whether or not an image is in focus is by examining its power spectrum.

## Power spectrum and focus

It is generally assumed that natural images are made up of fractals, and it can be shown that the power spectrum (power as a function of frequency) of a natural image should fall off as

$\frac{1}{{f}^{2}}$

where f is the frequency.

As an image goes out of focus, it becomes blurred. That is to say that the edges are less sharp. If an image contains less sharp edges, its power spectrum will contain less high-frequency power. The power spectrum of an out-of-focus image should, therefore, fall off faster than an in-focus image.

So by calculating the power spectrum and examining its linear regression on a loglog plot (log[power] vs log[frequency]), we can get an indicator of focus.

## Calculating the power spectrum

The power specturm is simply the square of the two dimensional Fourier transform:

$P\left({k}_{x},{k}_{y}\right)=\mid F{\left({k}_{x},{k}_{y}\right)}^{2}\mid$

where the two dimensional Fourier transform is given by:

$F\left({k}_{x},{k}_{y}\right)=\sum _{x=0}^{N-1}\sum _{y=0}^{N-1}f{\left({k}_{x},{k}_{y}\right)}^{2}{e}^{\frac{-\mathrm{j2\pi }}{N}\left({\text{xk}}_{x}+{\text{yk}}_{y}\right)}$

Note that denotes an individual image pixel. You may have noticed that the above equations define a square image. While a non-symmetric two dimensional Fourier transform exists, using square images eases the process.

Because whether or not an image is in focus depends on the magnitude of power as a function of frequency, once the two dimensional power spectrum is computed as above, we radially average the spectrum. That is, the average of the values which lie on a circle a distance R from the origin is taken. Because frequency increases linearly in all directions from the origin, radially averaging the power spectrum gives the average power at one frequency , effectively collapsing the two dimensional spectrum to one dimension. It should be noted that $F\left({k}_{x},{k}_{y}\right)$ has been centered around baseband, meaning the frequency of the rotionally averaged power spectrum extends from 0 to N/2 -1.

The power spectrum’s falloff on a loglog plot can now be examined to determine focus.

## Illustrative example of focus analysis on entire image

The following images show the results of a linear regression of the power spectrum on a loglog plot for an in-focus image and an out-of-focus image.

As expected, the out-of-focus image yielded a linear regression with a slope of -3.3, while the in-focus image yielded a linear regression with a slope of -2.3, indicating that the out-of-focus image has fewer high frequency components.

## Determining regions of focus

Because frequency and power should be related exponentially as stated before, the loglog plot should display a linear relationship. Taking the linear regression of the loglog plot leads to an estimate of the frequency fall off. For example, if the linear regression where to return a slope of -2, we know that the power spectrum falls off as $\frac{1}{{f}^{2}}$ .

The same principles used to determine whether or not an image is in focus can be used to determine what region of an image is in focus. Because cameras can only focus on one spatial plane, in a single picture certain objects will be more in focus than others. To determine which region of an image is in focus, one simply has to divide the image into separate spatial region and then use the methods described above on each region. The region whose power spectrum conforms most closely to the $\frac{1}{{f}^{2}}$ fall off can be considered the center of focus in the image.

how do you translate this in Algebraic Expressions
why surface tension is zero at critical temperature
Shanjida
Need to simplify the expresin. 3/7 (x+y)-1/7 (x-1)=
. After 3 months on a diet, Lisa had lost 12% of her original weight. She lost 21 pounds. What was Lisa's original weight?
what is biological synthesis of nanoparticles
what's the easiest and fastest way to the synthesize AgNP?
China
Cied
types of nano material
I start with an easy one. carbon nanotubes woven into a long filament like a string
Porter
many many of nanotubes
Porter
what is the k.e before it land
Yasmin
what is the function of carbon nanotubes?
Cesar
I'm interested in nanotube
Uday
what is nanomaterials​ and their applications of sensors.
what is nano technology
what is system testing?
preparation of nanomaterial
Yes, Nanotechnology has a very fast field of applications and their is always something new to do with it...
what is system testing
what is the application of nanotechnology?
Stotaw
In this morden time nanotechnology used in many field . 1-Electronics-manufacturad IC ,RAM,MRAM,solar panel etc 2-Helth and Medical-Nanomedicine,Drug Dilivery for cancer treatment etc 3- Atomobile -MEMS, Coating on car etc. and may other field for details you can check at Google
Azam
anybody can imagine what will be happen after 100 years from now in nano tech world
Prasenjit
after 100 year this will be not nanotechnology maybe this technology name will be change . maybe aftet 100 year . we work on electron lable practically about its properties and behaviour by the different instruments
Azam
name doesn't matter , whatever it will be change... I'm taking about effect on circumstances of the microscopic world
Prasenjit
how hard could it be to apply nanotechnology against viral infections such HIV or Ebola?
Damian
silver nanoparticles could handle the job?
Damian
not now but maybe in future only AgNP maybe any other nanomaterials
Azam
Hello
Uday
I'm interested in Nanotube
Uday
this technology will not going on for the long time , so I'm thinking about femtotechnology 10^-15
Prasenjit
can nanotechnology change the direction of the face of the world
At high concentrations (>0.01 M), the relation between absorptivity coefficient and absorbance is no longer linear. This is due to the electrostatic interactions between the quantum dots in close proximity. If the concentration of the solution is high, another effect that is seen is the scattering of light from the large number of quantum dots. This assumption only works at low concentrations of the analyte. Presence of stray light.
the Beer law works very well for dilute solutions but fails for very high concentrations. why?
how did you get the value of 2000N.What calculations are needed to arrive at it
Privacy Information Security Software Version 1.1a
Good
Got questions? Join the online conversation and get instant answers!