Upload
others
View
0
Download
0
Embed Size (px)
Citation preview
Final Review
Image Processing
CSE 166
Lecture 18
Topics covered
• Basis vectors• Matrix-based transforms• Basis images• Wavelet transform• Image compression• Image watermarking• Morphological image processing• Edge detection• Segmentation
CSE 166, Spring 2019 2
Matrix-based transforms
CSE 166, Spring 2019 3
Forward transform
Inverse transform
where
General inverse transform using basis vectors
CSE 166, Spring 2019 4
Matrix-based transforms using orthonormal basis vectors
• In vector form
CSE 166, Spring 2019 5
Matrix-based transforms using orthonormal basis vectors
• In matrix form
CSE 166, Spring 2019 6
Matrix-based transforms using biorthonormal basis vectors
• In matrix form
CSE 166, Spring 2019 7
Matrix-based transform
CSE 166, Spring 2019 8
Example: 8-point DFT of f(x) = sin(2πx)
real part + imaginary part
Matrix-based transforms
• Discrete Fourier transform (DFT)• Discrete Hartley transform (DHT)• Discrete cosine transform (DCT)• Discrete sine transform (DST)• Walsh-Hadamard (WHT)• Slant (SLT)• Haar (HAAR)• Daubechies (DB4)• Biorthogonal B-spline (BIOR3.1)
CSE 166, Spring 2019 9
Basis vectors of matrix-based 1D transforms
CSE 166, Spring 2019 10
N = 16
real part
imaginary part
Standard basis(for reference)
Basis vectors of matrix-based 1D transforms
CSE 166, Spring 2019 11
N = 16
basis dual Standard basis(for reference)
Matrix-based transformsin two dimensions
CSE 166, Spring 2019 12
Forward transform
Inverse transform
where
Matrix-based transformsin two dimensions
• If r and s are separable and symmetric, and M = N, then
– For orthonormal basis vectors
– For biorthonormal basis vectors
CSE 166, Spring 2019 13
Matrix-based transforms in two dimensions using basis images
• Inverse transform
CSE 166, Spring 2019 14
where
Each Su,v is a basis image
Basis images of matrix-based 2D transforms
CSE 166, Spring 2019 15
Standard basis images (for reference)
8-by-8 array of8-by-8
basis images
Basis images of matrix-based 2D transforms
CSE 166, Spring 2019 16
Discrete Fourier transform (DFT) basis images
real part imaginary part
Basis images of matrix-based 2D transforms
CSE 166, Spring 2019 17
Discrete Hartley transform (DHT) basis images
Basis images of matrix-based 2D transforms
CSE 166, Spring 2019 18
Discrete cosine transform (DCT) basis images
Basis images of matrix-based 2D transforms
CSE 166, Spring 2019 19
Discrete sine transform (DST) basis images
Basis images of matrix-based 2D transforms
CSE 166, Spring 2019 20
Walsh-Hadamard transform (WHT) basis images
Basis images of matrix-based 2D transforms
CSE 166, Spring 2019 21
Slant transform (SLT) basis images
Basis images of matrix-based 2D transforms
CSE 166, Spring 2019 22
Haar transform (HAAR) basis images
Wavelet transforms
• A scaling function is used to create a series of approximations of a function or image, each differing by a factor of 2 in resolution from its nearest neighboring approximations.
• Wavelet functions (wavelets) are then used to encode the differences between adjacent approximations.
• The discrete wavelet transform (DWT) uses those wavelets, together with a single scaling function, to represent a function or image as a linear combination of the wavelets and scaling function.
CSE 166, Spring 2019 23
Scaling functions and set of basis vectors
• Father scaling function
• Set of basis functions
– Integer translation k
– Binary scaling j
• Basis of the function space spanned by
CSE 166, Spring 2019 24
Scaling function, multiresolution analysis
1. The scaling function is orthogonal to its integer translates.
2. The function spaces spanned by the scaling function at low scales are nested within those spanned at higher scales.𝑉−∞⊂⋯⊂ 𝑉−1⊂ 𝑉0⊂ 𝑉1⊂⋯⊂ 𝑉∞
3. The only function representable at every scale (all 𝑉𝑗) is f(x) = 0.
4. All measureable, square-integrable functions can be represented as 𝑗 → ∞
CSE 166, Spring 2019 25
• Given father scaling function , there exists a mother wavelet function whose integer translations and binary scalings
span the difference between any two adjacent scaling spaces
• The orthogonal compliment of
Wavelet functions
CSE 166, Spring 2019 26
Relationship between scaling and wavelet function spaces
CSE 166, Spring 2019 27
Union
Scaling function coefficients and wavelet function coefficients
• Refinement (or dilation) equation
where are scaling function coefficients
• And
where are wavelet function coefficients
• Relationship
CSE 166, Spring 2019 28
1D discrete wavelet transform
• Forward
• Inverse
CSE 166, Spring 2019 29
Approximation
Details
2D discrete wavelet transform
• Forward
CSE 166, Spring 2019 30
Approximation
Details
where
Directionalwavelets
2D discrete wavelet transform
• Inverse
CSE 166, Spring 2019 31
2D discrete wavelet transform
CSE 166, Spring 2019 32
Decomposition
2D discrete wavelet transform
CSE 166, Spring 2019 33
3-levelwavelet
decomposition
Wavelet-based edge detection
CSE 166, Spring 2019 34
Zero horizontal
details
Zero lowest scale
approximation
Vertical edges
Edges
Wavelet-based noise removal
CSE 166, Spring 2019 35
Noisy imageThreshold
details
Zero highest
resolution details
Zero details for all levels
Data compression
• Data redundancy
where compression ratio
CSE 166, Spring 2019 36
where
Data redundancy in images
CSE 166, Spring 2019 37
Coding redundancy
Spatial redundancy
Irrelevant information
Does not need all 8 bits
Information is unnecessarily
replicated
Information is not useful
Image information
• Entropy
– It is not possible to encode input image with fewer than bits/pixel
CSE 166, Spring 2019 38
where
Fidelity criteria,objective (quantitative)
• Total error
• Root-mean-square error
• Mean-square signal to noise ratio (SNR)
CSE 166, Spring 2019 39
Fidelity criteriasubjective (qualitative)
CSE 166, Spring 2019 40
Approximations
CSE 166, Spring 2019 41
5.17 15.67 14.17
(a) (b) (c)
Objective (quantitative) qualityrms error (in intensity levels)
Subjective (qualitative) quality, relative
Lower is better
(a) is better than (b).
(b) is better than (c)
Compression system
CSE 166, Spring 2019 42
Compression methods
• Huffman coding• Golomb coding• Arithmetic coding• Lempel-Ziv-Welch (LZW) coding• Run-length coding• Symbol-based coding• Bit-plane coding• Block transform coding• Predictive coding• Wavelet coding
CSE 166, Spring 2019 43
Block-transform coding
CSE 166, Spring 2019 44
Encoder
Decoder
Block-transform coding
• Example: discrete cosine transform
• Inverse
CSE 166, Spring 2019 45
where
Block-transform coding
CSE 166, Spring 2019 46
Discrete cosine transformWalsh-Hadamard transform
4x4 subimages (4x4 basis images)
Block-transform coding
CSE 166, Spring 2019 47
Fourier transform
cosine transform
Walsh-Hadamardtransform
2.32 1.78 1.13rms error
Retain 32 largest
coefficients
Error image
8x8 subimages
Lower is better
Block-transform coding
CSE 166, Spring 2019 48
2x2 4x4 8x8
Reconstruction error versus subimage size
DCT subimage size:
JPEG uses block DCT-based coding
CSE 166, Spring 2019 49
Compression reconstruction
Scaled error image
Zoomed compression
reconstruction
25:1
52:1
Compression ratio
Predictive coding model
CSE 166, Spring 2019 50
Encoder
Decoder
Predictive coding
CSE 166, Spring 2019 51
Input image
Prediction error image
Example: previous pixel coding
Histograms
Wavelet coding
CSE 166, Spring 2019 52
Encoder
Decoder
Wavelet coding
CSE 166, Spring 2019 53
Detail coefficients below 25 are truncated to zero
JPEG-2000 uses wavelet-based coding
CSE 166, Spring 2019 54
Compression reconstruction
Scaled error image
Zoomed compression
reconstruction
25:1
52:1
Compression ratio
JPEG-2000 uses wavelet-based coding
CSE 166, Spring 2019 55
Compression reconstruction
Scaled error image
Zoomed compression
reconstruction
75:1
105:1
Compression ratio
Visible watermark
CSE 166, Spring 2019 56
Original image minus watermark
Watermarked image
Watermark
Invisible image watermarking system
CSE 166, Spring 2019 57
Encoder
Decoder
Invisible watermark
CSE 166, Spring 2019 58
Two least significant
bits
JPEGcompressed
Fragile invisible
watermark
Originalimage Extracted
watermark
Example: watermarking using two least significant bits
Invisible watermark
CSE 166, Spring 2019 59
Watermarked images
Example: DCT-based watermarking
Extracted robust
invisible watermark
Reflection and translation
CSE 166, Spring 2019 60
Translation
Reflection
Sets of pixels: objects and structuring elements (SEs)
CSE 166, Spring 2019 61
Border of background
pixels around objects
Tight border around SE
Reflection about the origin
CSE 166, Spring 2019 62
Origin
Don’t care elements
Erosion
CSE 166, Spring 2019 63
Example: square SE
Complement of A (i.e., set of elements not in A)
Erosion
CSE 166, Spring 2019 64
Example: elongated SE
Erosion
CSE 166, Spring 2019 65
11x11
45x4515x15
Shrinks
Dilation
CSE 166, Spring 2019 66
Square SEExamples
Elongated SE
Dilation
CSE 166, Spring 2019 67
Expands
Opening
CSE 166, Spring 2019 68
Structuring element rolls along inner boundary
Closing
CSE 166, Spring 2019 69
Structuring element rolls along outer boundary
Opening and closing
CSE 166, Spring 2019 70
Opening
Closing
Dilation
Erosion
Morphological image processing
CSE 166, Spring 2019 71
Noisy input
Dilation
Erosion
Opening
Dilation
Erosion
Closing
Boundary extraction
CSE 166, Spring 2019 72
Erosion Set difference
Boundary extraction
CSE 166, Spring 2019 73
Hole filling
CSE 166, Spring 2019 74
Given point in hole
Hole filling
CSE 166, Spring 2019 75
Given points in holes All holes filled
Connected components
CSE 166, Spring 2019 76
Given point in A
Connected components
CSE 166, Spring 2019 77
15 connected
components
X-ray image
Threshold (negative)
Image segmentation
• General approach
1. Spatial filtering
2. Additional processing
3. Thresholding
CSE 166, Spring 2019 78
Image segmentation
CSE 166, Spring 2019 79
Edge-based
Region-based
Input Edges Segmentation
Derivatives in 1D
• Forward difference
• Backward difference
• Central difference
CSE 166, Spring 2019 80
Image derivatives
CSE 166, Spring 2019 81
Detection of isolated points
CSE 166, Spring 2019 82
Laplacian(second derivative)
Input Segmentation
Threshold absolute
value
Line detection
CSE 166, Spring 2019 83
Threshold absolute
value
Threshold value
Laplacian(second
derivative)Input
Double lines
Line detection, specific directions
CSE 166, Spring 2019 84
Spatial filters
Line detection, specific directions
CSE 166, Spring 2019 85
+45°
Negative values set
to zero
Threshold
Edge models
CSE 166, Spring 2019 86
Step Ramp Roof edge
Edge models
CSE 166, Spring 2019 87
Step
RampRoofedge
Ramp edge
CSE 166, Spring 2019 88
First derivative
Second derivative
One point
Two points
Noise and image derivatives
CSE 166, Spring 2019 89
First derivative
Second derivativeInput
Noise
Edge detection
1. Image smoothing for noise reduction
2. Detection of image points (edge point candidates)
3. Edge localization (select from candidates, set of edge points)
CSE 166, Spring 2019 90
Gradient and edge direction
CSE 166, Spring 2019 91
Gradient direction is orthogonal to edge direction
Gradient operators
CSE 166, Spring 2019 92
Forward difference
Gradients
CSE 166, Spring 2019 93
Magnitude of
vertical gradient
Magnitude of
horizontal gradient
Magnitude of
gradient vector
Input
Gradients
CSE 166, Spring 2019 94
Magnitude of
vertical gradient
Magnitude of
horizontal gradient
Magnitude of
gradient vector
Input
Smooth image prior to computing gradients.Results in more selective edges
Edge detection
1. Smooth the input image
2. Compute the gradient magnitude image
3. Apply nonmaximal suppression to the gradient magnitude image
4. Threshold the resulting image
CSE 166, Spring 2019 95
Edge detection
CSE 166, Spring 2019 96
Without smoothing With smoothing
Threshold magnitude of gradient vector
Advanced edge detection
CSE 166, Spring 2019 97
Magnitude of gradient vector
(with smoothing)Input
Marr-Hildreth CannyFigure 10.25 in textbook looks better
Canny edge detector
1. Smooth the input image with a Gaussian filter
2. Compute the gradient magnitude and angle images
3. Apply nonmaximal suppression to the gradient magnitude image
4. Use double thresholding and connectivity analysis to detect and link edges
CSE 166, Spring 2019 98
Double thresholding
• Use a high threshold to start edge curves and a low threshold to continue them– Define two thresholds TH and TL– Starting with output of nonmaximal suppression, find a point q0,
which is a local maximum greater than TH– Start tracking an edge chain at pixel location q0 in one of the two
directions– Stop when gradient magnitude is less than TL
CSE 166, Spring 2019 99
TH
TL
q0
Double thresholding
CSE 166, Spring 2019 100
TH = 15 and TL = 5T = 5T = 15
Single threshold Double threshold
Thresholding
CSE 166, Spring 2019 101
Single threshold Dual thresholds
Histograms
Thresholding
• Single threshold
• Dual thresholds
CSE 166, Spring 2019 102
where
where
Noise and thresholding
CSE 166, Spring 2019 103
Noise
Varying background and thresholding
CSE 166, Spring 2019 104
Intensity ramp Product of input and intensity ramp
Input
Basic global thresholding
CSE 166, Spring 2019 105
Intensity ramp ThresholdInput
Basic global thresholding
CSE 166, Spring 2019 106
Value used to stop iterating
Optimum global thresholding
CSE 166, Spring 2019 107
Histogram
Basic global thresholding
Optimum global
thresholding using Otsu’s
method
Input
Otsu’s method
CSE 166, Spring 2019 108
Image smoothing to improve global thresholding
CSE 166, Spring 2019 109
Without smoothing
With smoothing
Otsu’s method
Image smoothing does not always improve global thresholding
CSE 166, Spring 2019 110
Without smoothing
With smoothing
Otsu’s method
Edges to improve global thresholding
CSE 166, Spring 2019 111
Mask image (thresholded
gradient magnitude)
Input
Masked input
Optimum global
thresholding using Otsu’s
method
Edges to improve global thresholding
CSE 166, Spring 2019 112
Input
Masked input
Optimum global
thresholding using Otsu’s
method
Mask image (thresholded absolute Laplacian)
Variable thresholding
CSE 166, Spring 2019 113
Global thresholding
Local standard
deviations
Local thresholding
using standard
deviations
Input
Variable thresholding
CSE 166, Spring 2019 114
Global thresholding
Local thresholding using moving
averages
Input(spot shading)
Variable thresholding
CSE 166, Spring 2019 115
Global thresholding
Local thresholding using moving
averages
Input(sinusoidal shading)
Segmentation by region growing
CSE 166, Spring 2019 116
Initial seed
image
InputX-ray image
Final seed
image
Output image
Segmentation by region growing
CSE 166, Spring 2019 117
Segmentation by region growing
CSE 166, Spring 2019 118
Difference image thresholded with the smallest of the dual
thresholds
Segmentation by region growing
Difference image thresholded using
dual thresholds
Difference image
Advanced segmentation methods
• k-means clustering
• Superpixels
• Graph cuts
CSE 166, Spring 2019 119
Segmentation using k-means clustering
CSE 166, Spring 2019 120
Input Segmentation using k-means, k = 3
Segmentation using k-means clustering
CSE 166, Spring 2019 121
Superpixels
CSE 166, Spring 2019 122
Image of 4,000 superpixels with
boundaries
Image of 4,000 superpixels
Input image of 480,000 pixels
Superpixels
CSE 166, Spring 2019 123
500 superpixels 250 superpixels1,000 superpixels
Superpixels for image segmentation
CSE 166, Spring 2019 124
Segmentation using k-means, k = 3
Superpixel image (100 superpixels)
Input image of 301,678 pixels
Segmentation using k-means, k = 3
Images as graphs
CSE 166, Spring 2019 125
Simple graph with edges only between
4-connected neighbors
Stronger (greater weight) edges are darker
Graph cuts for image segmentation
CSE 166, Spring 2019 126
Cut the weak edges
Graph cuts for image segmentation
CSE 166, Spring 2019 127
Smoothed input Graph cut segmentation
Input
CSE 166
• Image acquisition
• Geometric transformations and image interpolation
• Intensity transformations
• Spatial filtering
• Fourier transform and filtering in the frequency domain
• Image restoration
• Color image processing
• Basis vectors
• Matrix-based transforms
• Basis images
• Wavelet transform
• Image compression
• Image watermarking
• Morphological image processing
• Edge detection
• Segmentation
CSE 166, Spring 2019 128