SlideShare a Scribd company logo
1 of 31
© 2020 Wael Badawy
11
RANSAC
— Computer Vision —
DISCLAIMER:
This video is optimized for HD large display using
patented and patent-pending “Nile Codec”, the first
Egyptian Video Codec for more information,
PLEASE check https://NileCodec.com
RAndom SAmple Consensus
Also available as a PodCast
http://www.wired.com/gadgetlab/2010/07/camera-software-lets-you-see-into-the-past/
© 2020 Wael Badawy
Copyright © 2020 Wael Badawy. All rights reserved
 This video is subject to copyright owned by Wael Badawy “WB”. Any
reproduction or republication of all or part of this video is expressly prohibited
unless WB has explicitly granted its prior written consent. All other rights
reserved.
 This video is intended for education and information only and is offered AS IS,
without any warranty of the accuracy or the quality of the content. Any other
use is strictly prohibited. The viewer is fully responsible to verify the accuracy
of the contents received without any claims of costs or liability arising .
 The names, trademarks service marked as logos of WB or the sponsors
appearing in this video may not be used in any any product or service,
without prior express written permission from WB and the video sponsors
 Neither WB nor any party involved in creating, producing or delivering
information and material via this video shall be liable for any direction,
incidental, consequential, indirect of punitive damages arising out of access
to, use or inability to use this content or any errors or omissions in the
content thereof.
 If you will continue to watch this video, you agree to the terms above and
other terms that may be available on http://nu.edu.eg & https://caiwave.net
2
© 2020 Wael Badawy
© 2020 Wael Badawy
Reading
 Szeliski: Chapter 6.1
© 2020 Wael Badawy
Outliers
outliers
inliers
© 2020 Wael Badawy
Robustness
 Let’s consider a simpler example… linear regression
 How can we fix this?
Problem: Fit a line to these datapoints Least squares fit
© 2020 Wael Badawy
We need a better cost function…
 Suggestions?
© 2020 Wael Badawy
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
© 2020 Wael Badawy
Counting inliers
© 2020 Wael Badawy
Counting inliers
Inliers: 3
© 2020 Wael Badawy
Counting inliers
Inliers: 20
© 2020 Wael Badawy
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?
© 2020 Wael Badawy
Translations
© 2020 Wael Badawy
RAndom SAmple Consensus
Select one match at random, count inliers
© 2020 Wael Badawy
RAndom SAmple Consensus
Select another match at random, count inliers
© 2020 Wael Badawy
RAndom SAmple Consensus
Output the translation with the highest number of inliers
© 2020 Wael Badawy
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
© 2020 Wael Badawy
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?
© 2020 Wael Badawy
RANSAC
x translation
y translation
set threshold so that,
e.g., 95% of the Gaussian
lies inside that radius
© 2020 Wael Badawy
RANSAC
 Back to linear regression
 How do we generate a hypothesis?
x
y
© 2020 Wael Badawy
RANSAC
 Back to linear regression
 How do we generate a hypothesis?
x
y
© 2020 Wael Badawy
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
© 2020 Wael Badawy
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. Pollefeysp = 0.99
© 2020 Wael Badawy
How big is s?
 For alignment, depends on the motion model
 Here, each sample is a correspondence (pair of
matching points)
© 2020 Wael Badawy
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
© 2020 Wael Badawy
Final step: least squares fit
Find average translation vector over all inliers
© 2020 Wael Badawy
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…
© 2020 Wael Badawy
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?
© 2020 Wael Badawy
Can we use homographies to create a 360
panorama?
 In order to figure this out, we need to learn
what a camera is
© 2020 Wael Badawy
360 panorama
© 2020 Wael Badawy
Questions?

More Related Content

Similar to Computer Vision RANSAC

N F A - Non Deterministic Finite Automata
N F A - Non Deterministic Finite AutomataN F A - Non Deterministic Finite Automata
N F A - Non Deterministic Finite AutomataWael Badawy
 
Devoxx UK 2022 - Application security: What should the attack landscape look ...
Devoxx UK 2022 - Application security: What should the attack landscape look ...Devoxx UK 2022 - Application security: What should the attack landscape look ...
Devoxx UK 2022 - Application security: What should the attack landscape look ...Chris Swan
 
20201013 - Serverless Architecture Conference - How to migrate your existing ...
20201013 - Serverless Architecture Conference - How to migrate your existing ...20201013 - Serverless Architecture Conference - How to migrate your existing ...
20201013 - Serverless Architecture Conference - How to migrate your existing ...Marcia Villalba
 
Little Known Tips & Tricks from Across the Oracle SOA Landscape
Little Known Tips & Tricks from Across the Oracle SOA LandscapeLittle Known Tips & Tricks from Across the Oracle SOA Landscape
Little Known Tips & Tricks from Across the Oracle SOA LandscapeRevelation Technologies
 
State of Load Balancing 2020
State of Load Balancing 2020State of Load Balancing 2020
State of Load Balancing 2020Avi Networks
 
Cloud Computing Terms in Simple Examples
Cloud Computing Terms in Simple ExamplesCloud Computing Terms in Simple Examples
Cloud Computing Terms in Simple ExamplesOrienge
 
Ecommerce Payment Digital Wallet PowerPoint Presentation Slides
Ecommerce Payment Digital Wallet PowerPoint Presentation SlidesEcommerce Payment Digital Wallet PowerPoint Presentation Slides
Ecommerce Payment Digital Wallet PowerPoint Presentation SlidesSlideTeam
 
Realize True Business Value With ThousandEyes
Realize True Business Value With ThousandEyesRealize True Business Value With ThousandEyes
Realize True Business Value With ThousandEyesThousandEyes
 
re:Invent OPN306 AWS Lambda Powertools Lessons 10M downloads.pdf
re:Invent OPN306 AWS Lambda Powertools Lessons 10M downloads.pdfre:Invent OPN306 AWS Lambda Powertools Lessons 10M downloads.pdf
re:Invent OPN306 AWS Lambda Powertools Lessons 10M downloads.pdfHeitor Lessa
 
State of the Union: Compute & DevOps
State of the Union: Compute & DevOpsState of the Union: Compute & DevOps
State of the Union: Compute & DevOpsAmazon Web Services
 

Similar to Computer Vision RANSAC (10)

N F A - Non Deterministic Finite Automata
N F A - Non Deterministic Finite AutomataN F A - Non Deterministic Finite Automata
N F A - Non Deterministic Finite Automata
 
Devoxx UK 2022 - Application security: What should the attack landscape look ...
Devoxx UK 2022 - Application security: What should the attack landscape look ...Devoxx UK 2022 - Application security: What should the attack landscape look ...
Devoxx UK 2022 - Application security: What should the attack landscape look ...
 
20201013 - Serverless Architecture Conference - How to migrate your existing ...
20201013 - Serverless Architecture Conference - How to migrate your existing ...20201013 - Serverless Architecture Conference - How to migrate your existing ...
20201013 - Serverless Architecture Conference - How to migrate your existing ...
 
Little Known Tips & Tricks from Across the Oracle SOA Landscape
Little Known Tips & Tricks from Across the Oracle SOA LandscapeLittle Known Tips & Tricks from Across the Oracle SOA Landscape
Little Known Tips & Tricks from Across the Oracle SOA Landscape
 
State of Load Balancing 2020
State of Load Balancing 2020State of Load Balancing 2020
State of Load Balancing 2020
 
Cloud Computing Terms in Simple Examples
Cloud Computing Terms in Simple ExamplesCloud Computing Terms in Simple Examples
Cloud Computing Terms in Simple Examples
 
Ecommerce Payment Digital Wallet PowerPoint Presentation Slides
Ecommerce Payment Digital Wallet PowerPoint Presentation SlidesEcommerce Payment Digital Wallet PowerPoint Presentation Slides
Ecommerce Payment Digital Wallet PowerPoint Presentation Slides
 
Realize True Business Value With ThousandEyes
Realize True Business Value With ThousandEyesRealize True Business Value With ThousandEyes
Realize True Business Value With ThousandEyes
 
re:Invent OPN306 AWS Lambda Powertools Lessons 10M downloads.pdf
re:Invent OPN306 AWS Lambda Powertools Lessons 10M downloads.pdfre:Invent OPN306 AWS Lambda Powertools Lessons 10M downloads.pdf
re:Invent OPN306 AWS Lambda Powertools Lessons 10M downloads.pdf
 
State of the Union: Compute & DevOps
State of the Union: Compute & DevOpsState of the Union: Compute & DevOps
State of the Union: Compute & DevOps
 

More from Wael Badawy

HTML introduction
HTML introduction HTML introduction
HTML introduction Wael Badawy
 
Np complete reductions
Np complete reductionsNp complete reductions
Np complete reductionsWael Badawy
 
Computer Vision Gans
Computer Vision GansComputer Vision Gans
Computer Vision GansWael Badawy
 
Computer Vision image classification
Computer Vision image classificationComputer Vision image classification
Computer Vision image classificationWael Badawy
 
Computer Vision Structure from motion
Computer Vision Structure from motionComputer Vision Structure from motion
Computer Vision Structure from motionWael Badawy
 
Universal turing
Universal turing Universal turing
Universal turing Wael Badawy
 
Turing variations
Turing variations Turing variations
Turing variations Wael Badawy
 
Time complexity
Time complexity Time complexity
Time complexity Wael Badawy
 
Regular pumping examples
Regular pumping examples Regular pumping examples
Regular pumping examples Wael Badawy
 
Regular properties
Regular propertiesRegular properties
Regular propertiesWael Badawy
 
Pushdown Automota
Pushdown Automota Pushdown Automota
Pushdown Automota Wael Badawy
 
Computer Vision sfm
Computer Vision sfmComputer Vision sfm
Computer Vision sfmWael Badawy
 
Computer vision - photometric
Computer vision - photometricComputer vision - photometric
Computer vision - photometricWael Badawy
 
Computer vision - light
Computer vision - lightComputer vision - light
Computer vision - lightWael Badawy
 
Computer vision - two view geometry
Computer vision -  two view geometryComputer vision -  two view geometry
Computer vision - two view geometryWael Badawy
 
Computer Vision - Stereo Vision
Computer Vision - Stereo VisionComputer Vision - Stereo Vision
Computer Vision - Stereo VisionWael Badawy
 
Computer Vision - Single View
Computer Vision - Single ViewComputer Vision - Single View
Computer Vision - Single ViewWael Badawy
 
Computer Vision panoramas
Computer Vision  panoramasComputer Vision  panoramas
Computer Vision panoramasWael Badawy
 
Computer Vision - cameras
Computer Vision - camerasComputer Vision - cameras
Computer Vision - camerasWael Badawy
 

More from Wael Badawy (20)

HTML introduction
HTML introduction HTML introduction
HTML introduction
 
Np complete reductions
Np complete reductionsNp complete reductions
Np complete reductions
 
Parsers -
Parsers -Parsers -
Parsers -
 
Computer Vision Gans
Computer Vision GansComputer Vision Gans
Computer Vision Gans
 
Computer Vision image classification
Computer Vision image classificationComputer Vision image classification
Computer Vision image classification
 
Computer Vision Structure from motion
Computer Vision Structure from motionComputer Vision Structure from motion
Computer Vision Structure from motion
 
Universal turing
Universal turing Universal turing
Universal turing
 
Turing variations
Turing variations Turing variations
Turing variations
 
Time complexity
Time complexity Time complexity
Time complexity
 
Regular pumping examples
Regular pumping examples Regular pumping examples
Regular pumping examples
 
Regular properties
Regular propertiesRegular properties
Regular properties
 
Pushdown Automota
Pushdown Automota Pushdown Automota
Pushdown Automota
 
Computer Vision sfm
Computer Vision sfmComputer Vision sfm
Computer Vision sfm
 
Computer vision - photometric
Computer vision - photometricComputer vision - photometric
Computer vision - photometric
 
Computer vision - light
Computer vision - lightComputer vision - light
Computer vision - light
 
Computer vision - two view geometry
Computer vision -  two view geometryComputer vision -  two view geometry
Computer vision - two view geometry
 
Computer Vision - Stereo Vision
Computer Vision - Stereo VisionComputer Vision - Stereo Vision
Computer Vision - Stereo Vision
 
Computer Vision - Single View
Computer Vision - Single ViewComputer Vision - Single View
Computer Vision - Single View
 
Computer Vision panoramas
Computer Vision  panoramasComputer Vision  panoramas
Computer Vision panoramas
 
Computer Vision - cameras
Computer Vision - camerasComputer Vision - cameras
Computer Vision - cameras
 

Recently uploaded

Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfChris Hunter
 
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.MaryamAhmad92
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxNikitaBankoti2
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Shubhangi Sonawane
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
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.pdfAdmir Softic
 
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.pdfPoh-Sun Goh
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 

Recently uploaded (20)

Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
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.
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptx
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
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
 
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
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 

Computer Vision RANSAC

  • 1. © 2020 Wael Badawy 11 RANSAC — Computer Vision — DISCLAIMER: This video is optimized for HD large display using patented and patent-pending “Nile Codec”, the first Egyptian Video Codec for more information, PLEASE check https://NileCodec.com RAndom SAmple Consensus Also available as a PodCast http://www.wired.com/gadgetlab/2010/07/camera-software-lets-you-see-into-the-past/
  • 2. © 2020 Wael Badawy Copyright © 2020 Wael Badawy. All rights reserved  This video is subject to copyright owned by Wael Badawy “WB”. Any reproduction or republication of all or part of this video is expressly prohibited unless WB has explicitly granted its prior written consent. All other rights reserved.  This video is intended for education and information only and is offered AS IS, without any warranty of the accuracy or the quality of the content. Any other use is strictly prohibited. The viewer is fully responsible to verify the accuracy of the contents received without any claims of costs or liability arising .  The names, trademarks service marked as logos of WB or the sponsors appearing in this video may not be used in any any product or service, without prior express written permission from WB and the video sponsors  Neither WB nor any party involved in creating, producing or delivering information and material via this video shall be liable for any direction, incidental, consequential, indirect of punitive damages arising out of access to, use or inability to use this content or any errors or omissions in the content thereof.  If you will continue to watch this video, you agree to the terms above and other terms that may be available on http://nu.edu.eg & https://caiwave.net 2
  • 3. © 2020 Wael Badawy
  • 4. © 2020 Wael Badawy Reading  Szeliski: Chapter 6.1
  • 5. © 2020 Wael Badawy Outliers outliers inliers
  • 6. © 2020 Wael Badawy Robustness  Let’s consider a simpler example… linear regression  How can we fix this? Problem: Fit a line to these datapoints Least squares fit
  • 7. © 2020 Wael Badawy We need a better cost function…  Suggestions?
  • 8. © 2020 Wael Badawy 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
  • 9. © 2020 Wael Badawy Counting inliers
  • 10. © 2020 Wael Badawy Counting inliers Inliers: 3
  • 11. © 2020 Wael Badawy Counting inliers Inliers: 20
  • 12. © 2020 Wael Badawy 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. © 2020 Wael Badawy Translations
  • 14. © 2020 Wael Badawy RAndom SAmple Consensus Select one match at random, count inliers
  • 15. © 2020 Wael Badawy RAndom SAmple Consensus Select another match at random, count inliers
  • 16. © 2020 Wael Badawy RAndom SAmple Consensus Output the translation with the highest number of inliers
  • 17. © 2020 Wael Badawy 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
  • 18. © 2020 Wael Badawy 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?
  • 19. © 2020 Wael Badawy RANSAC x translation y translation set threshold so that, e.g., 95% of the Gaussian lies inside that radius
  • 20. © 2020 Wael Badawy RANSAC  Back to linear regression  How do we generate a hypothesis? x y
  • 21. © 2020 Wael Badawy RANSAC  Back to linear regression  How do we generate a hypothesis? x y
  • 22. © 2020 Wael Badawy 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
  • 23. © 2020 Wael Badawy 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. Pollefeysp = 0.99
  • 24. © 2020 Wael Badawy How big is s?  For alignment, depends on the motion model  Here, each sample is a correspondence (pair of matching points)
  • 25. © 2020 Wael Badawy 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
  • 26. © 2020 Wael Badawy Final step: least squares fit Find average translation vector over all inliers
  • 27. © 2020 Wael Badawy 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…
  • 28. © 2020 Wael Badawy 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?
  • 29. © 2020 Wael Badawy Can we use homographies to create a 360 panorama?  In order to figure this out, we need to learn what a camera is
  • 30. © 2020 Wael Badawy 360 panorama
  • 31. © 2020 Wael Badawy Questions?