40
Image Processing and Analysis (ImagePandA) 5 – Image Restoration and Reconstruction Christoph Lampert / Chris Wojtan Based on slides by Selim Aksoy, Bilkent University

Image Processing and Analysis (ImagePandA) 5 – Image Restoration and Reconstruction Christoph Lampert / Chris Wojtan Based on slides by Selim Aksoy, Bilkent

Embed Size (px)

Citation preview

Page 1: Image Processing and Analysis (ImagePandA) 5 – Image Restoration and Reconstruction Christoph Lampert / Chris Wojtan Based on slides by Selim Aksoy, Bilkent

Image Processing and Analysis (ImagePandA)

5 – Image Restoration and Reconstruction

Christoph Lampert / Chris Wojtan

Based on slides by Selim Aksoy, Bilkent University

Page 2: Image Processing and Analysis (ImagePandA) 5 – Image Restoration and Reconstruction Christoph Lampert / Chris Wojtan Based on slides by Selim Aksoy, Bilkent

Image interpolation

Page 3: Image Processing and Analysis (ImagePandA) 5 – Image Restoration and Reconstruction Christoph Lampert / Chris Wojtan Based on slides by Selim Aksoy, Bilkent

Image interpolation

Page 4: Image Processing and Analysis (ImagePandA) 5 – Image Restoration and Reconstruction Christoph Lampert / Chris Wojtan Based on slides by Selim Aksoy, Bilkent

Image interpolation

Page 5: Image Processing and Analysis (ImagePandA) 5 – Image Restoration and Reconstruction Christoph Lampert / Chris Wojtan Based on slides by Selim Aksoy, Bilkent

Nearest neighbor interpolation

Page 6: Image Processing and Analysis (ImagePandA) 5 – Image Restoration and Reconstruction Christoph Lampert / Chris Wojtan Based on slides by Selim Aksoy, Bilkent

Image interpolation

Page 7: Image Processing and Analysis (ImagePandA) 5 – Image Restoration and Reconstruction Christoph Lampert / Chris Wojtan Based on slides by Selim Aksoy, Bilkent

Image interpolation

   

   

 

Page 8: Image Processing and Analysis (ImagePandA) 5 – Image Restoration and Reconstruction Christoph Lampert / Chris Wojtan Based on slides by Selim Aksoy, Bilkent

Nearest neighbor interpolationFirst, find the x and y values of the nearest pixels

int[] px = new int[4];int[] py = new int[4];px[0] = Math.floor(x); py[0] = Math.floor(y);px[1] = Math.ceil(x); py[1] = Math.floor(y);px[2] = Math.floor(x); py[2] = Math.ceil(y);px[3] = Math.ceil(x); py[3] = Math.ceil(y);

   

   

 

Page 9: Image Processing and Analysis (ImagePandA) 5 – Image Restoration and Reconstruction Christoph Lampert / Chris Wojtan Based on slides by Selim Aksoy, Bilkent

Nearest neighbor interpolationNext, find the nearest pixel

int nx, ny; // x,y coords of nearest neighbordouble minDist = Double.MAX_VALUE;for(int i=0; i<4; i++) { double dist = Math.abs(x-px[i])+Math.abs(y-py[i]); if(dist<minDist) { minDist = dist; nx=px[i]; ny=py[i]; }}

Finally, assign the value of the nearest pixel

pixelVal = image.get(nx,ny);

   

   

 

Page 10: Image Processing and Analysis (ImagePandA) 5 – Image Restoration and Reconstruction Christoph Lampert / Chris Wojtan Based on slides by Selim Aksoy, Bilkent

Nearest neighbor interpolation

Page 11: Image Processing and Analysis (ImagePandA) 5 – Image Restoration and Reconstruction Christoph Lampert / Chris Wojtan Based on slides by Selim Aksoy, Bilkent

Piecewise linear interpolation

Page 12: Image Processing and Analysis (ImagePandA) 5 – Image Restoration and Reconstruction Christoph Lampert / Chris Wojtan Based on slides by Selim Aksoy, Bilkent

Piecewise Linear interpolation

 

 

  

 

 

 

0 1

 

 

Page 13: Image Processing and Analysis (ImagePandA) 5 – Image Restoration and Reconstruction Christoph Lampert / Chris Wojtan Based on slides by Selim Aksoy, Bilkent

Piecewise linear interpolation

Page 14: Image Processing and Analysis (ImagePandA) 5 – Image Restoration and Reconstruction Christoph Lampert / Chris Wojtan Based on slides by Selim Aksoy, Bilkent

Piecewise cubic interpolation

Page 15: Image Processing and Analysis (ImagePandA) 5 – Image Restoration and Reconstruction Christoph Lampert / Chris Wojtan Based on slides by Selim Aksoy, Bilkent

Piecewise Cubic (Hermite) interpolation

 

 

 

Page 16: Image Processing and Analysis (ImagePandA) 5 – Image Restoration and Reconstruction Christoph Lampert / Chris Wojtan Based on slides by Selim Aksoy, Bilkent

2D interpolation

Nearest neighbor Bi-linear Bi-cubic

Page 17: Image Processing and Analysis (ImagePandA) 5 – Image Restoration and Reconstruction Christoph Lampert / Chris Wojtan Based on slides by Selim Aksoy, Bilkent

17

Resizing images

How can we generate a half-sized version of a large image?

Adapted from Steve Seitz, U of Washington

Page 18: Image Processing and Analysis (ImagePandA) 5 – Image Restoration and Reconstruction Christoph Lampert / Chris Wojtan Based on slides by Selim Aksoy, Bilkent

18

Resizing images

Throw away every other row and column to create a 1/2 size image (also called sub-sampling).

1/4

1/8

Adapted from Steve Seitz, U of Washington

Page 19: Image Processing and Analysis (ImagePandA) 5 – Image Restoration and Reconstruction Christoph Lampert / Chris Wojtan Based on slides by Selim Aksoy, Bilkent

19

Resizing images

Does this look nice?1/4 (2x zoom)

1/8 (4x zoom)

1/2

Adapted from Steve Seitz, U of Washington

Page 20: Image Processing and Analysis (ImagePandA) 5 – Image Restoration and Reconstruction Christoph Lampert / Chris Wojtan Based on slides by Selim Aksoy, Bilkent

20

Sampling and aliasing

Adapted from Steve Seitz, U of Washington

Page 21: Image Processing and Analysis (ImagePandA) 5 – Image Restoration and Reconstruction Christoph Lampert / Chris Wojtan Based on slides by Selim Aksoy, Bilkent

Sampling and aliasing

http://www.youtube.com/watch?v=ckmtG8CZjDA

Page 22: Image Processing and Analysis (ImagePandA) 5 – Image Restoration and Reconstruction Christoph Lampert / Chris Wojtan Based on slides by Selim Aksoy, Bilkent

22

Sampling and aliasing

Errors appear if we do not sample properly. Common phenomenon:

High spatial frequency components of the image appear as low spatial frequency components.

Examples: Wagon wheels rolling the wrong way in movies. Checkerboards misrepresented in ray tracing. Striped shirts look funny on color television.

Page 23: Image Processing and Analysis (ImagePandA) 5 – Image Restoration and Reconstruction Christoph Lampert / Chris Wojtan Based on slides by Selim Aksoy, Bilkent

23

Resizing images

Throw away every other row and column…… regular sampling of a high-frequency function!

1/4

1/8

Adapted from Steve Seitz, U of Washington

Page 24: Image Processing and Analysis (ImagePandA) 5 – Image Restoration and Reconstruction Christoph Lampert / Chris Wojtan Based on slides by Selim Aksoy, Bilkent

24

Resizing images

Does this look nice?1/4 (2x zoom)

1/8 (4x zoom)

1/2

Adapted from Steve Seitz, U of Washington

ALIASING

Page 25: Image Processing and Analysis (ImagePandA) 5 – Image Restoration and Reconstruction Christoph Lampert / Chris Wojtan Based on slides by Selim Aksoy, Bilkent

25

Resizing images Regular sampling of a high-frequency image causes

aliasing! Solution: smooth the image (remove high

frequencies) first!

Gaussian 1/4

Gaussian 1/8

Gaussian 1/2

Adapted from Steve Seitz, U of Washington

Page 26: Image Processing and Analysis (ImagePandA) 5 – Image Restoration and Reconstruction Christoph Lampert / Chris Wojtan Based on slides by Selim Aksoy, Bilkent

26

Resizing images

Gaussian 1/4 (2x zoom)

Gaussian 1/8 (4x zoom)

Gaussian 1/2

Adapted from Steve Seitz, U of Washington

Page 27: Image Processing and Analysis (ImagePandA) 5 – Image Restoration and Reconstruction Christoph Lampert / Chris Wojtan Based on slides by Selim Aksoy, Bilkent

28

Gaussian pyramids

Adapted from Michael Black, Brown University

Page 28: Image Processing and Analysis (ImagePandA) 5 – Image Restoration and Reconstruction Christoph Lampert / Chris Wojtan Based on slides by Selim Aksoy, Bilkent

29

Gaussian pyramids

Adapted from Michael Black, Brown University

Page 29: Image Processing and Analysis (ImagePandA) 5 – Image Restoration and Reconstruction Christoph Lampert / Chris Wojtan Based on slides by Selim Aksoy, Bilkent

De-noising

30

 

Page 30: Image Processing and Analysis (ImagePandA) 5 – Image Restoration and Reconstruction Christoph Lampert / Chris Wojtan Based on slides by Selim Aksoy, Bilkent

Removing Noise

31

 

Page 31: Image Processing and Analysis (ImagePandA) 5 – Image Restoration and Reconstruction Christoph Lampert / Chris Wojtan Based on slides by Selim Aksoy, Bilkent

Inverting the Degradation Function

32

 

Page 32: Image Processing and Analysis (ImagePandA) 5 – Image Restoration and Reconstruction Christoph Lampert / Chris Wojtan Based on slides by Selim Aksoy, Bilkent

Inverting the Degradation Function

33

   

 

http://www.sweaglesw.com/cs448/

Original motion-blurred imagePSF Clean image of The Beehive Nebula

Page 33: Image Processing and Analysis (ImagePandA) 5 – Image Restoration and Reconstruction Christoph Lampert / Chris Wojtan Based on slides by Selim Aksoy, Bilkent

Inverting the Degradation Function

34

Page 34: Image Processing and Analysis (ImagePandA) 5 – Image Restoration and Reconstruction Christoph Lampert / Chris Wojtan Based on slides by Selim Aksoy, Bilkent

Inverting the Degradation Function

35

Page 35: Image Processing and Analysis (ImagePandA) 5 – Image Restoration and Reconstruction Christoph Lampert / Chris Wojtan Based on slides by Selim Aksoy, Bilkent

Texture Synthesis

36

Incrementally growing pixels Given an incomplete neighborhood Find similar neighborhoods from the example, copy pixels

?

Page 36: Image Processing and Analysis (ImagePandA) 5 – Image Restoration and Reconstruction Christoph Lampert / Chris Wojtan Based on slides by Selim Aksoy, Bilkent

Texture Synthesis

37

Incrementally growing pixels Given an incomplete neighborhood Find similar neighborhoods from the example, copy pixels

Page 37: Image Processing and Analysis (ImagePandA) 5 – Image Restoration and Reconstruction Christoph Lampert / Chris Wojtan Based on slides by Selim Aksoy, Bilkent

Texture Synthesis

38

Incrementally growing pixels Given an incomplete neighborhood Find similar neighborhoods from the example, copy pixels

Image Quilting Cut up the example into patches (not just pixels) Choose patches which line up the best Stitch the patches together along optimal seems

Page 38: Image Processing and Analysis (ImagePandA) 5 – Image Restoration and Reconstruction Christoph Lampert / Chris Wojtan Based on slides by Selim Aksoy, Bilkent

Texture Synthesis

39

Incrementally growing pixels Given an incomplete neighborhood Find similar neighborhoods from the example, copy pixels

Image Quilting Cut up the example into patches (not just pixels) Choose patches which line up the best Stitch the patches together along optimal seems

Can use this to fill holes in an image Instead of some example, use the image itself http://www.youtube.com/watch?v=NH0aEp1oDOI

Page 39: Image Processing and Analysis (ImagePandA) 5 – Image Restoration and Reconstruction Christoph Lampert / Chris Wojtan Based on slides by Selim Aksoy, Bilkent

Super-resolution

40

How do we increase image size?

Interpolation? Need to fill in missing details

EMBIGGEN

INTERPO

LATION

Page 40: Image Processing and Analysis (ImagePandA) 5 – Image Restoration and Reconstruction Christoph Lampert / Chris Wojtan Based on slides by Selim Aksoy, Bilkent

Super-resolution

41

How do we increase image size? Interpolation?

Need to fill in missing details Combine multiple images at sub-pixel off-sets Synthesize details from examples

Steal details from other images Copy details from same image (at different scales)

http://www.wisdom.weizmann.ac.il/~vision/SingleImageSR.html