KEMBAR78
04 image transformations_ii | PPTX
Part II
Legal Notices and Disclaimers
This presentation is for informational purposes only. INTEL MAKES NO WARRANTIES,
EXPRESS OR IMPLIED, IN THIS SUMMARY.
Intel technologies’ features and benefits depend on system configuration and may require
enabled hardware, software or service activation. Performance varies depending on system
configuration. Check with your system manufacturer or retailer or learn more at intel.com.
This sample source code is released under the Intel Sample Source Code License
Agreement.
Intel and the Intel logo are trademarks of Intel Corporation in the U.S. and/or other countries.
*Other names and brands may be claimed as the property of others.
Copyright © 2018, Intel Corporation. All rights reserved.
2
Canny Edge Detection
This algorithm performs edge detection by completing the following steps:
1. Remove noise with a 5x5 Gaussian
2. Detect horizontal and vertical edges
 The x,y gradients are first computed and then combined into four directional
derivatives
3. Suppress non-maximums (in direction of gradient)
Local maxima define edges
Canny Edge Detection Continued…
4. Apply two thresholds, high and low
Points below low are dropped
Points above high are kept
Points in between are kept if they connect to a kept point
High: Low thresholds should be between 2:1 and 3:1
Note: Direction of gradient is perpendicular to direction of edge
Canny Edge Detection
Low Threshold = 100; High Threshold = 200
Ptolemy and Complex Representation of
Planet Motions
Ptolemy and the ancients had a model of the planets:
• Deferents and epicycles
• A series of smaller circles turning on bigger circles
This modeled the observed motions of the planets fairly well
Ptolemy and Complex Representation of
Planet Motions
But the model was not explanatory.
Why? (CLICK ME)
An infinite sum of circles on top of circles can trace ANY fairly well-behaved (continuous
and not too wiggly) path ...
This is the fundamental idea of Fourier methods.
https://www.youtube.com/watch?v=QVuU2YCwHjw
Ptolemy and Complex Representation of
Planet Motions
The model was descriptive.
• It gave the right positions of planets.
The model was not explanatory.
• The mathematics did not reflect the mechanism of planetary motion (aka gravity).
• Doh!
Fourier Techniques
All Fourier techniques take a function as input and output another function.
They all add up to a very special set of terms that form an orthogonal basis for those fairly
well-behaved functions.
NOTE:
In math, we call this a functional / functional form
In CS, we call this a second-order function
𝑓 𝑔 𝑥 → ℎ 𝑥
𝑓 𝑔 𝑥 → ℎ(𝑦)
𝑋 𝑘 =
1
𝑛
∑
𝑛=0
𝑁−1
𝑋 𝑛
Xi = ith component
of Fourier series,
each a component of
orthogonal basis (see
next slide)
Formula for each Xi
is in later slides.
Fourier Techniques
Orthogonal? Basis?
We have experience with bases from working with data
• We can rewrite any (x,y) point in a 2D plane as (x,y)=x(1,0) + y(0,1)
This is an incredibly powerful mathematical idea that can be applied to many
sets of mathematical objects including functions!
(0,0)
(3,5)
3
0
1
5
0 1
+
How Does Fourier Work?
The bases of Fourier methods are a bit more complicated than (1,0) and (0,1).
They are functions of a special type: They are circles!
• Information needed to coordinate drawing the same circle at the same time (verbal
information)
Image adapted from: https://betterexplained.com/articles/an-interactive-guide-to-the-fourier-transform/
A = Amplitude (radius, size)
P = Phase angle (starting point)
F = Frequency (speed around the circle)A
P
F
Fourier Methods
Fourier methods rewrite a function f in terms of an infinite sum of circles.
The rewritten function is defined at a different set of inputs and produces different
outputs:
• Inputs: Frequencies (speeds of drawing the circles)
• Outputs: The radii and phases (size of circle and angle of starting point)
How Does Fourier Work?
Mathematically, the circles are encoded as either (scary, complex)
exponentials, sins, or sins and cosines.
The three are equivalent because of trigonometric identities and Euler's
formula.
Image adapted from: https://betterexplained.com/articles/an-interactive-guide-to-the-fourier-transform/
cos 𝑥 + 𝑖𝑠𝑖𝑛(𝑥)
𝑒 𝑖𝑥 = cos 𝑥 + 𝑖𝑠𝑖𝑛(𝑥)
𝑒 𝑖𝑥
Fourier Comparison with Taylor Series
Taylor series rewrites a function as a sum of derivative-polynomial terms (a different
basis):
• Function of data to function of data
𝑓 𝑥 =
𝑛=0
∞
𝑓 𝑛 (𝑎)
𝑛!
𝑥 − 𝑎 𝑛
Fourier Comparison with Taylor Series
Same but different:
• Yes it is a rewrite.
• In the Taylor series case, both the original and the rewrite are in terms of
the same inputs and outputs.
Fourier methods are more extreme: They change the domain and range of
the rewritten function!
• f(data)  f(circles)
𝑓 𝑥 =
𝑛=0
∞
𝑓 𝑛 (𝑎)
𝑛!
𝑥 − 𝑎 𝑛
FFT and DFT
We will be using one pair of Fourier methods.
Forward: Data to circle
Backward: Circle to data
FFT and DFT: Forward
Forward: Data to circle
Input fdata([0,N-1]]) 
Output fcircles([0,N-1])
The input function tells us our data values
Input has N data values
Output has N circles
The output function tells us characteristics of the circles in our rewrites
FFT and DFT: Backward
Backward: Circle to data
Input fcircles([0,N-1]]) 
Output fdata([0,N-1])
Here we are going from an input function in terms of circles to an output
function in terms of our data
Input has N circles
Output has N data values
FFT and DFT: p
You might be worried that neither of these are necessarily functions of, or around, a
circle.
What is a function of a circle?
• A function of a circle is defined for each angle of a walk around a circle [0, 2p]
radians
FFT and DFT: p
We can convert to a function of a circle if
1. Our input is discrete and finite:
Map our values from [0, N-1] to points around the circle
Divide [0, 2p] into N parts
This is what we have with images
 Images are discrete and finite
 Edges of the images wrap to make a circle
2. Our input is discrete and repeating:
Do the exact same thing because the circle wraps around itself!
Obligatory Math #1
𝑋𝑘 =
1
𝑁
𝑛=0
𝑁−1
𝑥𝑛 𝑒−𝑖2𝜋𝑘
𝑛
𝑁
Place on Circle
Data
Frequency
Average
Obligatory Math #2
Notice formulas are almost the same
Only fundamental difference is that the sign
of the exponents is opposite.
Different mathematically equivalent equations
will move the 1/N to the circle recipe or split it
as root N on both recipes.
Circle recipe Contributions from a given circle
𝑋𝑘 =
𝑛=0
𝑁−1
𝑥𝑛 𝑒−𝑖2𝜋𝑘
𝑛
𝑁
Data recipe Contributions from a given circle
𝑥𝑛 =
1
𝑁
𝑘=0
𝑁−1
𝑋𝑘 𝑒 𝑖2𝜋𝑛
𝑘
𝑁
Place on Circle
Data
Frequency
Average
Why Fourier?
Filtering
Fast convolutions
Compression
• See JPEG and MP3s!
Why Fourier?
Our rewrite in terms of circles can be hacked.
Different circles move at different speeds
• For example, we even have a term for the stationary circle: the mean
Speeds (frequencies) are related to image regions of slow and fast variation
• High-speed changes are either edges or noise
Low-speed changes are, taken together, a peculiar averaging of the data.
Why Fourier?
These give us:
High-pass filters where we keep high frequencies.
Low-pass filters where we keep low frequencies.
Frequency Based Techniques: High-Pass
Filters
High-pass filtering removes low frequencies.
In images, a high frequency is a contour.
Why Fourier?
We can take advantage of properties of Fourier transforms.
Convolutions, in circle space, are simply multiplication.
This can allow us to drastically speed up convolutions:
1. Discrete Fourier transform (DFT) the data and the kernel
2. Perform multiplication in circle space
3. Transform back to data space
Filters
Simple averaging
Gaussian edge detection
• Laplacian
• Sobel
• Scharr
How to Use Fourier Methods
NumPy and OpenCV (and others):
• It uses the fast Fourier transform to compute the discrete Fourier transform.
Gives data points from an underlying, unknown function
• There are usually some variations for dealing with different types of input.
• There are variations for whether we are going forward (to circle space) or
backwards (to data space).
How to Use Fourier Methods
There are usually some helper functions to deal with the weirdness of
implementation details.
One important detail is that of size:
 DFT algorithms are designed to work best with particular sizes
 Different implementations subdivide the problem into different sizes, so
they have different ideal input sizes
– NumPy implementation ideal size is a power of 2
– OpenCV implementation ideal size is a product of 2s, 3s, 5s
– For example, 2*2*3*5*5 = 300
For OpenCV, we can calculate with cv2.getOptimalDFTSize().
Wavelets
Wavelets are an alternative basis to represent data.
• There are many, many wavelet basis
• Circles can be exponentials or sin/cos
These are closer to one cycle of sin or cos
Haar wavelet basis
Wavelets
A data representation describes the phenomena point-by-point.
Circle space describes the data in terms of cycles.
Wavelets represent a tradeoff between the two.
Wavelets
We can tell something about both the data and the circle characteristics at the same
time.
But …
• We can’t know both exactly.
• Amazingly, this is the mathematical root of one version of the Heisenberg
Uncertainty Principle.
Wavelet Applications
Wavelets are:
• Used for denoising
• Used for compression
• May outperform DFT and discrete cosine transform (DCT) in peak detection
Wavelet Applications
Low-pass filter
• Approximation coefficient
High-pass filter
• Detail coefficient
Horizontal
Vertical
Diagonal
Approximation Coefficient (low pass) Horizontal details (high pass)
Vertical details (high pass) Diagonal details (high pass)
Discrete Wavelet Transform
Similar to the FFT and DFT, we use the discrete wavelet transform (DWT).
We use the PyWavelets* (pywt) package to do the calculations.
import pywt
cA2, (cH2, cV2, cD2), (cH1, cV1, cD1) =
pywt.wavedec2(messi, 'haar', level=2)
Discrete Wavelet Transform
Level is similar to levels in a Gaussian pyramid:
• One application of DWT results in an approximate image and details.
We can add the two to get back the original image
• Subsequent applications of DWT on the level 1 approximate image give us a level 2
approximate image and level 2 detail images.
• We can continue applying this process recursively.
Line Detection: Successive Approximation
Transforming from a curve-contour to a simpler representation (aka line simplification)
Piecewise-linear polyline
B-spline curve
If the contour is a line (with noise) we can simplify it to that line.
If not, the line simplification is used to approximate the original curve.
Hough Transforms
Propose shape from point
Count points that agree with shape
Keep shapes at points with highest counts
Can do this for any shape we can describe with a small number of parameters (such as
point-slope, angle-distance, center-radius, center-scale-angle).
Hough Transforms
LINES CIRCLES
Hough Transforms: An Example
What potential lines do we see here?
Hough Transforms: An Example
Setup  m,b grid
Count = 3 at
m = -1 and b = 4
m
b
3
Hough Transforms: An Example
Accumulator over (distances, angles)
Fill d, Q table (accumulator) with counts of agreeing pixels
0-(w,h)
# bins
0-p) radians
# bins
0 1 2 3
135
90
45
0
Angle with respect to
line, pixel, and horizontal
Hough Transforms: An Example
L1 L2 L3 L4
D = 2.83 or ~3
Q = 45
D = 2
Q = 90
D = 2
Q = 0
D = 0
Q = 135
Hough Transforms: An Example
Tally of the points that match the d,Q model
0 1 2 3
135
90
45
0
L1
L2
L4
L3
2cts
3cts
2cts
2cts
1 point votes (cts) for 4 lines (L1-L4)
is 1 vote per angle bin
Hough Circle Transform
The circle is similar to the lines
But, the vote is performed by taking the circle center and its radius
Three parameters in this case
Would be too slow because of combinatorics
Would produce a very sparse table because of relatively few matching objects
Instead, we use the gradient and combined edges
Only the connected can vote for the same circle
General Hough Transform
We can generalize this process to other shapes by using a contour instead of the
perimeter of the circle.
Track from a pixel on the contour, rotate the orientation of the contour around a circle
• Count pixels matching at angles.
• Can also have scaling factors.
Line Detection: RANdom SAmple Consensus
(RANSAC)Pair of edge elements are used to form a line hypothesis.
How many others fall on this line?
Set boundaries for minimum matchers
Can also use RANSAC for image alignment.
Note: see OpenCV fitLine:
It may use a RANSAC-like method
Is it RANSAC-like only in use of m-estimator?
Edge Thinning: Detecting Thick Edges
Detect thick edges as one edge (without doubling)
Morphological erosion
Skeletonization
Watershed
Pearling
Convert edges to contours
 findCountours()
Line Detection: Hough Transforms
For occluded lines, we need more advanced techniques like Hough transform.
• NOTE: Hough can include or exclude gradient information.
• With it:
Do not need to orient the line
Need fewer accumulators
Do not need inner loop (work has already been done)

04 image transformations_ii

  • 1.
  • 2.
    Legal Notices andDisclaimers This presentation is for informational purposes only. INTEL MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS SUMMARY. Intel technologies’ features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. Check with your system manufacturer or retailer or learn more at intel.com. This sample source code is released under the Intel Sample Source Code License Agreement. Intel and the Intel logo are trademarks of Intel Corporation in the U.S. and/or other countries. *Other names and brands may be claimed as the property of others. Copyright © 2018, Intel Corporation. All rights reserved. 2
  • 4.
    Canny Edge Detection Thisalgorithm performs edge detection by completing the following steps: 1. Remove noise with a 5x5 Gaussian 2. Detect horizontal and vertical edges  The x,y gradients are first computed and then combined into four directional derivatives 3. Suppress non-maximums (in direction of gradient) Local maxima define edges
  • 5.
    Canny Edge DetectionContinued… 4. Apply two thresholds, high and low Points below low are dropped Points above high are kept Points in between are kept if they connect to a kept point High: Low thresholds should be between 2:1 and 3:1 Note: Direction of gradient is perpendicular to direction of edge
  • 6.
    Canny Edge Detection LowThreshold = 100; High Threshold = 200
  • 8.
    Ptolemy and ComplexRepresentation of Planet Motions Ptolemy and the ancients had a model of the planets: • Deferents and epicycles • A series of smaller circles turning on bigger circles This modeled the observed motions of the planets fairly well
  • 9.
    Ptolemy and ComplexRepresentation of Planet Motions But the model was not explanatory. Why? (CLICK ME) An infinite sum of circles on top of circles can trace ANY fairly well-behaved (continuous and not too wiggly) path ... This is the fundamental idea of Fourier methods. https://www.youtube.com/watch?v=QVuU2YCwHjw
  • 10.
    Ptolemy and ComplexRepresentation of Planet Motions The model was descriptive. • It gave the right positions of planets. The model was not explanatory. • The mathematics did not reflect the mechanism of planetary motion (aka gravity). • Doh!
  • 11.
    Fourier Techniques All Fouriertechniques take a function as input and output another function. They all add up to a very special set of terms that form an orthogonal basis for those fairly well-behaved functions. NOTE: In math, we call this a functional / functional form In CS, we call this a second-order function 𝑓 𝑔 𝑥 → ℎ 𝑥 𝑓 𝑔 𝑥 → ℎ(𝑦) 𝑋 𝑘 = 1 𝑛 ∑ 𝑛=0 𝑁−1 𝑋 𝑛 Xi = ith component of Fourier series, each a component of orthogonal basis (see next slide) Formula for each Xi is in later slides.
  • 12.
    Fourier Techniques Orthogonal? Basis? Wehave experience with bases from working with data • We can rewrite any (x,y) point in a 2D plane as (x,y)=x(1,0) + y(0,1) This is an incredibly powerful mathematical idea that can be applied to many sets of mathematical objects including functions! (0,0) (3,5) 3 0 1 5 0 1 +
  • 13.
    How Does FourierWork? The bases of Fourier methods are a bit more complicated than (1,0) and (0,1). They are functions of a special type: They are circles! • Information needed to coordinate drawing the same circle at the same time (verbal information) Image adapted from: https://betterexplained.com/articles/an-interactive-guide-to-the-fourier-transform/ A = Amplitude (radius, size) P = Phase angle (starting point) F = Frequency (speed around the circle)A P F
  • 14.
    Fourier Methods Fourier methodsrewrite a function f in terms of an infinite sum of circles. The rewritten function is defined at a different set of inputs and produces different outputs: • Inputs: Frequencies (speeds of drawing the circles) • Outputs: The radii and phases (size of circle and angle of starting point)
  • 15.
    How Does FourierWork? Mathematically, the circles are encoded as either (scary, complex) exponentials, sins, or sins and cosines. The three are equivalent because of trigonometric identities and Euler's formula. Image adapted from: https://betterexplained.com/articles/an-interactive-guide-to-the-fourier-transform/ cos 𝑥 + 𝑖𝑠𝑖𝑛(𝑥) 𝑒 𝑖𝑥 = cos 𝑥 + 𝑖𝑠𝑖𝑛(𝑥) 𝑒 𝑖𝑥
  • 16.
    Fourier Comparison withTaylor Series Taylor series rewrites a function as a sum of derivative-polynomial terms (a different basis): • Function of data to function of data 𝑓 𝑥 = 𝑛=0 ∞ 𝑓 𝑛 (𝑎) 𝑛! 𝑥 − 𝑎 𝑛
  • 17.
    Fourier Comparison withTaylor Series Same but different: • Yes it is a rewrite. • In the Taylor series case, both the original and the rewrite are in terms of the same inputs and outputs. Fourier methods are more extreme: They change the domain and range of the rewritten function! • f(data)  f(circles) 𝑓 𝑥 = 𝑛=0 ∞ 𝑓 𝑛 (𝑎) 𝑛! 𝑥 − 𝑎 𝑛
  • 18.
    FFT and DFT Wewill be using one pair of Fourier methods. Forward: Data to circle Backward: Circle to data
  • 19.
    FFT and DFT:Forward Forward: Data to circle Input fdata([0,N-1]])  Output fcircles([0,N-1]) The input function tells us our data values Input has N data values Output has N circles The output function tells us characteristics of the circles in our rewrites
  • 20.
    FFT and DFT:Backward Backward: Circle to data Input fcircles([0,N-1]])  Output fdata([0,N-1]) Here we are going from an input function in terms of circles to an output function in terms of our data Input has N circles Output has N data values
  • 21.
    FFT and DFT:p You might be worried that neither of these are necessarily functions of, or around, a circle. What is a function of a circle? • A function of a circle is defined for each angle of a walk around a circle [0, 2p] radians
  • 22.
    FFT and DFT:p We can convert to a function of a circle if 1. Our input is discrete and finite: Map our values from [0, N-1] to points around the circle Divide [0, 2p] into N parts This is what we have with images  Images are discrete and finite  Edges of the images wrap to make a circle 2. Our input is discrete and repeating: Do the exact same thing because the circle wraps around itself!
  • 23.
    Obligatory Math #1 𝑋𝑘= 1 𝑁 𝑛=0 𝑁−1 𝑥𝑛 𝑒−𝑖2𝜋𝑘 𝑛 𝑁 Place on Circle Data Frequency Average
  • 24.
    Obligatory Math #2 Noticeformulas are almost the same Only fundamental difference is that the sign of the exponents is opposite. Different mathematically equivalent equations will move the 1/N to the circle recipe or split it as root N on both recipes. Circle recipe Contributions from a given circle 𝑋𝑘 = 𝑛=0 𝑁−1 𝑥𝑛 𝑒−𝑖2𝜋𝑘 𝑛 𝑁 Data recipe Contributions from a given circle 𝑥𝑛 = 1 𝑁 𝑘=0 𝑁−1 𝑋𝑘 𝑒 𝑖2𝜋𝑛 𝑘 𝑁 Place on Circle Data Frequency Average
  • 25.
  • 26.
    Why Fourier? Our rewritein terms of circles can be hacked. Different circles move at different speeds • For example, we even have a term for the stationary circle: the mean Speeds (frequencies) are related to image regions of slow and fast variation • High-speed changes are either edges or noise Low-speed changes are, taken together, a peculiar averaging of the data.
  • 27.
    Why Fourier? These giveus: High-pass filters where we keep high frequencies. Low-pass filters where we keep low frequencies.
  • 28.
    Frequency Based Techniques:High-Pass Filters High-pass filtering removes low frequencies. In images, a high frequency is a contour.
  • 29.
    Why Fourier? We cantake advantage of properties of Fourier transforms. Convolutions, in circle space, are simply multiplication. This can allow us to drastically speed up convolutions: 1. Discrete Fourier transform (DFT) the data and the kernel 2. Perform multiplication in circle space 3. Transform back to data space
  • 30.
    Filters Simple averaging Gaussian edgedetection • Laplacian • Sobel • Scharr
  • 31.
    How to UseFourier Methods NumPy and OpenCV (and others): • It uses the fast Fourier transform to compute the discrete Fourier transform. Gives data points from an underlying, unknown function • There are usually some variations for dealing with different types of input. • There are variations for whether we are going forward (to circle space) or backwards (to data space).
  • 32.
    How to UseFourier Methods There are usually some helper functions to deal with the weirdness of implementation details. One important detail is that of size:  DFT algorithms are designed to work best with particular sizes  Different implementations subdivide the problem into different sizes, so they have different ideal input sizes – NumPy implementation ideal size is a power of 2 – OpenCV implementation ideal size is a product of 2s, 3s, 5s – For example, 2*2*3*5*5 = 300 For OpenCV, we can calculate with cv2.getOptimalDFTSize().
  • 33.
    Wavelets Wavelets are analternative basis to represent data. • There are many, many wavelet basis • Circles can be exponentials or sin/cos These are closer to one cycle of sin or cos Haar wavelet basis
  • 34.
    Wavelets A data representationdescribes the phenomena point-by-point. Circle space describes the data in terms of cycles. Wavelets represent a tradeoff between the two.
  • 35.
    Wavelets We can tellsomething about both the data and the circle characteristics at the same time. But … • We can’t know both exactly. • Amazingly, this is the mathematical root of one version of the Heisenberg Uncertainty Principle.
  • 36.
    Wavelet Applications Wavelets are: •Used for denoising • Used for compression • May outperform DFT and discrete cosine transform (DCT) in peak detection
  • 37.
    Wavelet Applications Low-pass filter •Approximation coefficient High-pass filter • Detail coefficient Horizontal Vertical Diagonal Approximation Coefficient (low pass) Horizontal details (high pass) Vertical details (high pass) Diagonal details (high pass)
  • 38.
    Discrete Wavelet Transform Similarto the FFT and DFT, we use the discrete wavelet transform (DWT). We use the PyWavelets* (pywt) package to do the calculations. import pywt cA2, (cH2, cV2, cD2), (cH1, cV1, cD1) = pywt.wavedec2(messi, 'haar', level=2)
  • 39.
    Discrete Wavelet Transform Levelis similar to levels in a Gaussian pyramid: • One application of DWT results in an approximate image and details. We can add the two to get back the original image • Subsequent applications of DWT on the level 1 approximate image give us a level 2 approximate image and level 2 detail images. • We can continue applying this process recursively.
  • 40.
    Line Detection: SuccessiveApproximation Transforming from a curve-contour to a simpler representation (aka line simplification) Piecewise-linear polyline B-spline curve If the contour is a line (with noise) we can simplify it to that line. If not, the line simplification is used to approximate the original curve.
  • 41.
    Hough Transforms Propose shapefrom point Count points that agree with shape Keep shapes at points with highest counts Can do this for any shape we can describe with a small number of parameters (such as point-slope, angle-distance, center-radius, center-scale-angle).
  • 42.
  • 43.
    Hough Transforms: AnExample What potential lines do we see here?
  • 44.
    Hough Transforms: AnExample Setup  m,b grid Count = 3 at m = -1 and b = 4 m b 3
  • 45.
    Hough Transforms: AnExample Accumulator over (distances, angles) Fill d, Q table (accumulator) with counts of agreeing pixels 0-(w,h) # bins 0-p) radians # bins 0 1 2 3 135 90 45 0 Angle with respect to line, pixel, and horizontal
  • 46.
    Hough Transforms: AnExample L1 L2 L3 L4 D = 2.83 or ~3 Q = 45 D = 2 Q = 90 D = 2 Q = 0 D = 0 Q = 135
  • 47.
    Hough Transforms: AnExample Tally of the points that match the d,Q model 0 1 2 3 135 90 45 0 L1 L2 L4 L3 2cts 3cts 2cts 2cts 1 point votes (cts) for 4 lines (L1-L4) is 1 vote per angle bin
  • 48.
    Hough Circle Transform Thecircle is similar to the lines But, the vote is performed by taking the circle center and its radius Three parameters in this case Would be too slow because of combinatorics Would produce a very sparse table because of relatively few matching objects Instead, we use the gradient and combined edges Only the connected can vote for the same circle
  • 49.
    General Hough Transform Wecan generalize this process to other shapes by using a contour instead of the perimeter of the circle. Track from a pixel on the contour, rotate the orientation of the contour around a circle • Count pixels matching at angles. • Can also have scaling factors.
  • 50.
    Line Detection: RANdomSAmple Consensus (RANSAC)Pair of edge elements are used to form a line hypothesis. How many others fall on this line? Set boundaries for minimum matchers Can also use RANSAC for image alignment. Note: see OpenCV fitLine: It may use a RANSAC-like method Is it RANSAC-like only in use of m-estimator?
  • 51.
    Edge Thinning: DetectingThick Edges Detect thick edges as one edge (without doubling) Morphological erosion Skeletonization Watershed Pearling Convert edges to contours  findCountours()
  • 52.
    Line Detection: HoughTransforms For occluded lines, we need more advanced techniques like Hough transform. • NOTE: Hough can include or exclude gradient information. • With it: Do not need to orient the line Need fewer accumulators Do not need inner loop (work has already been done)

Editor's Notes

  • #7 Image url?
  • #10 Click the ”click me” when in presentation mode. Note: Skip to 1:00 on the video for the start of drawing homer https://www.youtube.com/watch?v=QVuU2YCwHjw
  • #12 For the mathematicians, well-behaved means finite Lebesgue measure.
  • #13 The scalar value x times a special element of the plane. Since we can write any (x,y) point in the plane in terms of the special elements (0,1) and (1,0), they form a basis for the 2D plane. Since they cannot be written in terms of each other (try it!), they are orthogonal.
  • #14 How big of a circle (the radius or amplitude) Where to start in the circle (an angle or phase) How fast to draw around the diameter (a speed or frequency) Images adapted from https://betterexplained.com at URL: https://betterexplained.com/articles/an-interactive-guide-to-the-fourier-transform/
  • #16 We will see the exponetial form in a second Images adapted from: https://betterexplained.com/articles/an-interactive-guide-to-the-fourier-transform/
  • #25 NOTE: The colors are chosen to maximize the similarities between the forwards and the backwards transforms. Note that the red ‘x’s are the data in forward case and the frequencies in the backward case. But, in reality, they are symmetric and can be interpreted either way. Don’t get hung up, the key is that the forward and backward transforms are effectively the same. We can make them even more similar if instead of a 1/N factor in the backward transform we have factors of 1/sqrt(N) in both forward and backward. Then the only difference is the sign.
  • #29 Image url?
  • #37 DCT discrete cosine transformation is basically a real number version of DFT
  • #46 We are going to discuss theta in terms of the angle of the line through the test point that might match other points. In reality, OpenCV returns thetas that are the angle of the line normal to our line (that is perpendicular to our line). That means there is a 90-degree difference between them.
  • #47 The red line is perpendicular (angle of our line of interest minus 90-degrees wrapping around a circle and mirroring the half circle). For mirroring, +90 = 270 for wrapping, 45-90 = 315 = 135