Im Image Form rmation, , Basic ic Im Image Processing Wei-Chih - - PowerPoint PPT Presentation

im image form rmation basic ic im image processing
SMART_READER_LITE
LIVE PREVIEW

Im Image Form rmation, , Basic ic Im Image Processing Wei-Chih - - PowerPoint PPT Presentation

Lecture 2: Im Image Form rmation, , Basic ic Im Image Processing Wei-Chih Tu ( ) National Taiwan University Fall 2018 Vision How vision is formed Physical world Sensing device Interpreting device Interpretations cat,


slide-1
SLIDE 1

Im Image Form rmation, , Basic ic Im Image Processing

Wei-Chih Tu (塗偉志) National Taiwan University Fall 2018 Lecture 2:

slide-2
SLIDE 2

Vision

  • How vision is formed

Sensing device Interpreting device CPU/GPU/DSP Interpretations cat, lovely, in a box Physical world Image formation Image processing

2

slide-3
SLIDE 3

Image Formation

  • Emission theory of vision

Eyes send out “feeling rays” into the world

Slide by Alexei Efros

Supported by:

  • Empedocles
  • Plato
  • Euclid (kinda)
  • Ptolemy
  • 50% of US college students*

*http://www.ncbi.nlm.nih.gov/pubmed/12094435?dopt=Abstract

“For every complex problem there is an answer that is clear, simple, and wrong.”

  • - H. L. Mencken

3

slide-4
SLIDE 4

Image Formation

  • The human eye is a camera
  • The image is inverted, but the spatial relationships are preserved

4

slide-5
SLIDE 5

Mini-tutorial on Color

  • What is color?
  • Def The property possessed by an object of producing different

sensations on the eye as a result of the way it reflects or emits light.

  • - Oxford Dictionary
  • Color is perceptual!
  • Which one is “true blue”?

5

slide-6
SLIDE 6

Color

  • How do we see light?
  • Cones (short, medium, long)
  • Rods

6

slide-7
SLIDE 7

Color

  • We only see very small range of EM spectrum

7

slide-8
SLIDE 8

Color

  • Spectral power distribution (SPD)

Media IC & System Lab 8

slide-9
SLIDE 9

Color

  • Human vision sensation is a “dimension reduction”!
  • Many-to-one mapping

9

SPD of a real apple  stimulating S = 0.2, M = 0.2, L = 0.8 SPD of red ink  stimulating S = 0.2, M = 0.2, L = 0.8 same color

slide-10
SLIDE 10

Color

  • Tristimulus color theory (1850~)
  • Grassman’s Law
  • A source color can be matched by a linear combination of three

independent primaries.

  • Quantifying color
  • SPDs go through a “black box” (human visual system) and are

perceived as color

  • Scientists performed human study…

10

slide-11
SLIDE 11

Color

  • CIE RGB color matching

11

slide-12
SLIDE 12

Color

  • CIE RGB results

Media IC & System Lab 12

slide-13
SLIDE 13

Color

  • CIE 1931

13

slide-14
SLIDE 14

CIE XYZ 3D Plot

14

slide-15
SLIDE 15

Color

  • What does it mean?
  • Given a SPD, 𝐽(𝜇), we can find its mapping into the CIE XYZ space
  • Given two SPDs, if their CIE XYZ values are equal, they are

considered the same perceived color

Media IC & System Lab 15

𝑌 = න

380 780

𝐽 𝜇 ҧ 𝑦 𝜇 𝑒𝜇 𝑍 = න

380 780

𝐽 𝜇 ത 𝑧 𝜇 𝑒𝜇 𝑎 = න

380 780

𝐽 𝜇 ҧ 𝑨 𝜇 𝑒𝜇

slide-16
SLIDE 16

Color

  • Sometimes it is useful to discuss color in terms of luminance

and chromaticity

  • CIE xy chromaticity is designed for this purpose
  • Project the CIE XYZ values onto the X + Y + Z = 1 plane

16

slide-17
SLIDE 17

Color

  • CIE xy chromaticity diagram
  • Gamut

17

slide-18
SLIDE 18

Color

  • The XYZ values are not specific to any device
  • What does RGB = (33, 55, 128) mean?
  • For example: iPhone Xs vs. HTC U12+
  • Devices (camera, scanners, displays, …) can find mappings of

their specific values to corresponding CIE XYZ values

  • Standard RGB (sRGB)
  • This provides a canonical space to match between devices!

18

slide-19
SLIDE 19

Color

  • And the light source matters

19

slide-20
SLIDE 20

Color

  • Color constancy: They “perceive” the same!

20

slide-21
SLIDE 21

Color

  • More color constancy

21 https://motherboard.vice.com/en_us/article/this-picture-has-no-red-pixelsso-why-do-the-strawberries-still-look-red

slide-22
SLIDE 22

Image Formation

film

  • bject
  • Building a camera
  • Put a piece of film in front of an object

22

slide-23
SLIDE 23

Image Formation

film

  • bject
  • Add a barrier to block off most of the rays
  • This reduces blurring

barrier aperture inverted image

23

slide-24
SLIDE 24

Aperture Size Matters

  • Why not making the

aperture as small as possible?

  • Less light get through
  • Diffraction effect

24 Slide by Steve Seitz

slide-25
SLIDE 25

The “Trashcam” Project

https://petapixel.com/2012/04/18/german-garbage-men-turn-dumpsters-into-giant-pinhole-cameras/ 25

slide-26
SLIDE 26

Image Formation

  • Adding a lens

Slide by Steve Seitz 26

slide-27
SLIDE 27

Image Formation

  • Thin lens equation

Source: https://www.chegg.com/homework-help/questions-and-answers/theory-thin-lens-equation-written-1-f-1-0-1-f-focal-length-o-

  • bject-distance-image-distanc-q13090621

27

slide-28
SLIDE 28

Image Formation

film

  • bject
  • The lens focuses light onto the film

lens in focus circle of confusion

28

slide-29
SLIDE 29

Image Formation

  • Circle of confusion controls depth of field

29

Depth of field

Wiki: circle of confusion

slide-30
SLIDE 30

Image Formation

  • Aperture also controls depth of field

30 Wiki: depth of field

slide-31
SLIDE 31

Image Formation

  • Defocus

Source: AMC 31

slide-32
SLIDE 32

Image Formation

  • Real lens consists of two or more pieces of glass
  • To alleviate chromatic aberration and vignetting

Vignetting

32

slide-33
SLIDE 33

Image Formation

  • Focal length controls field of view

33

slide-34
SLIDE 34

Image Formation

  • Shutter speed (exposure time) also matters

34

slide-35
SLIDE 35

Digital Imaging

35

film Sensor (CCD/CMOS)

slide-36
SLIDE 36

Digital Imaging

  • Images are sampled and quantized
  • Sampled: discrete space (and time)
  • Quantized: only a finite number of possible values (i.e. 0 to 255)

36 Source: Ulas Bagci

pixel

slide-37
SLIDE 37

Digital Imaging

  • Camera pipeline

Figure 2.23 from Computer Vision: Algorithms and Applications 37

slide-38
SLIDE 38

Digital Imaging

  • Demosaicing: color filter array interpolation
  • The image sensor knows nothing about color!

Color filter array (CFA) Bayer pattern: 1R1B2G in a 2x2 block

38

slide-39
SLIDE 39

Digital Imaging

39 Wiki: Sergey Prokudin-Gorsky

A picture of Alim Khan (1880-1944), Emir of Bukhara, taken in 1911.

slide-40
SLIDE 40

Digital Imaging

  • More CFA design

40

slide-41
SLIDE 41

Digital Imaging

  • Resolution
  • Image sensor samples and quantizes the scene

Low resolution High resolution

41 Figure by Yen-Cheng Liu

Low sampling rate may cause aliasing artifact

slide-42
SLIDE 42

Digital Imaging

  • Super resolution: the problem of resolving the high

resolution image from the low resolution image

42

Example results of 4x upscaling. Figure from SRGAN [Ledig et al. CVPR 2017]

slide-43
SLIDE 43

Digital Imaging

  • Dynamic range
  • Information loss due to A/D conversion
  • Typical image: 8 bit (0~255)

The world is HDR and our eyes have great ability to sense it

An exposure bracketed sequence (Each picture is a LDR image)

43

slide-44
SLIDE 44

Digital Imaging

  • HDR imaging: LDRs  HDR
  • Tone mapping: HDR  LDR
  • Do we really need HDR?
  • Exposure fusion: LDRs  LDR

[Mertens et al. PG 2007]

44 Wiki: tone mapping

3 exposure (-2,0,+2) tone mapped image of a scene at Nippori Station.

slide-45
SLIDE 45

More Sensing Devices

  • 360 camera

45 Source: LUNA

slide-46
SLIDE 46

More Sensing Devices

  • Infra-red camera

46

slide-47
SLIDE 47

More Sensing Devices

  • Depth camera

47

Kinect V2 (time of flight) PointGrey Bumblebee 2 (stereo)

slide-48
SLIDE 48

Vision

  • How vision is formed

Sensing device Interpreting device CPU/GPU/DSP Interpretations cat, lovely, in a box Physical world Image formation Image processing

48

slide-49
SLIDE 49

Image Processing in the Brain

  • The dorsal stream (green) and ventral stream (purple) are
  • shown. They originate from a common source in the visual

cortex.

49 Wiki: two-streams hypothesis

“what” pathway “where” pathway

slide-50
SLIDE 50

Digital Image Processing

  • Extract information (what and where) from digital images

50

slide-51
SLIDE 51

Digital Image Processing

  • Some low-level image processing
  • Histogram
  • Morphological operations
  • Edge detection
  • Image filtering
  • Topics to be covered in this course
  • Key point and feature descriptor
  • Matching
  • Geometric transformation
  • Semantic analysis
  • Learning-based techniques

51

slide-52
SLIDE 52

Histogram

52

slide-53
SLIDE 53

Histogram

  • Histogram equalization
  • By mapping CDF to the line 𝑧 = 𝑦

53

slide-54
SLIDE 54

Histogram

  • Understanding data distribution

54

slide-55
SLIDE 55

Morphological Operations

  • Take a binary image and a structuring element as input.

55 https://homepages.inf.ed.ac.uk/rbf/HIPR2/morops.htm

Dilation Example structuring element Erosion dilate

slide-56
SLIDE 56

Morphological Operations

56

  • Opening: erosion  dilation
  • Closing: dilation  erosion
slide-57
SLIDE 57

Image Filtering

  • What is filtering?
  • Forming a new image whose pixel values are transformed from
  • riginal pixel values
  • Goals
  • To extract useful information from images
  • e.g. edges
  • To transform images into another domain where we can

modify/enhance image properties

  • e.g. denoising, image decomposition

57

slide-58
SLIDE 58

Image Filtering

  • Try it yourself!

58

http://setosa.io/ev/image-kernels/

slide-59
SLIDE 59

Image Filtering

  • Convolution
  • Linear shift invariant (LSI)

59 Figure 3.10 from Computer Vision: Algorithms and Applications

Output size changed… 

slide-60
SLIDE 60

Image Filtering

  • Padding

60

Zero padding Symmetric Replicate Circular

slide-61
SLIDE 61

Image Filtering

  • Box filter
  • Average filter
  • Compute summation if ignoring 1/𝑂
  • Complexity: 𝑃(𝑠2)

61

825 9

box filter

slide-62
SLIDE 62

Image Filtering

  • Box filter in 𝑃(𝑠)
  • Moving sum technique

62

Moving 1 pixel forward

+

  • Source: Ben Weiss
slide-63
SLIDE 63

Image Filtering

  • Box filter in 𝑃(1)
  • Integral image (sum area table)
  • Computing integral image: 2 addition + 1 subtraction
  • Obtaining box sum: 2 subtraction + 1 addition
  • Regardless of box size 

63

Sum = 24 Sum = 48 – 14 – 13 + 3 = 24 19 + 17 – 11 + 3 = 28 Note: 𝑃(1) filter is also called constant time filter

slide-64
SLIDE 64

Image Filtering

  • Gaussian filter
  • The kernel weight is a Gaussian function
  • Center pixels contribute more weights

64

1D illustration of Gaussian functions

𝜏 = 1 𝜏 = 2 𝜏 = 3

slide-65
SLIDE 65

Image Filtering

  • Gaussian filter
  • 2D case:
  • Complexity: 𝑃(𝑠2)

65

slide-66
SLIDE 66

Image Filtering

  • Gaussian filter in 𝑃(𝑠)
  • Gaussian kernel is separable

(The same technique can be applied to other separable kernels)

66

slide-67
SLIDE 67

Image Filtering

  • Gaussian filter in 𝑃(𝑠)

67

Input Image 1D Pass 1D Pass Input Image 2D Sliding Window

Direct 2D implementation: 𝑃(𝑠2) Separable implementation: 𝑃(𝑠)

slide-68
SLIDE 68

Image Filtering

  • Gaussian filter in 𝑃(1)
  • FFT
  • Iterative box filtering
  • Recursive filter

68

slide-69
SLIDE 69

Image Filtering

  • 𝑃(1) Gaussian filter by FFT approach
  • Complexity:
  • Take FFT: 𝑃(𝑥ℎ ln(𝑥) ln(ℎ))
  • Multiply by FFT of Gaussian: 𝑃(𝑥ℎ)
  • Take inverse FFT: 𝑃(𝑥ℎ ln(𝑥) ln(ℎ))
  • Cost independent of filter size

69

slide-70
SLIDE 70

Image Filtering

  • 𝑃(1) Gaussian filter by iterative box filtering
  • Based on the central limit theorem
  • Pros: easy to implement!
  • Cons: limited choice of box size (3, 5, 7, …) results in limited choice
  • f Gaussian function 𝜏2

70

Box Box * Box Box3 Box4

slide-71
SLIDE 71

Image Filtering

  • 𝑃(1) Gaussian filter by recursive implementation
  • All filters we discussed above are FIR filters
  • We can use IIR (infinite impulse response) filters to approximate

Gaussians…

71

1st order IIR filter: 2nd order IIR filter:

slide-72
SLIDE 72

IIR Filters

72

64

+

÷2

+

slide-73
SLIDE 73

IIR Filters

  • The example above is an exponential decay
  • Equivalent to convolution by:

73

slide-74
SLIDE 74

IIR Filters

  • Makes large, smooth filters with very little computation! 
  • One forward pass (causal), one backward pass (anti-causal),

equivalent to convolution by:

74

slide-75
SLIDE 75

Image Filtering

  • 𝑃(1) Gaussian filter by recursive implementation
  • 2nd order IIR filter approximation

75

“Recursively implementing the Gaussian and its derivatives”, ICIP 1992

slide-76
SLIDE 76

Image Filtering

  • Median filter
  • 3x3 example:

76

11 19 22 12 25 27 18 26 23 A local patch 11, 12, 18, 19, 22, 23, 25, 26, 27 Sort 11 19 22 12 22 27 18 26 23 Replace center pixel value by median

slide-77
SLIDE 77

Image Filtering

  • Median filter
  • Useful to deal with salt and pepper noise

77

Original Add salt & pepper Gaussian filter Median filter

Source: https://www.pinterest.com/pin/304485624782669932

slide-78
SLIDE 78

Edge Detection

78 Slide by Steve Seitz

Convert a 2D image into a set of curves

  • Extract salient features of the scene
  • More compact than pixels
slide-79
SLIDE 79

Edge Detection

  • We know edges are special from mammalian vision studies

79

Hubel & Wiesel (1962)

slide-80
SLIDE 80

Edge Detection

  • Origin of edges

80

depth discontinuity surface color discontinuity illumination discontinuity surface normal discontinuity

Slide by Steve Seitz

slide-81
SLIDE 81

Edge Detection

  • Characterizing edges

81

Intensity profile Gradient magnitude

slide-82
SLIDE 82

Edge Detection

  • How to compute gradient for digital images?
  • Take discrete derivative
  • Gradient direction and magnitude

82

slide-83
SLIDE 83

Discrete Derivative

  • Backward difference
  • Forward difference
  • Central difference

83

Equivalent to convolve with:

[1, -1] [-1, 1] [1, 0, -1]

slide-84
SLIDE 84

Edge Detection

  • Sobel filter

84 Wiki: Sobel operator

Input image 𝐻 After thresholding

slide-85
SLIDE 85

Edge Detection

  • Effect of noise
  • Difference filters respond strongly to noise
  • Solution: smooth first

85 Slide by Steve Seitz

slide-86
SLIDE 86

Derivative Theorem of Convolution

  • Differentiation is convolution, which is associative:

86

slide-87
SLIDE 87

Edge Detection

  • Tradeoff between smoothing and localization
  • Smoothing filter removes noise but blurs edges 

87

No filtering Gaussian filter, 𝜏 = 2 Gaussian filter, 𝜏 = 5

slide-88
SLIDE 88

Edge Detection

  • Criteria for a good edge detector
  • Good detection
  • Find all real edges, ignoring noise
  • Good localization
  • Locate edges as close as possible to the true edges
  • Edge width is only one pixel

88

Not edge Missing edge Bad localization

slide-89
SLIDE 89

Edge Detection

  • Canny edge detector
  • The most widely used edge detector
  • The best you can find in existing tools like MATLAB, OpenCV…
  • Algorithm:
  • Apply Gaussian filter to reduce noise
  • Find the intensity gradients of the image
  • Apply non-maximum suppression to get rid of false edges
  • Apply double threshold to determine potential edges
  • Track edge by hysteresis: suppressing weak edges that are not

connected to strong edges

89

slide-90
SLIDE 90

Non-Maximum Suppression

90

Bilinear interpolation Gradient magnitude After NMS

slide-91
SLIDE 91

Double Thresholding

91

Strong edges Weak edges

slide-92
SLIDE 92

Hysteresis

  • Find connected components from strong edge pixels to

finalize edge detection

92

slide-93
SLIDE 93

More Image Filtering

  • Bilateral filter
  • Smoothing images while preserving edges

93

Input Output Edge remains sharp Small fluctuations are removed

slide-94
SLIDE 94

Bilateral Filtering

  • Bilateral filter
  • Spatial kernel: weights are larger for pixels near the window center
  • Range kernel: weights are larger if the neighbor pixel has similar

intensity (color) to the center pixel

94

Spatial kernel Range kernel

slide-95
SLIDE 95

Bilateral Filtering

95

slide-96
SLIDE 96

Joint Bilateral Filtering

  • The range kernel takes another guidance image as reference

96

Flash No flash Joint bilateral filtering

http://hhoppe.com/proj/flash/

slide-97
SLIDE 97

Bilateral Filtering

  • Fast bilateral filtering also exists
  • “A fast approximation of the bilateral filter using a signal processing

approach”, ECCV 2006

  • “Constant time O(1) bilateral filtering”, CVPR 2008
  • “Real-time O(1) bilateral filtering”, CVPR 2009
  • “Fast high-dimensional filtering using the permutohedral lattice”, EG 2010
  • and many more…
  • We also contribute some works in this field
  • “Constant time bilateral filtering for color images”, ICIP 2016
  • “VLSI architecture design of layer-based bilateral and median filtering for

4k2k videos at 30fps”, ISCAS 2017

97

slide-98
SLIDE 98

Guided Image Filtering

  • Local linear assumption
  • Per pixel 𝑃(1)

98 http://kaiminghe.com/eccv10/index.html

[He et al. ECCV 2010]

slide-99
SLIDE 99

Guided Image Filtering

  • Local linear assumption

99

[He et al. ECCV 2010]

Linear regression

slide-100
SLIDE 100

Edge-Preserving Filtering

  • Both the bilateral filter and the guided image filter are

called edge-preserving filters (EPF)

  • They can smooth images while preserving edges
  • Other widely used EPFs with source code
  • Weighted least square filter, SIGGRAPH 2008
  • Domain transform filter, SIGGRAPH 2011
  • 𝑀0 filter, SIGGRAPH Asia 2011
  • Fast global smoothing filter, TIP 2014

100

slide-101
SLIDE 101

Edge-Preserving Filtering

  • Applications

101

Edit (e.g. color) propagation Guided upsampling (depth maps, features, …, etc.) Detail manipulation

slide-102
SLIDE 102

What we have learned today

  • Digital imaging
  • Some low-level image processing

Sensing device Interpreting device CPU/GPU/DSP Interpretations cat, lovely, in a box Physical world Image formation

  • Pinhole camera
  • Photography
  • Camera pipeline

Image processing

  • Histogram
  • Morphological operations
  • Edge detection
  • Image filtering

102