Linear Motion Deblurring - Vision Day 2019 · 2014-07-01 · Linear Motion Deblurring Kristian...

1
Linear Motion Deblurring Kristian Ryder Thomsen and Kristian Berg Thomsen 02625 CSI: Computational Science in Imaging, DTU Compute Image blurring is assumed to be a linear operation. Denote by and the vectorized sharp and blurred image respectively. The image consists of N = × pixels. Because of linearity there must exist a (huge) matrix A∈ N×N such that and are related by the fundamental linear model of image blurring A = . The naive solution = A -1 fails due to effects of inverted noise. In special cases with specific boundary conditions (BC) and point spread function (PSF) fast non-iterative algorithms exist, but otherwise iterative methods are needed. Linear motion blur is motion blur along a straight line. If linear motion blur is not parallel with one of the image axes this gives rise to a PSF that is neither separable nor doubly symmetric. This means that we cannot use periodic BC and hence we must use iterative methods. Linear motion blur is characterized by its angle α and length L. The angle is measured in degrees and the length in pixels. The angle decribes the motion direction w.r.t horizontal. The length decribes how much the camera/photographed object was moved during the exposure. Examples of blurred images and the corresponding parameters α and L can be seen in the bottom of the second and third column. For α = 10 and L = 15 an explictly formed A matrix is seen to the left. The A matrix is normally never explictly formed and it is formed here only for illustrative purposes. Note that the sum of each row is approximately constant. This will impact the iterative methods presented later. Blurring the image Using only matrix-vector multiplications iterative methods produce a sequence [0] [1] [2] that (hopefully) converge to the desired solution. This gives two major advantages The matrix A is never altered, and is only “touched” when computing A and A T . The matrix A is not explictly required - we only need a “black box” that computes the action of A or its underlying operator. Computing the multiplication A corresponds to a blurring of the image stored vectorized in . This means that A and A T can be computed by a filter operation without forming A (nor A T ) explictily. Advantages of iterative methods The image deblurring problem is an inverse problem. This is difficult for several reasons The matrix A is huge. The matrix A is very ill-conditioned. The matrix A may be an imprecise model of the blurring. The image deblurring problem is an inverse problem. This is difficult for several reasons The matrix A is huge. The matrix A is very ill-conditioned. The matrix A may be an imprecise model of the blurring. Since the linear motion blur does not necessarily give rise to a PSF which is separable or doubly symmetric we have to use iterative methods. We consider three such methods, namely, Landweber’s method, Cimmino’s method, and CGLS (conjugate gradients for least squares). All these algoritms exhibit semiconvergence, that is, initial convergence towards exact followed by slow convergence to A . We can obtain an approximate solution by choosing the number of iterations correctly. ( +1) = ( ) + ωA - A ( ) where ω is a parameter chosen such that 0 <ω< 2||A A|| -1 2 . This method is a simple version of Cimmino’s method, if the weights are almost constant. Landweber’s method ( +1) = ( ) + ωA D - A ( ) where D is a diagonal matrix with weights determined by the rows of A. The weights are given by = 1 || || 2 2 when || || 2 = 0. Otherwise = 0. Cimmino’s method To motivate the CGLS method we first need to introduce the Krylov subspaces = span A A AA A A 2 A A A -1 A We now search for a solution in this space. In each iteration we solve ( ) = argmin ||A - || 2 from which one can derive a simple iteration scheme. Conjugate gradients for least squares Iterative methods Note that in our implementation of the above methods we never need to form the matrix A explicitly. Note that in our implementation of the above methods we never need to form the matrix A explicitly. We can now present the first results using the CGLS algorithms with 40 iterations. All images are quadratic and the length of the blur is given in percent of the image width. Similar results are obtained with Landweber’s method. Fig. 1: α =0L = 6% Fig. 2: α = 30L = 7% Fig. 3: α = 120L = 14% Fig. 4: α = 170L = 18% Fig. 5: α = 90L = 37% Results To obtain the results before we had to know how the images had been blurred, i.e. we had to know the angle and the length of the blurring. Now we want to deblur an image without “a priori” knowledge of angle and length. For this we will use the cepstral method. The cepstrum ( ) is defined as ( )= -1 (log | ( ())|) Below we see a blurred image, the Fourier transform and the cepstrum of the image. To reduce boundary effects in the cepstrum we apply a Hann window to the blurred image. Fig. 11: Blurred image with Hann window Fig. 12: Fourier transform Fig. 13: Cepstrum To estimate the angle we have to find the slope of the line connecting the two smallest points in the cepstrum. We know that ()= () *() ˆ ()= ˆ () · ˆ () and that ˆ is the sinc function. We want to detect the ripples in the Fourier spectrum. Finding the two points in the third plot above we can calculate the angle as the slope of line though the points. The length of the blur is calculated as half the distance between the two points due to symmetry in the Fourier spectrum. Estimating parameters For images without noise the above method is very effective. We have also plotted the error of the estimates for constant length and constant angle, respectively. Fig. 14: Blurred image, α = 45 L = 6% Fig. 15: Deblurred im., α est = 4507 L est =609% Fig. 16: Blurred image, α = 22 L = 18% Fig. 17: Deblurred im., α est = 2180 L est = 1796% 0 60 120 180 -1 -0.5 0 0.5 1 α Error in α [Degrees] Fig. 18: Error for angle estimation, L = 10% 0 60 120 180 -0.2 -0.1 0 0.1 0.2 α Error in L [% points] Fig. 19: Error for length estimation, L = 10% 3 10 20 30 40 -2 -1 0 1 2 L [%] Error in α [Degrees] Fig. 20: Error for angle estimation, α = 25 3 10 20 30 40 -0.5 -0.25 0 0.25 0.5 L [%] Error in L [% points] Fig. 21: Error for length estimation, α = 25 Results

Transcript of Linear Motion Deblurring - Vision Day 2019 · 2014-07-01 · Linear Motion Deblurring Kristian...

Page 1: Linear Motion Deblurring - Vision Day 2019 · 2014-07-01 · Linear Motion Deblurring Kristian Ryder Thomsen and Kristian Berg Thomsen 02625 CSI: Computational Science in Imaging,

Linear Motion DeblurringKristian Ryder Thomsen and Kristian Berg Thomsen02625 CSI: Computational Science in Imaging, DTU Compute

Image blurring is assumed to be a linear operation. Denote by x and b the vectorizedsharp and blurred image respectively. The image consists ofN = m×n pixels. Becauseof linearity there must exist a (huge) matrix A ∈ RN×N such that x and b are relatedby the fundamental linear model of image blurring Ax = b.The naive solution xnaive = A−1b fails due to effects of inverted noise. In specialcases with specific boundary conditions (BC) and point spread function (PSF) fastnon-iterative algorithms exist, but otherwise iterative methods are needed.Linear motion blur is motion blur along a straight line. If linear motion blur is notparallel with one of the image axes this gives rise to a PSF that is neither separablenor doubly symmetric. This means that we cannot use periodic BC and hence we mustuse iterative methods.Linear motion blur is characterized by its angle α and length L. The angle is measuredin degrees and the length in pixels. The angle decribes the motion direction w.r.thorizontal. The length decribes how much the camera/photographed object was movedduring the exposure. Examples of blurred images and the corresponding parametersα and L can be seen in the bottom of the second and third column.

For α = 10 and L = 15 an explictly formed A matrix is seento the left. The A matrix is normally never explictly formed andit is formed here only for illustrative purposes. Note that thesum of each row is approximately constant. This will impact theiterative methods presented later.

Blurring the image

Using only matrix-vector multiplications iterative methods produce a sequence x [0] →x [1] → x [2] → ... that (hopefully) converge to the desired solution. This gives two majoradvantages• The matrix A is never altered, and is only “touched” when computing Ax and ATy.• The matrix A is not explictly required - we only need a “black box” that computes theaction of A or its underlying operator.Computing the multiplication Ax corresponds to a blurring of the image stored vectorizedin x . This means that Ax and AT x can be computed by a filter operation without formingA (nor AT ) explictily.

Advantages of iterative methods

The image deblurring problem is an inverse problem.This is difficult for several reasons• The matrix A is huge.• The matrix A is very ill-conditioned.• The matrix A may be an imprecise model of the blurring.

The image deblurring problem is an inverse problem.This is difficult for several reasons• The matrix A is huge.• The matrix A is very ill-conditioned.• The matrix A may be an imprecise model of the blurring.

Since the linear motion blur does not necessarily give rise to a PSF which is separableor doubly symmetric we have to use iterative methods. We consider three such methods,namely, Landweber’s method, Cimmino’s method, and CGLS (conjugate gradients forleast squares). All these algoritms exhibit semiconvergence, that is, initial convergencetowards xexact followed by slow convergence to A†b. We can obtain an approximatesolution by choosing the number of iterations correctly.

x(k+1) = x(k) + ωA>(b− Ax(k))where ω is a parameter chosen such that0 < ω < 2||A>A||−12 . This method is asimple version of Cimmino’s method, ifthe weights di are almost constant.

Landweber’s method

x(k+1) = x(k) + ωA>D(b− Ax(k))where D is a diagonal matrix withweights determined by the rows ai of A.The weights are given by di = 1

m||ai||22when ||ai||2 6= 0. Otherwise di = 0.

Cimmino’s method

To motivate the CGLS method we first need to introduce the Krylov subspaces

Kk = span {A>b, A>AA>b,

(A>A

)2A>b, . . . ,

(A>A

)k−1A>b

}.

We now search for a solution in this space. In each iteration we solvex(k) = argminx||Ax − b||2, x ∈ Kk ,from which one can derive a simple iteration scheme.

Conjugate gradients for least squares

Iterative methods

Note that in our implementation of the above methods we neverneed to form the matrix A explicitly.Note that in our implementation of the above methods we neverneed to form the matrix A explicitly.

We can now present the first results using the CGLS algorithms with 40 iterations.All images are quadratic and the length of the blur is given in percent of the imagewidth. Similar results are obtained with Landweber’s method.

Fig. 1:α = 0, L = 6% Fig. 2:

α = 30, L = 7% Fig. 3:α = 120, L = 14% Fig. 4:

α = 170, L = 18% Fig. 5:α = 90, L = 37%

Results

To obtain the results before we had to know how the images had been blurred, i.e. wehad to know the angle and the length of the blurring. Now we want to deblur an imagewithout “a priori” knowledge of angle and length. For this we will use the cepstralmethod. The cepstrum C(f ) is defined asC(f ) = F−1(log |F (f (x, y))|).

Below we see a blurred image, the Fourier transform and the cepstrum of the image. Toreduce boundary effects in the cepstrum we apply a Hann window to the blurred image.

Fig. 11: Blurred imagewith Hann window Fig. 12:Fourier transform Fig. 13:CepstrumTo estimate the angle we have to find the slope of the line connecting the two smallestpoints in the cepstrum. We know thatg(x, y) = f (x, y) ∗ h(x, y) → g(x, y) = f (x, y) · h(x, y),

and that h is the sinc function. We want to detect the ripples in the Fourier spectrum.Finding the two points in the third plot above we can calculate the angle as the slope ofline though the points. The length of the blur is calculated as half the distance betweenthe two points due to symmetry in the Fourier spectrum.

Estimating parameters

For images without noise the above method is very effective. We have also plotted theerror of the estimates for constant length and constant angle, respectively.

Fig. 14: Blurred image,α = 45L = 6%

Fig. 15: Deblurred im.,αest = 45.07Lest = 6.09%

Fig. 16: Blurred image,α = 22L = 18%

Fig. 17: Deblurred im.,αest = 21.80Lest = 17.96%

0 60 120 180−1

−0.5

0

0.5

1

α

Err

or in

α [D

egre

es]

Fig. 18: Error for angleestimation, L = 10%0 60 120 180

−0.2

−0.1

0

0.1

0.2

α

Err

or in

L [%

poi

nts]

Fig. 19: Error for lengthestimation, L = 10%3 10 20 30 40

−2

−1

0

1

2

L [%]

Err

or in

α [D

egre

es]

Fig. 20: Error for angleestimation, α = 253 10 20 30 40

−0.5

−0.25

0

0.25

0.5

L [%]

Err

or in

L [%

poi

nts]

Fig. 21: Error for lengthestimation, α = 25

Results