SlideShare a Scribd company logo
1 of 30
Lecture 9: RANSAC
CS5760: Computer Vision
Noah Snavely
http://www.wired.com/gadgetlab/2010/07/camera-software-lets-you-see-into-the-past/
Reading
• Szeliski: Chapter 6.1
Announcements
• Project 2 – code due today at 11:59pm
– Report due Friday at 11:59pm
• Midterm
– Plan to release in class next Wednesday, 3/13
– Due at the beginning of class, Monday, 3/18
• Kristen Grauman talk
– Friday at noon
Outliers outliers
inliers
Robustness
• Let’s consider a simpler example… linear
regression
• How can we fix this?
Problem: Fit a line to these datapoints Least squares fit
We need a better cost function…
• Suggestions?
Idea
• Given a hypothesized line
• Count the number of points that “agree” with
the line
– “Agree” = within a small distance of the line
– I.e., the inliers to that line
• For all possible lines, select the one with the
largest number of inliers
Counting inliers
Counting inliers
Inliers: 3
Counting inliers
Inliers: 20
How do we find the best line?
• Unlike least-squares, no simple closed-form
solution
• Hypothesize-and-test
– Try out many lines, keep the best one
– Which lines?
Translations
RAndom SAmple Consensus
Select one match at random, count inliers
RAndom SAmple Consensus
Select another match at random, count inliers
RAndom SAmple Consensus
Output the translation with the highest number of inliers
RANSAC
• Idea:
– All the inliers will agree with each other on the
translation vector; the (hopefully small) number of
outliers will (hopefully) disagree with each other
• RANSAC only has guarantees if there are < 50% outliers
– “All good matches are alike; every bad match is
bad in its own way.”
– Tolstoy via Alyosha Efros
RANSAC
• Inlier threshold related to the amount of
noise we expect in inliers
– Often model noise as Gaussian with some
standard deviation (e.g., 3 pixels)
• Number of rounds related to the percentage
of outliers we expect, and the probability of
success we’d like to guarantee
– Suppose there are 20% outliers, and we want to
find the correct answer with 99% probability
– How many rounds do we need?
RANSAC
x translation
y translation
set threshold so that, e.g.,
95% of the Gaussian
lies inside that radius
RANSAC
• Back to linear regression
• How do we generate a hypothesis?
x
y
RANSAC
x
y
• Back to linear regression
• How do we generate a hypothesis?
RANSAC
• General version:
1. Randomly choose s samples
• Typically s = minimum sample size that lets you fit a
model
2. Fit a model (e.g., line) to those samples
3. Count the number of inliers that approximately
fit the model
4. Repeat N times
5. Choose the model that has the largest set of
inliers
How many rounds?
• If we have to choose s samples each time
– with an outlier ratio e
– and we want the right answer with probability p
proportion of outliers e
s 5% 10% 20% 25% 30% 40% 50%
2 2 3 5 6 7 11 17
3 3 4 7 9 11 19 35
4 3 5 9 13 17 34 72
5 4 6 12 17 26 57 146
6 4 7 16 24 37 97 293
7 4 8 20 33 54 163 588
8 5 9 26 44 78 272 1177
Source: M. Pollefeys
p = 0.99
How big is s?
• For alignment, depends on the motion model
– Here, each sample is a correspondence (pair of
matching points)
RANSAC pros and cons
• Pros
– Simple and general
– Applicable to many different problems
– Often works well in practice
• Cons
– Parameters to tune
– Sometimes too many iterations are required
– Can fail for extremely low inlier ratios
– We can often do better than brute-force sampling
Final step: least squares fit
Find average translation vector over all inliers
RANSAC
• An example of a “voting”-based fitting scheme
• Each hypothesis gets voted on by each data
point, best hypothesis wins
• There are many other types of voting schemes
– E.g., Hough transforms…
Panoramas
• Now we know how to create panoramas!
• Given two images:
– Step 1: Detect features
– Step 2: Match features
– Step 3: Compute a homography using RANSAC
– Step 4: Combine the images together (somehow)
• What if we have more than two images?
Can we use homographies to create a
360 panorama?
• In order to figure this out, we need to learn
what a camera is
360 panorama
Questions?

More Related Content

Similar to lec09_ransac.pptx

Applied Mathematical Modeling with Apache Solr - Joel Bernstein, Lucidworks
Applied Mathematical Modeling with Apache Solr - Joel Bernstein, LucidworksApplied Mathematical Modeling with Apache Solr - Joel Bernstein, Lucidworks
Applied Mathematical Modeling with Apache Solr - Joel Bernstein, Lucidworks
Lucidworks
 

Similar to lec09_ransac.pptx (20)

Data Analysis and Algorithms Lecture 1: Introduction
 Data Analysis and Algorithms Lecture 1: Introduction Data Analysis and Algorithms Lecture 1: Introduction
Data Analysis and Algorithms Lecture 1: Introduction
 
Simple math for anomaly detection toufic boubez - metafor software - monito...
Simple math for anomaly detection   toufic boubez - metafor software - monito...Simple math for anomaly detection   toufic boubez - metafor software - monito...
Simple math for anomaly detection toufic boubez - metafor software - monito...
 
Applied Mathematical Modeling with Apache Solr - Joel Bernstein, Lucidworks
Applied Mathematical Modeling with Apache Solr - Joel Bernstein, LucidworksApplied Mathematical Modeling with Apache Solr - Joel Bernstein, Lucidworks
Applied Mathematical Modeling with Apache Solr - Joel Bernstein, Lucidworks
 
Greedy_Backtracking graph coloring.ppt
Greedy_Backtracking graph coloring.pptGreedy_Backtracking graph coloring.ppt
Greedy_Backtracking graph coloring.ppt
 
Anomaly detection Full Article
Anomaly detection Full ArticleAnomaly detection Full Article
Anomaly detection Full Article
 
Week08.pdf
Week08.pdfWeek08.pdf
Week08.pdf
 
Lecture 6
Lecture 6Lecture 6
Lecture 6
 
17 large scale machine learning
17 large scale machine learning17 large scale machine learning
17 large scale machine learning
 
Distance-based bias in model-directed optimization of additively decomposable...
Distance-based bias in model-directed optimization of additively decomposable...Distance-based bias in model-directed optimization of additively decomposable...
Distance-based bias in model-directed optimization of additively decomposable...
 
Quantum Computers new Generation of Computers part 7 by prof lili saghafi Qua...
Quantum Computers new Generation of Computers part 7 by prof lili saghafi Qua...Quantum Computers new Generation of Computers part 7 by prof lili saghafi Qua...
Quantum Computers new Generation of Computers part 7 by prof lili saghafi Qua...
 
AI Algorithms
AI AlgorithmsAI Algorithms
AI Algorithms
 
cs 601 - lecture 1.pptx
cs 601 - lecture 1.pptxcs 601 - lecture 1.pptx
cs 601 - lecture 1.pptx
 
lec10svm.ppt
lec10svm.pptlec10svm.ppt
lec10svm.ppt
 
Clustering - ACM 2013 02-25
Clustering - ACM 2013 02-25Clustering - ACM 2013 02-25
Clustering - ACM 2013 02-25
 
Unit III_Ch 17_Probablistic Methods.pptx
Unit III_Ch 17_Probablistic Methods.pptxUnit III_Ch 17_Probablistic Methods.pptx
Unit III_Ch 17_Probablistic Methods.pptx
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 
lec1.ppt
lec1.pptlec1.ppt
lec1.ppt
 
Lec07-Greedy Algorithms.pdf Lec07-Greedy Algorithms.pdf
Lec07-Greedy Algorithms.pdf Lec07-Greedy Algorithms.pdfLec07-Greedy Algorithms.pdf Lec07-Greedy Algorithms.pdf
Lec07-Greedy Algorithms.pdf Lec07-Greedy Algorithms.pdf
 
Pseudo Random Number
Pseudo Random NumberPseudo Random Number
Pseudo Random Number
 
Machine Learning, Stock Market and Chaos
Machine Learning, Stock Market and Chaos Machine Learning, Stock Market and Chaos
Machine Learning, Stock Market and Chaos
 

More from AneesAbbasi14 (10)

Goal Setting UPDATED.pptx
Goal Setting UPDATED.pptxGoal Setting UPDATED.pptx
Goal Setting UPDATED.pptx
 
Lec_15_OOP_ObjectsAsParametersFriendClasses.pdf
Lec_15_OOP_ObjectsAsParametersFriendClasses.pdfLec_15_OOP_ObjectsAsParametersFriendClasses.pdf
Lec_15_OOP_ObjectsAsParametersFriendClasses.pdf
 
lecture-2021inheritance-160705095417.pdf
lecture-2021inheritance-160705095417.pdflecture-2021inheritance-160705095417.pdf
lecture-2021inheritance-160705095417.pdf
 
lecture-18staticdatamember-160705095116.pdf
lecture-18staticdatamember-160705095116.pdflecture-18staticdatamember-160705095116.pdf
lecture-18staticdatamember-160705095116.pdf
 
lec07_transformations.pptx
lec07_transformations.pptxlec07_transformations.pptx
lec07_transformations.pptx
 
02-07-20_Anees.pptx
02-07-20_Anees.pptx02-07-20_Anees.pptx
02-07-20_Anees.pptx
 
Yasir Presentation.pptx
Yasir Presentation.pptxYasir Presentation.pptx
Yasir Presentation.pptx
 
Lec5_OOP.pptx
Lec5_OOP.pptxLec5_OOP.pptx
Lec5_OOP.pptx
 
Lec_1,2_OOP_(Introduction).pdf
Lec_1,2_OOP_(Introduction).pdfLec_1,2_OOP_(Introduction).pdf
Lec_1,2_OOP_(Introduction).pdf
 
IntroComputerVision23.pptx
IntroComputerVision23.pptxIntroComputerVision23.pptx
IntroComputerVision23.pptx
 

Recently uploaded

Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 

Recently uploaded (20)

80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 

lec09_ransac.pptx

  • 1. Lecture 9: RANSAC CS5760: Computer Vision Noah Snavely http://www.wired.com/gadgetlab/2010/07/camera-software-lets-you-see-into-the-past/
  • 3. Announcements • Project 2 – code due today at 11:59pm – Report due Friday at 11:59pm • Midterm – Plan to release in class next Wednesday, 3/13 – Due at the beginning of class, Monday, 3/18 • Kristen Grauman talk – Friday at noon
  • 5. Robustness • Let’s consider a simpler example… linear regression • How can we fix this? Problem: Fit a line to these datapoints Least squares fit
  • 6. We need a better cost function… • Suggestions?
  • 7. Idea • Given a hypothesized line • Count the number of points that “agree” with the line – “Agree” = within a small distance of the line – I.e., the inliers to that line • For all possible lines, select the one with the largest number of inliers
  • 11. How do we find the best line? • Unlike least-squares, no simple closed-form solution • Hypothesize-and-test – Try out many lines, keep the best one – Which lines?
  • 13. RAndom SAmple Consensus Select one match at random, count inliers
  • 14. RAndom SAmple Consensus Select another match at random, count inliers
  • 15. RAndom SAmple Consensus Output the translation with the highest number of inliers
  • 16. RANSAC • Idea: – All the inliers will agree with each other on the translation vector; the (hopefully small) number of outliers will (hopefully) disagree with each other • RANSAC only has guarantees if there are < 50% outliers – “All good matches are alike; every bad match is bad in its own way.” – Tolstoy via Alyosha Efros
  • 17. RANSAC • Inlier threshold related to the amount of noise we expect in inliers – Often model noise as Gaussian with some standard deviation (e.g., 3 pixels) • Number of rounds related to the percentage of outliers we expect, and the probability of success we’d like to guarantee – Suppose there are 20% outliers, and we want to find the correct answer with 99% probability – How many rounds do we need?
  • 18. RANSAC x translation y translation set threshold so that, e.g., 95% of the Gaussian lies inside that radius
  • 19. RANSAC • Back to linear regression • How do we generate a hypothesis? x y
  • 20. RANSAC x y • Back to linear regression • How do we generate a hypothesis?
  • 21. RANSAC • General version: 1. Randomly choose s samples • Typically s = minimum sample size that lets you fit a model 2. Fit a model (e.g., line) to those samples 3. Count the number of inliers that approximately fit the model 4. Repeat N times 5. Choose the model that has the largest set of inliers
  • 22. How many rounds? • If we have to choose s samples each time – with an outlier ratio e – and we want the right answer with probability p proportion of outliers e s 5% 10% 20% 25% 30% 40% 50% 2 2 3 5 6 7 11 17 3 3 4 7 9 11 19 35 4 3 5 9 13 17 34 72 5 4 6 12 17 26 57 146 6 4 7 16 24 37 97 293 7 4 8 20 33 54 163 588 8 5 9 26 44 78 272 1177 Source: M. Pollefeys p = 0.99
  • 23. How big is s? • For alignment, depends on the motion model – Here, each sample is a correspondence (pair of matching points)
  • 24. RANSAC pros and cons • Pros – Simple and general – Applicable to many different problems – Often works well in practice • Cons – Parameters to tune – Sometimes too many iterations are required – Can fail for extremely low inlier ratios – We can often do better than brute-force sampling
  • 25. Final step: least squares fit Find average translation vector over all inliers
  • 26. RANSAC • An example of a “voting”-based fitting scheme • Each hypothesis gets voted on by each data point, best hypothesis wins • There are many other types of voting schemes – E.g., Hough transforms…
  • 27. Panoramas • Now we know how to create panoramas! • Given two images: – Step 1: Detect features – Step 2: Match features – Step 3: Compute a homography using RANSAC – Step 4: Combine the images together (somehow) • What if we have more than two images?
  • 28. Can we use homographies to create a 360 panorama? • In order to figure this out, we need to learn what a camera is