SlideShare a Scribd company logo
1 of 35
IMAGE DEBLURRING: PART 3
ERIK O. MAYER
IMAGES AS MATRICES
 Images can be represented as matrices, with each entry in the matrix
containing the intensity of the corresponding image’s pixel
 Grayscale intensities lie on an interval [0, n], where 0 = black, n = white
1040 x 857
image
(length by
width)
857 x 1040
matrix
(rows by
columns)
x1 1 x1 2 x1 1040
x2 1
x857 1 x857 1040
x2 2 x2 1040
 Grayscale images are represented by single matrices
 Color images are represented by multidimensional matrices
BLURRING AS A LINEAR OPERATION
• We have an m x n blurred image B, and the corresponding ideal, sharp m x n
image X
• Their vector forms, b and x, have m n = N entries, constructed by stacking
the columns of B and X respectively
• Blur is defined by how information that should be contained in a single pixel
“spills over” into surrounding pixels
• All the information about how X is blurred to B is contained in some N x N
matrix A such that,
Ax = b
The blurring matrix A has two primary ingredients
• Point-Spread Functions
• Boundary Conditions
BOUNDARY CONDITIONS
What’s happening just beyond the edges of
our image X?
 Different assumptions about the
boundary conditions will yield different
constructions of the blurring matrix A,
and thus affect our ability to accurately
model the behavior of the blur
 X is surrounded by 0 at every edge
This is the “default” boundary assumption
 This condition takes effect if no boundary condition is considered
at all
 A pixel value of 0 corresponds with black, so this condition might
be useful for images with black backgrounds, like outer space
ZERO BOUNDARY CONDITION
X is surrounded by copies of itself, repeated around every edge
PERIODIC BOUNDARY CONDITION
Each edge of X faces its mirror image
With this condition, the pixels at the edge of an image are always next to
identically valued pixels just beyond the edge
REFLEXIVE BOUNDARY CONDITION
POINT SPREAD FUNCTIONS
• An image with all black pixels (represented by 0) except for a single
white pixel (represented by 1) is known as a Point Source
This image is represented as an m x n matrix
(the same dimensions as X and B)
This matrix could be rearranged into a vector
of length m n = N
Since this vector is all 0 except for a 1 as the ith
entry, this vector is the ith column of an N x N
identity matrix, and denoted ei
POINT SPREAD FUNCTIONS
• A point spread function (PSF) is a function that describes the blurring and the
resulting image of the point source.
PSF
Horizontal Motion BlurOut-of-Focus BlurAtmospheric Turbulence BlurMoffat Blur
 For any PSF, the elements of the
resulting image must sum to 1, the
value of the original point source
 If the PSF is the same regardless of
the location of the point source, the
blurring is spatially invariant
HOW A INCORPORATES THE PSF
So the columns of A are the same as the
blurred images of the various point sources
 For each point source vector ei, we can easily determine Aei, the
blurred image vector of ei
 It’s defined by the PSF itself
 But we can also show that Aei is equivalent to the ith column of A
THE SIMPLE EXAMPLE
Last time, we constructed a 12 x 12 blurring matrix for a 4 x 3 image
matrix, where the PSF blurred the point source to a vertical line of 2 pixels
(the point source pixel and the pixel directly beneath)
 We accomplished this
by determining the
blurred images of
every possible point
source (they made up
the columns of A)
e1
1
0
0
0
0
0
0
0
0
0
0
0
1/2
1/2
0
0
0
0
0
0
0
0
0
0
1 0
0 0
0
0
0 0 0
0 0 0
1/2 0
1/2 0
0
0
0 0 0
0 0 0
Point Source Blurred Point Source
PSF
First column of A
THE SIMPLE EXAMPLE
 Create the long column
vector x from the image
matrix X
 Multiply A by x to get b,
the vector form of the
blurred image
 Rearrange b back into
matrix form to get the
blurred image matrix B
THE SIMPLE EXAMPLE
Our technique of constructing the 12 x 12 blurring matrix A column by
column worked well enough for a simple 4 x 3 image
 But constructing A column by column is typically extremely time consuming
A x = Ax = b
= =
=
Notice how each blurred pixel can
be written as a weighted sum of
pixels from the sharp image
 These weighted sums can be
attained through a process called
convolution!!!
0 0
0 0.5
0
0
0 0.5 0
0 0 0
0 0
0 1
0
0
0 0 0
0 0 0
Start with a point source and its corresponding
blurred image (known as the PSF array)
 The position of the nonzero pixel in the point
source is the “center” of the PSF array
Rotate the PSF array 180° and lay it
overtop of the sharp image matrix
 Multiply each pair of entries lying atop
of one another, then add them all
together
 The position of the entry from X that is
multiplied by the “center” of the PSF
array is the position of the entry in B
that assumes the value of the weighted
sum
0 0
0 0.5
0
0
0 0.5 0
0 0 0
b11 = (1/2)x11
b21 = (1/2)x11 + (1/2)x21
b31 = (1/2)x21 + (1/2)x31
b41 = (1/2)x31 + (1/2)x41
b12 = (1/2)x12
b22 = (1/2)x12 + (1/2)x22
b32 = (1/2)x22 + (1/2)x32
b42 = (1/2)x32 + (1/2)x42
b13 = (1/2)x13
b23 = (1/2)x13 + (1/2)x23
b33 = (1/2)x23 + (1/2)x33
b43 = (1/2)x33 + (1/2)x43
CONVOLUTION
NOISE REMOVAL AND EDGE DETECTION
Convolution of an image with the PSF array blurs the image, but
convolution can be used to accomplish other ends as well
 Noise Removal (Low-Pass Filter)
 Convolution of an image with a matrix that averages any given
pixel with its neighbors
 The result is a “smoothing out” of pixels that differ greatly from
their neighbors
 Edge Detection (High-Pass Filter)
 Convolution of an image with a matrix that amplifies pixels that
differ greatly from their neighbors
 The result is that edges in the image are amplified, but noise is
amplified as well
p11 p12
p21 p22
p13
p23
p31 p32 p33
p41 p42 p43
p43 p42
p33 p32
p41
p31
p23 p22 p21
p13 p12 p11
b11 = p22(x11) + p12(x21) + 0(x31) + 0(x41) + p21(x12) + p11(x22) + 0(x32) + 0(x42) + 0(x13) + 0(x23) + 0(x33) + 0(x43)
CONVOLUTION
Let’s repeat the PSF
convolution, now with a general
PSF array with center p22
b31 = p42(x11) + p32(x21) + p22(x31) + p12(x41) + p41(x12) + p31(x22) + p21(x32) + p11(x42) + 0(x13) + 0(x23) + 0(x33) + 0(x43)
b11 = p22(x11) + p12(x21) + 0(x31) + 0(x41) + p21(x12) + p11(x22) + 0(x32) + 0(x42) + 0(x13) + 0(x23) + 0(x33) + 0(x43)
b21 = p32(x11) + p22(x21) + p12(x31) + 0(x41) + p31(x12) + p21(x22) + p11(x32) + 0(x42) + 0(x13) + 0(x23) + 0(x33) + 0(x43)
b41 = 0(x11) + p42(x21) + p32(x31) + p22(x41) + 0(x12) + p41(x22) + p31(x32) + p21(x42) + 0(x13) + 0(x23) + 0(x33) + 0(x43)
b12 = p23(x11) + p13(x21) + 0(x31) + 0(x41) + p22(x12) + p12(x22) + 0(x32) + 0(x42) + p21(x13) + p11(x23) + 0(x33) + 0(x43)
b22 = p33(x11) + p23(x21) + p13(x31) + 0(x41) + p32(x12) + p22(x22) + p12(x32) + 0(x42) + p31(x13) + p21(x23) + p11(x33) + 0(x43)
b32 = p43(x11) + p33(x21) + p23(x31) + p13(x41) + p42(x12) + p32(x22) + p22(x32) + p12(x42) + p41(x13) + p31(x23) + p21(x33) + p11(x43)
b42 = 0(x11) + p43(x21) + p33(x31) + p23(x41) + 0(x12) + p42(x22) + p32(x32) + p22(x42) + 0(x13) + p41(x23) + p31(x33) + p21(x43)
b13 = 0(x11) + 0(x21) + 0(x31) + 0(x41) + p23(x12) + p13(x22) + 0(x32) + 0(x42) + p22(x13) + p12(x23) + 0(x33) + 0(x43)
b23 = 0(x11) + 0(x21) + 0(x31) + 0(x41) + p33(x12) + p23(x22) + p13(x32) + 0(x42) + p32(x13) + p22(x23) + p12(x33) + 0(x43)
b33 = 0(x11) + 0(x21) + 0(x31) + 0(x41) + p43(x12) + p33(x22) + p23(x32) + p13(x42) + p42(x13) + p32(x23) + p22(x33) + p12(x43)
b43 = 0(x11) + 0(x21) + 0(x31) + 0(x41) + 0(x12) + p43(x22) + p33(x32) + p23(x42) + 0(x13) + p42(x23) + p32(x33) + p22(x43)
We’ll convert this system of equations back into a matrix equation
=
We’ve arrived back at
Ax = b, and we can
now see that A is
filled with the entries
of the PSF array!
 Is there any
generality to be
gleaned from A’s
structure?
Divide A into 4 x 4 blocks
 All of the diagonals in each
block are constant
 A matrix where every
diagonal is constant is
known as Toeplitz
 So all blocks in A are
Toeplitz matrices
Also, each diagonal of blocks in
A is constant!
We say that A is a block
Toeplitz matrix with Toeplitz
blocks
 Note: This structure of A
holds only when we assume
zero boundary conditions
• Different boundary
conditions yield different
general structures for A
SEPARABLE BLUR
The blur is separable into vertical and horizontal components if the PSF
array, P, can be written as an outer product of vectors c and r
If this holds, then each element of the PSF array, pij, can be expressed as cirj
Let’s assume that the blur is separable in our arbitrary 4 x 3 PSF
 Then A can be rewritten as:
KRONECKER PRODUCTS
0
0
Each r component is
being multiplied by
the same matrix of c
components
 This is a Kronecker
Product of the
matrix of r
components with
the matrix of c
components
With separable blur, we were able to rewrite the full blurring matrix A
as the Kronecker product of matrices Ar and Ac , both of which are
much smaller than the full matrix A.
 The structure of both Ar and Ac is Toeplitz
Ar Ac
WHAT WE NEED:
 For our m x n image matrix X, we need a corresponding PSF array P
 If the blur is separable, we can determine vectors c and r such that
 Then we can use the entries of c and r to create m x m Ac and n x n Ar
 We can do this because we know the Toeplitz structure of those
matrices
WHAT WE NEED:
 The Kronecker Product of Ar and Ac gives us the full mn x mn blurring
matrix A
 Alternatively, we can use Ar and Ac to blur X directly
Ax = b
…is equivalent to…
Ac X Ar
T = B
SEPARATING THE BLUR
 If the PSF array P is a rank 1 matrix, then c and r can be determined as
follows, using the Singular Value Decomposition of P:
c = σ1 u1
r = σ1 v1
where σ1 is the first (largest) singular value of P, and u1 and v1 are its
corresponding left and right singular vectors.
DEBLURRING
Ax = b
Now we’ve sufficiently built up our model of how A blurs a given image:
Then, given a blurry image, we may deduce that it can be deblurred by
However, such a reconstruction of the sharp image would be naïve,
because our recorded blurry image likely contains more than just blur
 Our recorded image also contains noise, errors caused by factors
such as technical limitations and poor lighting
x = A-1b
where bexact = Ax and e represents the noise component.
Then our naïve reconstruction can be expressed as:
DEBLURRING
b = bexact + e
xnaïve = A-1b
Our recorded image can be expressed as:
xnaïve = A-1(bexact + e)
xnaïve = x + A-1e
xnaïve = A-1bexact + A-1e
SINGULAR VALUE DECOMPOSITION OF A
= Σi = 1 viui
TN
σi
A-1
A-1e= Σi = 1 ui
Te
N
σi
vi
where σi are the strictly positive singular values of A, arranged in a non-
increasing order, σ1 ≥ σ2 ≥ … ≥ σN > 0. Then the inverted noise can be
expressed as:
We’ll use the singular value decomposition of A to cut out as much of
the inverted noise as possible.
So the inverted noise can be written as a linear combination of the right
singular vectors, vi
A-1e= Σi = 1 ui
Te
N
σi
vi
SINGULAR VALUE DECOMPOSITION OF A
Because the singular vectors are ordered such that σ1 ≥ σ2 ≥ … ≥ σN > 0,
the coefficients on vi get very large as i gets large
 So the later terms in the sum contribute more to the inverted
noise
 Removing terms from the end of the sum will reduce the size
of the error, at the cost of sacrificing some of the image’s
information
TRUNCATION
xnaïve = A-1b = Σi = 1 ui
Tb
N
σi
vi
If we choose k < N, then our truncated reconstruction is,
Our “naïve” reconstruction can be represented as,
xk = Σi = 1 ui
Tb
k
σi
vi
This is called the Truncated SVD method, or the TSVD
SPECTRAL FILTERING
where Φi is the filter factor for the ith term in the sum
The truncated SVD method is actually an example of a more general class of
reconstruction methods called spectral filtering
 The filtered reconstruction is defined as:
The TSVD can be defined in terms of this general model by allowing:
xfilt = Σi = 1
ui
TbN
σi
viΦi
Φi =
1, i = 1, … , k
0, i = k + 1, … , N{
“R” EXAMPLE
In the program R, I created a 9 x 13 image matrix X, and defined the PSF
to take the point source and blur it to a square of 4 pixels
 Instead of constructing the 117 x 117 blurring matrix A column by
column, I created the 9 x 9 Ac and the 13 x 13 Ar , and used those
to blur my image
ALTERNATE PSF
The blurring is less severe in this PSF
Blurry, noisy image

More Related Content

What's hot

CS 354 Graphics Math
CS 354 Graphics MathCS 354 Graphics Math
CS 354 Graphics MathMark Kilgard
 
Image Acquisition and Representation
Image Acquisition and RepresentationImage Acquisition and Representation
Image Acquisition and RepresentationAmnaakhaan
 
CS 354 Pixel Updating
CS 354 Pixel UpdatingCS 354 Pixel Updating
CS 354 Pixel UpdatingMark Kilgard
 
6 spatial filtering p2
6 spatial filtering p26 spatial filtering p2
6 spatial filtering p2Gichelle Amon
 
The Day You Finally Use Algebra: A 3D Math Primer
The Day You Finally Use Algebra: A 3D Math PrimerThe Day You Finally Use Algebra: A 3D Math Primer
The Day You Finally Use Algebra: A 3D Math PrimerJanie Clayton
 
Notes on image processing
Notes on image processingNotes on image processing
Notes on image processingMohammed Kamel
 
04 image enhancement edge detection
04 image enhancement edge detection04 image enhancement edge detection
04 image enhancement edge detectionRumah Belajar
 
Lecture32
Lecture32Lecture32
Lecture32zukun
 
A MODIFIED DIRECTIONAL WEIGHTED CASCADED-MASK MEDIAN FILTER FOR REMOVAL OF RA...
A MODIFIED DIRECTIONAL WEIGHTED CASCADED-MASK MEDIAN FILTER FOR REMOVAL OF RA...A MODIFIED DIRECTIONAL WEIGHTED CASCADED-MASK MEDIAN FILTER FOR REMOVAL OF RA...
A MODIFIED DIRECTIONAL WEIGHTED CASCADED-MASK MEDIAN FILTER FOR REMOVAL OF RA...cscpconf
 
Chapter 1 introduction (Image Processing)
Chapter 1 introduction (Image Processing)Chapter 1 introduction (Image Processing)
Chapter 1 introduction (Image Processing)Varun Ojha
 
Digital image processing img smoothning
Digital image processing img smoothningDigital image processing img smoothning
Digital image processing img smoothningVinay Gupta
 
Cs229 notes-deep learning
Cs229 notes-deep learningCs229 notes-deep learning
Cs229 notes-deep learningVuTran231
 
Unit 2
Unit 2Unit 2
Unit 2ypnrao
 
Beginning direct3d gameprogramming08_usingtextures_20160428_jintaeks
Beginning direct3d gameprogramming08_usingtextures_20160428_jintaeksBeginning direct3d gameprogramming08_usingtextures_20160428_jintaeks
Beginning direct3d gameprogramming08_usingtextures_20160428_jintaeksJinTaek Seo
 

What's hot (20)

Image enhancement
Image enhancementImage enhancement
Image enhancement
 
Mathematical tools in dip
Mathematical tools in dipMathematical tools in dip
Mathematical tools in dip
 
CS 354 Graphics Math
CS 354 Graphics MathCS 354 Graphics Math
CS 354 Graphics Math
 
Pixelrelationships
PixelrelationshipsPixelrelationships
Pixelrelationships
 
Image Acquisition and Representation
Image Acquisition and RepresentationImage Acquisition and Representation
Image Acquisition and Representation
 
CS 354 Pixel Updating
CS 354 Pixel UpdatingCS 354 Pixel Updating
CS 354 Pixel Updating
 
Image restoration and reconstruction
Image restoration and reconstructionImage restoration and reconstruction
Image restoration and reconstruction
 
6 spatial filtering p2
6 spatial filtering p26 spatial filtering p2
6 spatial filtering p2
 
The Day You Finally Use Algebra: A 3D Math Primer
The Day You Finally Use Algebra: A 3D Math PrimerThe Day You Finally Use Algebra: A 3D Math Primer
The Day You Finally Use Algebra: A 3D Math Primer
 
Notes on image processing
Notes on image processingNotes on image processing
Notes on image processing
 
04 image enhancement edge detection
04 image enhancement edge detection04 image enhancement edge detection
04 image enhancement edge detection
 
Lect14 lines+circles
Lect14 lines+circlesLect14 lines+circles
Lect14 lines+circles
 
Lecture32
Lecture32Lecture32
Lecture32
 
A MODIFIED DIRECTIONAL WEIGHTED CASCADED-MASK MEDIAN FILTER FOR REMOVAL OF RA...
A MODIFIED DIRECTIONAL WEIGHTED CASCADED-MASK MEDIAN FILTER FOR REMOVAL OF RA...A MODIFIED DIRECTIONAL WEIGHTED CASCADED-MASK MEDIAN FILTER FOR REMOVAL OF RA...
A MODIFIED DIRECTIONAL WEIGHTED CASCADED-MASK MEDIAN FILTER FOR REMOVAL OF RA...
 
Chapter 1 introduction (Image Processing)
Chapter 1 introduction (Image Processing)Chapter 1 introduction (Image Processing)
Chapter 1 introduction (Image Processing)
 
Ip unit 1
Ip unit 1Ip unit 1
Ip unit 1
 
Digital image processing img smoothning
Digital image processing img smoothningDigital image processing img smoothning
Digital image processing img smoothning
 
Cs229 notes-deep learning
Cs229 notes-deep learningCs229 notes-deep learning
Cs229 notes-deep learning
 
Unit 2
Unit 2Unit 2
Unit 2
 
Beginning direct3d gameprogramming08_usingtextures_20160428_jintaeks
Beginning direct3d gameprogramming08_usingtextures_20160428_jintaeksBeginning direct3d gameprogramming08_usingtextures_20160428_jintaeks
Beginning direct3d gameprogramming08_usingtextures_20160428_jintaeks
 

Viewers also liked

Super Resolution in Digital Image processing
Super Resolution in Digital Image processingSuper Resolution in Digital Image processing
Super Resolution in Digital Image processingRamrao Desai
 
NeuralArt 電腦作畫
NeuralArt 電腦作畫NeuralArt 電腦作畫
NeuralArt 電腦作畫Mark Chang
 
Image Restoration (Digital Image Processing)
Image Restoration (Digital Image Processing)Image Restoration (Digital Image Processing)
Image Restoration (Digital Image Processing)Kalyan Acharjya
 
PES ncetec conference
PES ncetec conferencePES ncetec conference
PES ncetec conferenceAvinash P M
 
Deep Learning - Convolutional Neural Networks
Deep Learning - Convolutional Neural NetworksDeep Learning - Convolutional Neural Networks
Deep Learning - Convolutional Neural NetworksChristian Perone
 

Viewers also liked (7)

Neural artistic style
Neural artistic styleNeural artistic style
Neural artistic style
 
Super Resolution in Digital Image processing
Super Resolution in Digital Image processingSuper Resolution in Digital Image processing
Super Resolution in Digital Image processing
 
NeuralArt 電腦作畫
NeuralArt 電腦作畫NeuralArt 電腦作畫
NeuralArt 電腦作畫
 
Image Restoration (Digital Image Processing)
Image Restoration (Digital Image Processing)Image Restoration (Digital Image Processing)
Image Restoration (Digital Image Processing)
 
PES ncetec conference
PES ncetec conferencePES ncetec conference
PES ncetec conference
 
Image processing ppt
Image processing pptImage processing ppt
Image processing ppt
 
Deep Learning - Convolutional Neural Networks
Deep Learning - Convolutional Neural NetworksDeep Learning - Convolutional Neural Networks
Deep Learning - Convolutional Neural Networks
 

Similar to Deblurring3

My Lecture Notes from Linear Algebra
My Lecture Notes fromLinear AlgebraMy Lecture Notes fromLinear Algebra
My Lecture Notes from Linear AlgebraPaul R. Martin
 
Chapter 3 Output Primitives
Chapter 3 Output PrimitivesChapter 3 Output Primitives
Chapter 3 Output PrimitivesPrathimaBaliga
 
Nbhm m. a. and m.sc. scholarship test 2007
Nbhm m. a. and m.sc. scholarship test 2007 Nbhm m. a. and m.sc. scholarship test 2007
Nbhm m. a. and m.sc. scholarship test 2007 MD Kutubuddin Sardar
 
Pptpersamaankuadrat 150205080445-conversion-gate02
Pptpersamaankuadrat 150205080445-conversion-gate02Pptpersamaankuadrat 150205080445-conversion-gate02
Pptpersamaankuadrat 150205080445-conversion-gate02MasfuahFuah
 
Nbhm m. a. and m.sc. scholarship test 2006
Nbhm m. a. and m.sc. scholarship test 2006Nbhm m. a. and m.sc. scholarship test 2006
Nbhm m. a. and m.sc. scholarship test 2006MD Kutubuddin Sardar
 
Module 2 exponential functions
Module 2   exponential functionsModule 2   exponential functions
Module 2 exponential functionsdionesioable
 
4 pages from matlab an introduction with app.-2
4 pages from matlab an introduction with app.-24 pages from matlab an introduction with app.-2
4 pages from matlab an introduction with app.-2Malika khalil
 
Fourier 3
Fourier 3Fourier 3
Fourier 3nugon
 
ALA Solution.pdf
ALA Solution.pdfALA Solution.pdf
ALA Solution.pdfRkAA4
 
7.curves Further Mathematics Zimbabwe Zimsec Cambridge
7.curves   Further Mathematics Zimbabwe Zimsec Cambridge7.curves   Further Mathematics Zimbabwe Zimsec Cambridge
7.curves Further Mathematics Zimbabwe Zimsec Cambridgealproelearning
 
Interpolation techniques - Background and implementation
Interpolation techniques - Background and implementationInterpolation techniques - Background and implementation
Interpolation techniques - Background and implementationQuasar Chunawala
 
Binomial Theorem, Recursion ,Tower of Honai, relations
Binomial Theorem, Recursion ,Tower of Honai, relationsBinomial Theorem, Recursion ,Tower of Honai, relations
Binomial Theorem, Recursion ,Tower of Honai, relationsAqeel Rafique
 

Similar to Deblurring3 (20)

Digtial Image Processing Q@A
Digtial Image Processing Q@ADigtial Image Processing Q@A
Digtial Image Processing Q@A
 
Cse41
Cse41Cse41
Cse41
 
My Lecture Notes from Linear Algebra
My Lecture Notes fromLinear AlgebraMy Lecture Notes fromLinear Algebra
My Lecture Notes from Linear Algebra
 
Quadratic equations
Quadratic equationsQuadratic equations
Quadratic equations
 
Chapter 3 Output Primitives
Chapter 3 Output PrimitivesChapter 3 Output Primitives
Chapter 3 Output Primitives
 
Quadratic functions
Quadratic functionsQuadratic functions
Quadratic functions
 
Lecture_note2.pdf
Lecture_note2.pdfLecture_note2.pdf
Lecture_note2.pdf
 
Nbhm m. a. and m.sc. scholarship test 2007
Nbhm m. a. and m.sc. scholarship test 2007 Nbhm m. a. and m.sc. scholarship test 2007
Nbhm m. a. and m.sc. scholarship test 2007
 
Pptpersamaankuadrat 150205080445-conversion-gate02
Pptpersamaankuadrat 150205080445-conversion-gate02Pptpersamaankuadrat 150205080445-conversion-gate02
Pptpersamaankuadrat 150205080445-conversion-gate02
 
Nbhm m. a. and m.sc. scholarship test 2006
Nbhm m. a. and m.sc. scholarship test 2006Nbhm m. a. and m.sc. scholarship test 2006
Nbhm m. a. and m.sc. scholarship test 2006
 
Module 2 exponential functions
Module 2   exponential functionsModule 2   exponential functions
Module 2 exponential functions
 
4 pages from matlab an introduction with app.-2
4 pages from matlab an introduction with app.-24 pages from matlab an introduction with app.-2
4 pages from matlab an introduction with app.-2
 
Daa chapter7
Daa chapter7Daa chapter7
Daa chapter7
 
Multivariate Methods Assignment Help
Multivariate Methods Assignment HelpMultivariate Methods Assignment Help
Multivariate Methods Assignment Help
 
Quadratic functions my maths presentation
Quadratic functions my maths presentationQuadratic functions my maths presentation
Quadratic functions my maths presentation
 
Fourier 3
Fourier 3Fourier 3
Fourier 3
 
ALA Solution.pdf
ALA Solution.pdfALA Solution.pdf
ALA Solution.pdf
 
7.curves Further Mathematics Zimbabwe Zimsec Cambridge
7.curves   Further Mathematics Zimbabwe Zimsec Cambridge7.curves   Further Mathematics Zimbabwe Zimsec Cambridge
7.curves Further Mathematics Zimbabwe Zimsec Cambridge
 
Interpolation techniques - Background and implementation
Interpolation techniques - Background and implementationInterpolation techniques - Background and implementation
Interpolation techniques - Background and implementation
 
Binomial Theorem, Recursion ,Tower of Honai, relations
Binomial Theorem, Recursion ,Tower of Honai, relationsBinomial Theorem, Recursion ,Tower of Honai, relations
Binomial Theorem, Recursion ,Tower of Honai, relations
 

Deblurring3

  • 1. IMAGE DEBLURRING: PART 3 ERIK O. MAYER
  • 2. IMAGES AS MATRICES  Images can be represented as matrices, with each entry in the matrix containing the intensity of the corresponding image’s pixel  Grayscale intensities lie on an interval [0, n], where 0 = black, n = white 1040 x 857 image (length by width) 857 x 1040 matrix (rows by columns) x1 1 x1 2 x1 1040 x2 1 x857 1 x857 1040 x2 2 x2 1040  Grayscale images are represented by single matrices  Color images are represented by multidimensional matrices
  • 3. BLURRING AS A LINEAR OPERATION • We have an m x n blurred image B, and the corresponding ideal, sharp m x n image X • Their vector forms, b and x, have m n = N entries, constructed by stacking the columns of B and X respectively • Blur is defined by how information that should be contained in a single pixel “spills over” into surrounding pixels • All the information about how X is blurred to B is contained in some N x N matrix A such that, Ax = b The blurring matrix A has two primary ingredients • Point-Spread Functions • Boundary Conditions
  • 4. BOUNDARY CONDITIONS What’s happening just beyond the edges of our image X?  Different assumptions about the boundary conditions will yield different constructions of the blurring matrix A, and thus affect our ability to accurately model the behavior of the blur
  • 5.  X is surrounded by 0 at every edge This is the “default” boundary assumption  This condition takes effect if no boundary condition is considered at all  A pixel value of 0 corresponds with black, so this condition might be useful for images with black backgrounds, like outer space ZERO BOUNDARY CONDITION
  • 6. X is surrounded by copies of itself, repeated around every edge PERIODIC BOUNDARY CONDITION
  • 7. Each edge of X faces its mirror image With this condition, the pixels at the edge of an image are always next to identically valued pixels just beyond the edge REFLEXIVE BOUNDARY CONDITION
  • 8. POINT SPREAD FUNCTIONS • An image with all black pixels (represented by 0) except for a single white pixel (represented by 1) is known as a Point Source This image is represented as an m x n matrix (the same dimensions as X and B) This matrix could be rearranged into a vector of length m n = N Since this vector is all 0 except for a 1 as the ith entry, this vector is the ith column of an N x N identity matrix, and denoted ei
  • 9. POINT SPREAD FUNCTIONS • A point spread function (PSF) is a function that describes the blurring and the resulting image of the point source. PSF Horizontal Motion BlurOut-of-Focus BlurAtmospheric Turbulence BlurMoffat Blur  For any PSF, the elements of the resulting image must sum to 1, the value of the original point source  If the PSF is the same regardless of the location of the point source, the blurring is spatially invariant
  • 10. HOW A INCORPORATES THE PSF So the columns of A are the same as the blurred images of the various point sources  For each point source vector ei, we can easily determine Aei, the blurred image vector of ei  It’s defined by the PSF itself  But we can also show that Aei is equivalent to the ith column of A
  • 11. THE SIMPLE EXAMPLE Last time, we constructed a 12 x 12 blurring matrix for a 4 x 3 image matrix, where the PSF blurred the point source to a vertical line of 2 pixels (the point source pixel and the pixel directly beneath)  We accomplished this by determining the blurred images of every possible point source (they made up the columns of A) e1 1 0 0 0 0 0 0 0 0 0 0 0 1/2 1/2 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1/2 0 1/2 0 0 0 0 0 0 0 0 0 Point Source Blurred Point Source PSF First column of A
  • 12. THE SIMPLE EXAMPLE  Create the long column vector x from the image matrix X  Multiply A by x to get b, the vector form of the blurred image  Rearrange b back into matrix form to get the blurred image matrix B
  • 13. THE SIMPLE EXAMPLE Our technique of constructing the 12 x 12 blurring matrix A column by column worked well enough for a simple 4 x 3 image  But constructing A column by column is typically extremely time consuming
  • 14. A x = Ax = b = =
  • 15. = Notice how each blurred pixel can be written as a weighted sum of pixels from the sharp image  These weighted sums can be attained through a process called convolution!!!
  • 16. 0 0 0 0.5 0 0 0 0.5 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 Start with a point source and its corresponding blurred image (known as the PSF array)  The position of the nonzero pixel in the point source is the “center” of the PSF array Rotate the PSF array 180° and lay it overtop of the sharp image matrix  Multiply each pair of entries lying atop of one another, then add them all together  The position of the entry from X that is multiplied by the “center” of the PSF array is the position of the entry in B that assumes the value of the weighted sum 0 0 0 0.5 0 0 0 0.5 0 0 0 0 b11 = (1/2)x11 b21 = (1/2)x11 + (1/2)x21 b31 = (1/2)x21 + (1/2)x31 b41 = (1/2)x31 + (1/2)x41 b12 = (1/2)x12 b22 = (1/2)x12 + (1/2)x22 b32 = (1/2)x22 + (1/2)x32 b42 = (1/2)x32 + (1/2)x42 b13 = (1/2)x13 b23 = (1/2)x13 + (1/2)x23 b33 = (1/2)x23 + (1/2)x33 b43 = (1/2)x33 + (1/2)x43 CONVOLUTION
  • 17. NOISE REMOVAL AND EDGE DETECTION Convolution of an image with the PSF array blurs the image, but convolution can be used to accomplish other ends as well  Noise Removal (Low-Pass Filter)  Convolution of an image with a matrix that averages any given pixel with its neighbors  The result is a “smoothing out” of pixels that differ greatly from their neighbors  Edge Detection (High-Pass Filter)  Convolution of an image with a matrix that amplifies pixels that differ greatly from their neighbors  The result is that edges in the image are amplified, but noise is amplified as well
  • 18. p11 p12 p21 p22 p13 p23 p31 p32 p33 p41 p42 p43 p43 p42 p33 p32 p41 p31 p23 p22 p21 p13 p12 p11 b11 = p22(x11) + p12(x21) + 0(x31) + 0(x41) + p21(x12) + p11(x22) + 0(x32) + 0(x42) + 0(x13) + 0(x23) + 0(x33) + 0(x43) CONVOLUTION Let’s repeat the PSF convolution, now with a general PSF array with center p22
  • 19. b31 = p42(x11) + p32(x21) + p22(x31) + p12(x41) + p41(x12) + p31(x22) + p21(x32) + p11(x42) + 0(x13) + 0(x23) + 0(x33) + 0(x43) b11 = p22(x11) + p12(x21) + 0(x31) + 0(x41) + p21(x12) + p11(x22) + 0(x32) + 0(x42) + 0(x13) + 0(x23) + 0(x33) + 0(x43) b21 = p32(x11) + p22(x21) + p12(x31) + 0(x41) + p31(x12) + p21(x22) + p11(x32) + 0(x42) + 0(x13) + 0(x23) + 0(x33) + 0(x43) b41 = 0(x11) + p42(x21) + p32(x31) + p22(x41) + 0(x12) + p41(x22) + p31(x32) + p21(x42) + 0(x13) + 0(x23) + 0(x33) + 0(x43) b12 = p23(x11) + p13(x21) + 0(x31) + 0(x41) + p22(x12) + p12(x22) + 0(x32) + 0(x42) + p21(x13) + p11(x23) + 0(x33) + 0(x43) b22 = p33(x11) + p23(x21) + p13(x31) + 0(x41) + p32(x12) + p22(x22) + p12(x32) + 0(x42) + p31(x13) + p21(x23) + p11(x33) + 0(x43) b32 = p43(x11) + p33(x21) + p23(x31) + p13(x41) + p42(x12) + p32(x22) + p22(x32) + p12(x42) + p41(x13) + p31(x23) + p21(x33) + p11(x43) b42 = 0(x11) + p43(x21) + p33(x31) + p23(x41) + 0(x12) + p42(x22) + p32(x32) + p22(x42) + 0(x13) + p41(x23) + p31(x33) + p21(x43) b13 = 0(x11) + 0(x21) + 0(x31) + 0(x41) + p23(x12) + p13(x22) + 0(x32) + 0(x42) + p22(x13) + p12(x23) + 0(x33) + 0(x43) b23 = 0(x11) + 0(x21) + 0(x31) + 0(x41) + p33(x12) + p23(x22) + p13(x32) + 0(x42) + p32(x13) + p22(x23) + p12(x33) + 0(x43) b33 = 0(x11) + 0(x21) + 0(x31) + 0(x41) + p43(x12) + p33(x22) + p23(x32) + p13(x42) + p42(x13) + p32(x23) + p22(x33) + p12(x43) b43 = 0(x11) + 0(x21) + 0(x31) + 0(x41) + 0(x12) + p43(x22) + p33(x32) + p23(x42) + 0(x13) + p42(x23) + p32(x33) + p22(x43) We’ll convert this system of equations back into a matrix equation
  • 20. = We’ve arrived back at Ax = b, and we can now see that A is filled with the entries of the PSF array!  Is there any generality to be gleaned from A’s structure? Divide A into 4 x 4 blocks  All of the diagonals in each block are constant  A matrix where every diagonal is constant is known as Toeplitz  So all blocks in A are Toeplitz matrices Also, each diagonal of blocks in A is constant! We say that A is a block Toeplitz matrix with Toeplitz blocks  Note: This structure of A holds only when we assume zero boundary conditions • Different boundary conditions yield different general structures for A
  • 21. SEPARABLE BLUR The blur is separable into vertical and horizontal components if the PSF array, P, can be written as an outer product of vectors c and r If this holds, then each element of the PSF array, pij, can be expressed as cirj
  • 22. Let’s assume that the blur is separable in our arbitrary 4 x 3 PSF  Then A can be rewritten as:
  • 23. KRONECKER PRODUCTS 0 0 Each r component is being multiplied by the same matrix of c components  This is a Kronecker Product of the matrix of r components with the matrix of c components With separable blur, we were able to rewrite the full blurring matrix A as the Kronecker product of matrices Ar and Ac , both of which are much smaller than the full matrix A.  The structure of both Ar and Ac is Toeplitz Ar Ac
  • 24. WHAT WE NEED:  For our m x n image matrix X, we need a corresponding PSF array P  If the blur is separable, we can determine vectors c and r such that  Then we can use the entries of c and r to create m x m Ac and n x n Ar  We can do this because we know the Toeplitz structure of those matrices
  • 25. WHAT WE NEED:  The Kronecker Product of Ar and Ac gives us the full mn x mn blurring matrix A  Alternatively, we can use Ar and Ac to blur X directly Ax = b …is equivalent to… Ac X Ar T = B
  • 26. SEPARATING THE BLUR  If the PSF array P is a rank 1 matrix, then c and r can be determined as follows, using the Singular Value Decomposition of P: c = σ1 u1 r = σ1 v1 where σ1 is the first (largest) singular value of P, and u1 and v1 are its corresponding left and right singular vectors.
  • 27. DEBLURRING Ax = b Now we’ve sufficiently built up our model of how A blurs a given image: Then, given a blurry image, we may deduce that it can be deblurred by However, such a reconstruction of the sharp image would be naïve, because our recorded blurry image likely contains more than just blur  Our recorded image also contains noise, errors caused by factors such as technical limitations and poor lighting x = A-1b
  • 28. where bexact = Ax and e represents the noise component. Then our naïve reconstruction can be expressed as: DEBLURRING b = bexact + e xnaïve = A-1b Our recorded image can be expressed as: xnaïve = A-1(bexact + e) xnaïve = x + A-1e xnaïve = A-1bexact + A-1e
  • 29. SINGULAR VALUE DECOMPOSITION OF A = Σi = 1 viui TN σi A-1 A-1e= Σi = 1 ui Te N σi vi where σi are the strictly positive singular values of A, arranged in a non- increasing order, σ1 ≥ σ2 ≥ … ≥ σN > 0. Then the inverted noise can be expressed as: We’ll use the singular value decomposition of A to cut out as much of the inverted noise as possible. So the inverted noise can be written as a linear combination of the right singular vectors, vi
  • 30. A-1e= Σi = 1 ui Te N σi vi SINGULAR VALUE DECOMPOSITION OF A Because the singular vectors are ordered such that σ1 ≥ σ2 ≥ … ≥ σN > 0, the coefficients on vi get very large as i gets large  So the later terms in the sum contribute more to the inverted noise  Removing terms from the end of the sum will reduce the size of the error, at the cost of sacrificing some of the image’s information
  • 31. TRUNCATION xnaïve = A-1b = Σi = 1 ui Tb N σi vi If we choose k < N, then our truncated reconstruction is, Our “naïve” reconstruction can be represented as, xk = Σi = 1 ui Tb k σi vi This is called the Truncated SVD method, or the TSVD
  • 32. SPECTRAL FILTERING where Φi is the filter factor for the ith term in the sum The truncated SVD method is actually an example of a more general class of reconstruction methods called spectral filtering  The filtered reconstruction is defined as: The TSVD can be defined in terms of this general model by allowing: xfilt = Σi = 1 ui TbN σi viΦi Φi = 1, i = 1, … , k 0, i = k + 1, … , N{
  • 33. “R” EXAMPLE In the program R, I created a 9 x 13 image matrix X, and defined the PSF to take the point source and blur it to a square of 4 pixels  Instead of constructing the 117 x 117 blurring matrix A column by column, I created the 9 x 9 Ac and the 13 x 13 Ar , and used those to blur my image
  • 34. ALTERNATE PSF The blurring is less severe in this PSF