# Patent

## Title
Method for processing a digital image

## Abstract

A method and system for processing a distorted digital image B that is a convolution of an undistorted image F and a point spread function. Noise is removed from the image B so as to produce an image B′ of reduced noise. The image F is then obtained based upon a calculation involving the image B′.

## Background
FIELD OF THE INVENTION
This invention relates to methods for processing a digital image.
BACKGROUND OF THE INVENTION
Global distortion, or blurring, of a picture can arise from various factors such as distortion due to out-of-focus optics and linear translation or shaking of the camera during the exposure time.
Blurring of a digital image may be described by means of a convolution:

B0(x)=∫dx′F(x′)h(x−x′)  (1)

where B0(x) is the intensity of the pixel at the address x=(x,y) in the distorted picture, x being a two-dimensional vector, F(x) is the intensity of the pixel x in the undistorted image, and h(x) is the so-called point spread function (PSF) that describes the distortion. The function B0(x) is typically obtained as the output from a digital camera. The PSF for an image distorted by out-of-focus optics, for example, can be described in a first approximation by a function h that is constant inside a circle of radius r and h(x)=0 outside the circle.
Rectifying a distorted image involves determining the function F given the functions B0 and h. The convolution (1) can be Fourier transformed to yield

{tilde over (B)}0(q)={tilde over (F)}(q)·{tilde over (h)}(q)  (2)

where “{tilde over ( )}” represents the Fourier transform. Hence,





  
    
      
        
          
            F
            ~
          
          ⁡
          
            (
            q
            )
          
        
        =
        
          
            
              
                B
                ~
              
              0
            
            ⁡
            
              (
              q
              )
            
          
          
            
              h
              ~
            
            ⁡
            
              (
              q
              )
            
          
        
      
    
    
      
        (
        3
        )
      
    
  




In principle, therefore, F(x) may be obtained from the inverse Fourier transform of {tilde over (B)}(q)/{tilde over (h)}(q). In practice, however, this solution is characterized by a very low signal-to-noise ratio (SNR), due to amplification of noise at frequencies q at which {tilde over (h)}(q) is very small.

SUMMARY OF THE INVENTION
In the following description and set of claims, two explicitly described, calculable or measurable variables are considered equivalent to each other when the two variables are substantially proportional to each other.
The present invention provides a method for rectifying a distorted digital image B0(x) to produce a rectified image F(x). In accordance with the invention, noise is removed from the function {tilde over (B)}0(q) before applying the inverse Fourier transform to the right side of equation. (3). A noise function N is used to evaluate the amount of noise for functions {tilde over (B)}(q) that deviate slightly from {tilde over (B)}0(q) and a new function {tilde over (B)}(q) is selected that deviates slightly from {tilde over (B)}0(q) and that minimizes the noise function N. In a preferred embodiment of the invention, the noise N in an image B(x) is obtained based upon a calculation involving the gradient of the function P obtained by inverse Fourier transform of {tilde over (B)}(q)/{tilde over (h)}(q). In a most preferred embodiment, the noise N is calculated according to the equation:

N=∫∇P(x)·∇P′(x)dx  (4)

where “*” indicates complex conjugate. Equation (4) may be written in the equivalent form

N=∫dq·q2∥{tilde over (D)}(q)∥2·∥{tilde over (B)}0(q)∥2  (4)

where D(x) is the so-called deconvolution filter (DCF) defined as 1/h(x), wherein h(x) is the point spread function characteristic of the distortion, and q is a two-dimensional vector in Fourier space. The rectified image F(x) may then be obtained by calculating the inverse Fourier transform of the right side of equation (3) using the thus obtained B(x). However, a pattern characteristic of the DCF may have been superimposed on the obtained F(x). This pattern originates in the DCF and is correlated with it. In the most preferred embodiment, this pattern is removed.

The invention thus concerns a method for processing a digital image B1, the image B1 being a convolution of an image F and a point spread function h, comprising removing noise from the image B1 so as to produce an image B′ of reduced noise, and calculating F based upon B′.
The invention further concerns a method for processing a deconvoluted image B, the image B having been deconvoluted according to a deconvolution filter D, the method comprising reducing correlation between the image and the deconvolution filter.
Yet still further the invention concerns a method for processing a digital image B1, the image B1 being a convolution of an image F and a point spread function h comprising the steps of:

    
    
        (a) removing noise from the image B1 so as to produce an image B′ of reduced noise;
        (b) obtaining function {tilde over (P)}1(q) according to the algebraic expression {tilde over (P)}1(q)={tilde over (B)}′(q)/{tilde over (h)}(q);
        (c) reducing correlation between {tilde over (P)}1 and 1/{tilde over (h)} so as to product a function {tilde over (P)}′ of reduced correlation; and
        obtaining a rectified image F by inverse Fourier transform of {tilde over (P)}′(q).
    
    


By yet still another aspect the invention concerns a method for obtaining a radius r of a point spread function h describing an out-of-focus distortion of a digital image B, the method comprising a step of calculating a gradient at a plurality of pixels in the image B.
By a further aspect the invention concerns a program storage device readable by machine, tangibly embodying a program of instructions executable by the machine to perform method steps for processing a digital image B1, the image B1 being a convolution of an image F and a point spread function h, comprising removing noise from the image B1 so as to produce an image B′ of reduced noise, and calculating F based upon B′.
Further the invention concerns a program storage device readable by machine, tangibly embodying a program of instructions executable by the machine to perform method steps for processing a deconvoluted image B, the image B having been deconvoluted according to a deconvolution filter D, the method comprising reducing correlation between the image and the deconvolution filter.
Yet still further the invention concerns a program storage device readable by machine, tangibly embodying a program of instructions executable by the machine to perform method steps for processing a digital image B1, the image B1 being a convolution of an image F and a point spread function h comprising the steps of.

    
    
        (a) removing noise from the image B1 so as to produce an image B′ of reduced noise;
        (b) obtaining function {tilde over (P)}1(q) according to the algebraic expression {tilde over (P)}1(q)={tilde over (B)}′(q)/{tilde over (h)}(q);
        (c) reducing correlation between {tilde over (P)}1 and {tilde over (1)}/h so as to product a function {tilde over (P)}′ of reduced correlation; and
        (d) obtaining a rectified image F by inverse Fourier transform of {tilde over (P)}′(q).
    
    


Further the invention concerns a program storage device readable by machine, tangibly embodying a program of instructions executable by the machine to perform method steps for obtaining a radius r of a point spread function h describing an out-of-focus distortion of a digital image B, the method comprising a step of calculating a gradient at a plurality of pixels in the image B.



BRIEF DESCRIPTION OF THE DRAWINGS
In order to understand the invention and to see how it maybe carried out in practice, a preferred embodiment will now be described, by way of non-limiting example only, with reference to the accompanying drawings, in which:
FIG. 1 shows a digital image showing distortion due to out of focus optics;
FIG. 2 shows a histogram of heights of steps in the image of FIG. 1;
FIG. 3 shows the result of rectifying the image of FIG. 1 in accordance with the invention; and
FIG. 4 shows a system for digital image processing in accordance with an embodiment of the invention.



DETAILED DESCRIPTION OF A PREFERRED EMBODIMENT
In a preferred embodiment, as shown in FIG. 4, a system 20 for digital image processing comprises a camera 22 and an image processor 24 (which may be a separate unit as shown or may be integrated in the camera). The camera typically comprises objective optics 26, having a certain point spread function (PSF). Optics 26 focus an image onto an image sensor 28, comprising multiple pixels 30. Image sensor 28 outputs an image that is distorted, for reasons explained below. Digital image processor 24 processes the image to remove noise and distortion. The image processor may comprise a programmable processor, which operates in accordance with program instructions stored in a program storage device 32. Prior to removing noise from the distorted image B0(x), the function B0(x) is preprocessed as follows. Firstly, if the output signal B(x) from the digital camera is not linear with the input intensities I(x), the image B0(x) is transformed to make the signal linear with the intensity. This is accomplished by applying to the signal B0(x) the inverse transformation that was applied by the camera to the intensities in order to produce the signal B(x). For example, if the camera performs a transformation on the intensity of the form B(x)=A(A−1I(x))γ, where A is a scaling factor and γ a fixed exponent, the signal B0(x) is transformed by A(B0(x)/A)γ−1 to obtain a new B(x). For many digital cameras, γ=1⁄3 in order to make the obtained image more pleasing to the eye. The function B(x) is then transformed so as to decay smoothly at the edges to zero in order to make the image periodic at the edges. The function B1(x) produced by this preprocessing is operated on in accordance with the invention as described in detail below.
In accordance with the invention, a noise function N is used to evaluate the amount of noise for functions {tilde over (B)}(q) that deviate slightly from {tilde over (B)}1(q) and a new function {tilde over (B)}(q) is selected that deviates slightly from {tilde over (B)}1(q) and that minimizes the noise function N. In a preferred embodiment of the invention, the noise N in an image {tilde over (B)}(q) is obtained based upon a calculation involving the gradient of the function P obtained by inverse Fourier transform of {tilde over (B)}(q)/{tilde over (h)}(q). In a most preferred embodiment, the noise N is calculated according to the equation:

N=∫∇P(x)·∇*(x)dx

or equivalently, N=∫dq·q2∥{tilde over (D)}(q)∥2·∥{tilde over (B)}(q)∥2  (4)

where D(x) is the deconvolution filter defined as 1/h (x), where h(x) is the point spread function characteristic of the distortion.
A function B(x) of essentially minimal noise that deviates only slightly from B1(x) may be found by evaluating the variation of N with respect to B*(q), (∂N/∂{tilde over (B)}*(q)). For example, a sequence of functions {tilde over (B)}1(q) may be generated iteratively by:




  
    
      
        B
        ~
      
      
        l
        +
        1
      
    
    ⁡
    
      (
      q
      )
    
  
  =
  
    
      
        
          B
          ~
        
        l
      
      ⁡
      
        (
        q
        )
      
    
    -
    
      ɛ
      ⁢
      
        
          
            ∂
            N
          
          
            
              ∂
              
                
                  B
                  ~
                
                i
              
            
            *
            
              (
              q
              )
            
          
        
        .
      
    
  




In the most preferred embodiment, N is given by (4) so that




  
    
      
        
          
            
              B
              ~
            
            
              l
              +
              1
            
          
          ⁡
          
            (
            q
            )
          
        
        =
        
          
            
              
                
                  B
                  ~
                
                i
              
              ⁡
              
                (
                q
                )
              
            
            -
            
              ɛ
              ⁢
              
                
                  ∂
                  N
                
                
                  
                    ∂
                    
                      
                        B
                        ~
                      
                      l
                    
                  
                  *
                  
                    (
                    q
                    )
                  
                
              
            
          
          =
          
            
              
                
                  
                    B
                    ~
                  
                  l
                
                ⁡
                
                  (
                  q
                  )
                
              
              -
              
                ɛ
                ⁢
                
                  
                    
                      
                        B
                        ~
                      
                      i
                    
                    ⁡
                    
                      (
                      q
                      )
                    
                  
                  ·
                  
                    
                      
                      
                        
                          D
                          ~
                        
                        ⁡
                        
                          (
                          q
                          )
                        
                      
                      
                    
                    2
                  
                  ·
                  
                    q
                    2
                  
                
              
            
            =
            
              
                
                  
                    B
                    ~
                  
                  i
                
                ⁡
                
                  (
                  q
                  )
                
              
              ⁢
              
                
                  (
                  
                    1
                    -
                    
                      ɛ
                      ⁢
                      
                        
                          
                          
                            
                              D
                              ~
                            
                            ⁡
                            
                              (
                              q
                              )
                            
                          
                          
                        
                        2
                      
                      ⁢
                      
                        q
                        2
                      
                    
                  
                  )
                
                ·
              
            
          
        
      
    
    
      
        (
        5
        )
      
    
  




Thus in the most preferred embodiment, (N given by (4)), for finite α, i=n for large n, and ε=α/n, {tilde over (B)}n(q) is given by:




  
    
      
        
          B
          ~
        
        n
      
      ⁡
      
        (
        q
        )
      
    
    =
    
      
        
          
            B
            ~
          
          1
        
        ⁡
        
          (
          q
          )
        
      
      ⁢
      
        
          (
          
            1
            -
            
              
                α
                n
              
              ⁢
              
                
                  
                  
                    
                      D
                      ~
                    
                    ⁢
                    
                      (
                      q
                      )
                    
                  
                  
                
                2
              
              ⁢
              
                q
                2
              
            
          
          )
        
        n
      
    
  
  ,




and in the limit,




  
    
      
        
          
            
              B
              ~
            
            α
          
          ⁡
          
            (
            q
            )
          
        
        =
        
          
            
              lim
              
                n
                →
                ∞
              
            
            ⁢
            
              
                
                  
                    B
                    ~
                  
                  1
                
                ⁡
                
                  (
                  q
                  )
                
              
              ⁢
              
                
                  (
                  
                    1
                    -
                    
                      
                        α
                        n
                      
                      ⁢
                      
                        
                          
                          
                            
                              D
                              ~
                            
                            ⁢
                            
                              (
                              q
                              )
                            
                          
                          
                        
                        2
                      
                      ⁢
                      
                        q
                        2
                      
                    
                  
                  )
                
                n
              
            
          
          =
          
            
              
                
                  B
                  ~
                
                1
              
              ⁡
              
                (
                q
                )
              
            
            ⁢
            
              e
              
                
                  -
                  α
                
                ⁢
                
                  
                    
                    
                      
                        D
                        ~
                      
                      ⁡
                      
                        (
                        q
                        )
                      
                    
                    
                  
                  2
                
                ⁢
                
                  q
                  2
                
              
            
          
        
      
    
    
      
        (
        6
        )
      
    
  




{tilde over (B)}α(q) is preferably multiplied by a factor so that it acquires the same norm as {tilde over (B)}1(q) to produce a function {tilde over (B)}(q) and a new function {tilde over (P)}1(q)={tilde over (B)}(q)/{tilde over (h)}(q) is then obtained.
F(x) may now be obtained by inverse Fourier transform of {tilde over (P)}1(q). However, a pattern characteristic of the DCF may have been superimposed on {tilde over (P)}1(q). This pattern originates in the DCF and is correlated with it. In the most preferred embodiment, this pattern is removed from the function {tilde over (P)}1(q) before applying the inverse Fourier transform and return to x-space.
In order to remove this pattern, the correlation between the pattern and the DCF is decreased, An overall correlation function C is used to evaluate the correlation between the DCP and {tilde over (P)}(q) for functions {tilde over (P)}(q) that deviate slightly from {tilde over (P)}1(q) and a new function {tilde over (P)}(q) is selected that deviates slightly from {tilde over (P)}1(q) and that minimizes the correlation function C. In a preferred embodiment of the invention, the correlation C between the DCF and a function {tilde over (P)}(q) is calculated according to the equation:

C=∫dq∥{tilde over (D)}(q)∥2·∥{tilde over (P)}(q)∥2  (7)

The variation of C with respect to {tilde over (P)}*(q), ∂C/∂{tilde over (P)}* is used to change {tilde over (P)}(q) in order to reduce C. for example, a sequence of functions {tilde over (P)}i (q) may be generated iteratively by:




  
    
      
        P
        ~
      
      ⁢
      i
    
    +
    
      1
      ⁢
      
        (
        q
        )
      
    
  
  =
  
    
      
        P
        ~
      
      ⁢
      
        i
        ⁡
        
          (
          q
          )
        
      
    
    -
    
      ɛ
      ⁢
      
        
          
            ∂
            C
          
          
            ∂
            
              
                
                  P
                  ~
                
                *
              
              ⁡
              
                (
                q
                )
              
            
          
        
        .
      
    
  




In the most preferred embodiment, C is given by (7) so that




  
    
      
        
          P
          ~
        
        
          i
          +
          1
        
      
      ⁡
      
        (
        q
        )
      
    
    =
    
      
        
          
            
              P
              ~
            
            i
          
          ⁡
          
            (
            q
            )
          
        
        -
        
          ɛ
          ⁢
          
            
              ∂
              C
            
            
              ∂
              
                
                  
                    P
                    ~
                  
                  *
                
                ⁡
                
                  (
                  q
                  )
                
              
            
          
        
      
      =
      
        
          
            
              
                P
                ~
              
              i
            
            ⁡
            
              (
              q
              )
            
          
          -
          
            ɛ
            ·
            
              
                
                  P
                  ~
                
                i
              
              ⁡
              
                (
                q
                )
              
            
            ·
            
              
                
                
                  
                    D
                    ~
                  
                  ⁢
                  
                    (
                    q
                    )
                  
                
                
              
              2
            
          
        
        =
        
          
            
              
                P
                ~
              
              i
            
            ⁡
            
              (
              q
              )
            
          
          ⁢
          
            (
            
              1
              -
              
                ɛ
                ⁢
                
                  
                    
                    
                      
                        D
                        ~
                      
                      ⁢
                      
                        (
                        q
                        )
                      
                    
                    
                  
                  2
                
              
            
            )
          
        
      
    
  
  ,




Thus, in the most preferred embodiment (C given by (7)), for finite β, i=n for large n, and ε=β/n,




  
    
      
        
          
            
              P
              ~
            
            
              n
              +
              1
            
          
          ⁡
          
            (
            q
            )
          
        
        =
        
          
            
              
                P
                ~
              
              1
            
            ⁡
            
              (
              q
              )
            
          
          ⁢
          
            
              (
              
                1
                -
                
                  
                    β
                    n
                  
                  ⁢
                  
                    
                      
                      
                        
                          D
                          ~
                        
                        ⁢
                        
                          (
                          q
                          )
                        
                      
                      
                    
                    2
                  
                
              
              )
            
            n
          
        
      
    
    
      
        (
        8
        )
      
    
  




and in the limit,




  
    
      
        
          
            
              P
              ~
            
            β
          
          ⁡
          
            (
            q
            )
          
        
        =
        
          
            
              lim
              
                n
                →
                ∞
              
            
            ⁢
            
              
                
                  
                    P
                    ~
                  
                  1
                
                ⁡
                
                  (
                  q
                  )
                
              
              ⁢
              
                
                  (
                  
                    1
                    -
                    
                      
                        β
                        n
                      
                      ⁢
                      
                        
                          
                          
                            
                              D
                              ~
                            
                            ⁢
                            
                              (
                              q
                              )
                            
                          
                          
                        
                        2
                      
                    
                  
                  )
                
                n
              
            
          
          =
          
            
              
                
                  P
                  ~
                
                1
              
              ⁡
              
                (
                q
                )
              
            
            ⁢
            
              e
              
                
                  -
                  β
                
                ⁢
                
                  
                    
                    
                      
                        D
                        ~
                      
                      ⁡
                      
                        (
                        q
                        )
                      
                    
                    
                  
                  2
                
              
            
          
        
      
    
    
      
        (
        9
        )
      
    
  




{tilde over (P)}β(q) is multiplied by a factor to produce a {tilde over (P)}(q) having the same norm as {tilde over (P)}1(q)·F(x) is then obtained by inverse Fourier transfer of {tilde over (P)}(q).
After removing the superimposed pattern correction, the function F(x) may be converted from the linear intensity range to an intensity space suited for the eye. However, where the original B0(x) was near 0, the slope of B0(x) was very steep so that when values of B0(x) near 0 are converted for discrete representation, much information is lost. Thus, despite the fact that the resolution of the data is nominally 8 bit, with dark colors (corresponding to low values of B), the resolution of the data is equivalent to 3 bit.
Because much information has been lost in the dark regions, converting F(x) to an intensity space suited for the eye is preferably not performed simply by applying the inverse of the transformation previously applied by the camera to B(x) in order to convert it to the linear range. Instead, image F(x) is preferably first mapped into an interval, and then the inverse transformation is applied Thus, for example, if the transformation A(B(x)/A)γ−1 was applied to B(x) by the camera, F(x) is mapped linearly into the interval [0,255] and the transformation A(F(x)/A)γ is applied to the function F(x). For the obtained image, a histogram is obtained from which a cut-off value is obtained at which a predetermined fraction of pixels, for example 10% of the pixels in the image have an intensity value less than or equal to this cut-off value. The intensities are then linearly remapped so that 255 is mapped to 255, the cut-off value is mapped to 25 (10% of 255), and intensity values between 0 and the cut-off are mapped to zero.
The PSF for an image distorted by out-of-focus optics can be described in a first approximation by a function h that is constant inside a circle of radius r and h(x)=0 outside the circle. The radius r may be determined from a distorted image B(x) by the following algorithm. The algorithm makes use of the fact that in an unfocused picture, boundaries (referred to herein as “steps”) are gradual and not abrupt.
A step parallel to the y-axis at x=x0 of an image is described by a Heaviside function Θ(x−x0) independent of y. The mathematical description of the removal from focus of this step is then given by:

I(x)=∫dx′dy′h(x−x′,y−y′)Θ(x′−x0)

where the intensity I in the vicinity of the step is independent of y and h(x,y) is the PSF function. Integration with respect to y yields





  
    I
    ⁡
    
      (
      x
      )
    
  
  =
  
    
      ∫
      
        
          d
          
            x
            ′
          
        
        ⁢
        
          Θ
          ⁡
          
            (
            
              
                x
                ′
              
              -
              
                x
                0
              
            
            )
          
        
        ⁢
        
          ∫
          
            
              d
              
                (
                
                  y
                  -
                  
                    y
                    ′
                  
                
                )
              
            
            ⁢
            
              h
              ⁡
              
                (
                
                  
                    x
                    -
                    
                      x
                      ′
                    
                  
                  ,
                  
                    y
                    -
                    
                      y
                      ′
                    
                  
                
                )
              
            
          
        
      
    
    =
    
      ∫
      
        
          d
          
            x
            ′
          
        
        ⁢
        
          Θ
          ⁡
          
            (
            
              
                x
                ′
              
              -
              
                x
                0
              
            
            )
          
        
        ⁢
        
          
            
              2
              ⁢
              
                
                  
                    r
                    2
                  
                  -
                  
                    
                      (
                      
                        x
                        -
                        
                          x
                          ′
                        
                      
                      )
                    
                    2
                  
                
              
            
            
              π
              ⁢
              
                
              
              ⁢
              
                r
                2
              
            
          
          .
        
      
    
  




The slope of the step at x=x0 is





  
    
      
        
          
            
              
                
                  
                    
                      d
                      1
                    
                    ⁢
                    
                      (
                      x
                      )
                    
                  
                  
                    d
                    x
                  
                
                
              
              
                x
                =
                
                  x
                  0
                
              
            
            =
            
            ⁢
            
              
                d
                
                  d
                  x
                
              
              ⁢
              
                ∫
                
                  
                    d
                    
                      x
                      ′
                    
                  
                  ⁢
                  
                    Θ
                    ⁡
                    
                      (
                      
                        
                          x
                          ′
                        
                        -
                        
                          x
                          0
                        
                      
                      )
                    
                  
                  ⁢
                  
                    
                      2
                      ⁢
                      
                        
                          
                            r
                            2
                          
                          -
                          
                            
                              (
                              
                                x
                                -
                                
                                  x
                                  ′
                                
                              
                              )
                            
                            2
                          
                        
                      
                    
                    
                      π
                      ⁢
                      
                        
                      
                      ⁢
                      
                        r
                        2
                      
                    
                  
                
              
            
          
          
        
        
          x
          =
          
            x
            0
          
        
      
    
  
  
    
      
        
          
            
              =
              
              ⁢
              
                ∫
                
                  
                    d
                    
                      x
                      ′
                    
                  
                  ⁢
                  
                    Θ
                    ⁡
                    
                      (
                      
                        
                          x
                          ′
                        
                        -
                        
                          x
                          0
                        
                      
                      )
                    
                  
                  ⁢
                  
                    d
                    
                      d
                      x
                    
                  
                  ⁢
                  
                    (
                    
                      
                        2
                        ⁢
                        
                          
                            
                              r
                              2
                            
                            -
                            
                              
                                (
                                
                                  x
                                  -
                                  
                                    x
                                    ′
                                  
                                
                                )
                              
                              2
                            
                          
                        
                      
                      
                        π
                        ⁢
                        
                          
                        
                        ⁢
                        
                          r
                          2
                        
                      
                    
                    )
                  
                
              
            
            
          
          
            x
            =
            
              x
              0
            
          
        
        =
      
    
  
  
    
      
        =
        
        ⁢
        
          -
          
            ∫
            
              
                d
                
                  x
                  ′
                
              
              ⁢
              
                Θ
                ⁡
                
                  (
                  
                    
                      x
                      ′
                    
                    -
                    
                      x
                      0
                    
                  
                  )
                
              
              ⁢
              
                d
                
                  d
                  
                    x
                    ′
                  
                
              
              ⁢
              
                (
                
                  
                    2
                    ⁢
                    
                      
                        
                          r
                          2
                        
                        -
                        
                          
                            (
                            
                              
                                x
                                0
                              
                              -
                              
                                x
                                ′
                              
                            
                            )
                          
                          2
                        
                      
                    
                  
                  
                    π
                    ⁢
                    
                      
                    
                    ⁢
                    
                      r
                      2
                    
                  
                
                )
              
            
          
        
      
    
  
  
    
      
        =
        
        ⁢
        
          ∫
          
            
              d
              
                
                  x
                  ′
                
                ⁡
                
                  (
                  
                    
                      d
                      
                        Θ
                        ⁡
                        
                          (
                          
                            
                              x
                              ′
                            
                            -
                            
                              x
                              0
                            
                          
                          )
                        
                      
                    
                    
                      d
                      
                        x
                        ′
                      
                    
                  
                  )
                
              
            
            ⁢
            
              
                2
                ⁢
                
                  
                    
                      r
                      2
                    
                    -
                    
                      
                        (
                        
                          
                            x
                            0
                          
                          -
                          
                            x
                            ′
                          
                        
                        )
                      
                      2
                    
                  
                
              
              
                π
                ⁢
                
                  
                
                ⁢
                
                  r
                  2
                
              
            
          
        
      
    
  
  
    
      
        =
        
        ⁢
        
          
            ∫
            
              
                d
                
                  x
                  ′
                
              
              ⁢
              
                δ
                ⁡
                
                  (
                  
                    
                      x
                      ′
                    
                    -
                    
                      x
                      0
                    
                  
                  )
                
              
              ⁢
              
                
                  2
                  ⁢
                  
                    
                      
                        r
                        2
                      
                      -
                      
                        
                          (
                          
                            
                              x
                              0
                            
                            -
                            x
                          
                          )
                        
                        2
                      
                    
                  
                
                
                  π
                  ⁢
                  
                    
                  
                  ⁢
                  
                    r
                    2
                  
                
              
            
          
          =
          
            
              
                2
                ⁢
                r
              
              
                π
                ⁢
                
                  
                
                ⁢
                
                  r
                  2
                
              
            
            =
            
              2
              
                π
                ⁢
                
                  
                
                ⁢
                r
              
            
          
        
      
    
  




In accordance with the invention, r is found by determining the slope s(x) at each pixel x where a step exists in the image B1(x), where s is defined as the absolute value of the gradient of B1(x) divided by the height of the step at x. The radius r(x) at x is





  
    r
    ⁡
    
      (
      x
      )
    
  
  =
  
    2
    
      π
      ⁢
      
        
      
      ⁢
      
        s
        ⁡
        
          (
          x
          )
        
      
    
  




Edges in the image B1(x) are detected by any method of edge detection as is known in the art, for example, as disclosed in Crane, R., “Simplified Approach to Image Processing, A: Classical and Modern Techniques in C”; Chapter 3. Prentice Hall, 1996, Calculated radii r(x) for pixels x at an edge in the image B1(x) are normalized by dividing by the height of the step at the edge. The normalized radii are arranged in a histogram. The radius of the PSF is obtained essentially equal to the radius of maximum frequency in the histogram.
EXAMPLE
FIG. 1 shows an image that is blurred due to out-of focus optics. This image was rectified in accordance with the invention as follows.
The radius of the PSF of the distortion was first found as follows. Edges in the image were detected and radius r(x) was calculated for each pixel x located at an edge as described above. Each calculated radius was normalized by dividing it by the height of the step at x. FIG. 2 shows a histogram of the normalized heights. As can be seen in FIG. 2, the radius of maximum frequency of the histogram was found to be 4 pixels, and this was taken as the radius of the PSF of the distortion.
{tilde over (B)}α(q) was then obtained according to equation (6) using α=0.001, and then normalized so as to have the same norm as {tilde over (B)}1(q), A function {tilde over (P)}1(q) was then obtained by applying the right side of equation (3) using {tilde over (B)}α(q) for {tilde over (B)}0(q)·{tilde over (P)}β(q) was then obtained according to equation (9) using β=0.01, and then normalized so as to have the same norm as {tilde over (P)}1(q). The function F(x) was then obtained by inverse Fourier transform of {tilde over (P)}1(q). The rectified image F(x) is shown in FIG. 3.
It will also be understood that the system according to the invention may be a suitably programmed computer. Likewise, the invention contemplates a computer program being readable by a computer for executing the method of the invention. The invention further contemplates a machine-readable memory tangibly embodying a program of instructions executable by the machine for executing the method of the invention.

## Claims

1. A method for processing a digital image B1, the image B1 being a convolution of an image F and a point spread function h, comprising removing noise from the image B1 so as to produce an image B′ of reduced noise, and calculating F based upon B′,
wherein an amount of noise is calculated in a plurality of images B, and the image B′ is selected as an image of essentially minimal noise among the images B.

2. A method for processing a digital image B1, the image B1 being a convolution of an image F and a point spread function h, comprising removing noise from the image B1 so as to produce an image B′ of reduced noise, and calculating F based upon B′,
wherein the amount of noise in an image is calculated using an algebraic expression involving the gradient of a function P(x) obtained by inverse Fourier transform of {tilde over (B)}(q)/{tilde over (h)}(q).

3. The method of claim 2, wherein the amount of noise N in an image B is calculated according to the algebraic expression N=∫∇P(x)·∇P*(x)dx, wherein Δ indicates the gradient and “*” indicates complex conjugate.

4. The method according to claim 3 wherein {tilde over (B)}′(q), the Fourier transform of B′, is equal to {tilde over (B)}i+1(q) for some integer i, where {tilde over (B)}i+1(q) is obtained according to the algebraic expression {tilde over (B)}i+1(q)={tilde over (B)}1(q)(1+ε∥{tilde over (D)}(q)∥2 q 2)i, where ε is a small positive number.

5. The method according to claim 3 wherein {tilde over (B)}′(q) is obtained according to the algebraic expression {tilde over (B)}′(q)={tilde over (B)}1(q)e−α∥{tilde over (D)}(q)∥2q2, where α is a predetermined constant, and {tilde over (D)}(q) is the Fourier transform of 1/h.

6. A method for processing a digital image B1, the image B1 being a convolution of an image F and a point spread function h, comprising removing noise from the image B1 so as to produce an image B′ of reduced noise, and calculating F based upon B′,
wherein calculating F involves calculating an inverse Fourier transform of the algebraic expression {tilde over (B)}(q)/{tilde over (h)}(q). wherein {tilde over (B)}′(q)is the Fourier transform of the image B′ of reduced noise, and {tilde over (h)}(q)is the Fourier transform of h.

7. A method for processing a deconvoluted image B, the image B having been deconvoluted according to a deconvolution filter D, the method comprising reducing correlation between the image and the deconvolution filter,
wherein an amount of correlation is calculated in a plurality of images P, and an image P′ is selected among the images P as an image having essentially minimal correlation with the deconvolution filter.

8. The method of claim 7 wherein the amount of correlation C in an image P is calculated according to the algebraic expression C=∫dq∥{tilde over (D)}(q)∥2·∥{tilde over (P)}(q)∥2 wherein {tilde over (P)}(q) is the Fourier transform of an image P.

9. The method of claim 7 wherein {tilde over (P)}′(q), the Fourier transform of P′, is equal to {tilde over (P)}i+1(q) for some integer i, where {tilde over (P)}i+1(q) is obtained according to the algebraic expression {tilde over (P)}i+1(q)={tilde over (P)}1(q)(1+ε∥{tilde over (D)}(q)∥2)i, where ε is a small positive number.

10. The method of claim 7 wherein {tilde over (P)}′(q) is obtained according to the algebraic expression e,otl P′(q)={tilde over (P)}1(q)e−β∥{tilde over (D)}(q)∥2, where βis a predetermined constant.

11. A method for processing a digital image B1, the image B1 being a convolution of an image F and a point spread function h comprising the steps of:
removing noise from the image B1 so as to produce an image B′ of reduced noise;
obtaining function {tilde over (P)}1(q) according to the algebraic expression {tilde over (P)}1(q)={tilde over (B)}′(q)/{tilde over (h)}(q);
reducing correlation between {tilde over (P)}1 and 1/{tilde over (h)} so as to product a function {tilde over (P)}′ of reduced correlation; and
obtaining a rectified image F by inverse Fourier transform of {tilde over (P)}′(q).

12. A method for obtaining a radius r of a point spread function h describing an out-of-focus distortion of a digital image B, the method comprising a step of calculating a gradient at a plurality of pixels in the image B, in which a radius r(x) is calculated at each of the plurality of pixels based upon the gradient.

13. The method according to claim 12 wherein each of the plurality of pixels is located at an edge of the image B.

14. The method according to claim 12 wherein a radius r(x) is inversely proportional to the gradient at x.

15. The method according to claim 13 wherein r is obtained as the r(x) having an essentially maximal frequency among the calculated radii r(x).

16. The method according to claim 15 wherein a radius r(x) is calculated according to the algebraic expression r(x)=2/πs(x) , wherein s(x) is the absolute value of the gradient of B at x normalized by dividing by the height of the edge at x.

17. A method for processing a digital image B1, the image B1 being a convolution of an image F and a point spread function h, comprising removing noise from the image B1 so as to produce an image B′ of reduced noise, and calculating F based upon B′,
further comprising a step of producing the image B′ from an image B0, where the image B0 was obtained using a digital camera that applies a transformation to a light level detected at a pixel, the transformation having an inverse, wherein B1 is obtained from the image B0 by applying to the image B0 the inverse transformation.

18. A program storage device readable by machine, tangibly embodying a program of instructions executable by the machine to perform method steps for processing a digital image B1, the image B1being a convolution of an image F and a point spread function h, comprising the steps of:
removing noise from the image B1 so as to produce an image B′ of reduced noise;
obtaining function {tilde over (P)}1(q) according to the algebraic expression {tilde over (P)}1(q)={tilde over (B)}′(q)/{tilde over (h)}(q);
reducing calculation between {tilde over (P)}1 and {tilde over (1)}/h so as to product a function ′ of reduced correlation; and
obtaining a rectified image F by inverse Fourier transform of {tilde over (P)}′(q).