SlideShare ist ein Scribd-Unternehmen logo
1 von 47
Practical 3 - Digital Image
Processing
Aly Osama
‫اﻟﻣﺗﻧﺑﻲ‬ ‫اﻟطﯾب‬ ‫أﺑو‬
Stages of Computer Vision
Agenda
1. Template Matching
2. Hough Transform
3. Image Segmentation
4. Intro to feature descriptors
5. Harris Corner Detection
6. Practical Demo
7. Assignment
8. Project
Template Matching
Template Matching
Template Matching is a method for searching and finding the location of a
template image in a larger image.
OpenCV comes with a function cv2.matchTemplate() for this purpose.
Template matching
Here, as an example, we will search for Messi’s face in his photo.
We will try all the comparison methods
Template matching
Template matching
Template matching with multiple objects Example
Suppose you are searching for an object which has multiple occurrences, so,we
will use thresholding.
Hough Transform
Hough Line Transform
Hough Transform is a popular technique to detect any shape, if you can
represent that shape in mathematical form. It can detect the shape even if it is
broken or distorted a little bit.
Hough Line Transform
Any line can be represented in these two terms, (⍴, ). to detect a line we use the
OpenCV function, cv2.HoughLines(). It simply returns an array of (⍴, ).
Inputs
1. Input image should be a binary image, so apply threshold or use canny edge
detection before finding applying hough transform.
2. ⍴ and accuracies respectively.
3. threshold, which means minimum vote it should get for it to be considered as a line.
number of votes depend upon number of points on the line. So it
represents the minimum length of line that should be detected.
Hough Line Transform
Probabilistic Hough Transform
Probabilistic Hough Transform is an optimization of Hough Transform, It
doesn’t take all the points into consideration, instead take only a random
subset of points and that is sufficient for line detection. Just we have to
decrease the threshold.
OpenCV implementation is based on Robust Detection of Lines Using the
Progressive Probabilistic Hough Transform. The function used is
cv2.HoughLinesP(). It has two new arguments:
● minLineLength - Minimum length of line. Line segments shorter than
this are rejected.
● maxLineGap - Maximum allowed gap between line segments to treat
them as single line.
Probabilistic Hough Transform
Hough Circle Transform
So OpenCV uses Hough Gradient Method which uses the gradient information
of edges. The function we use here is cv2.HoughCircles().
Image Segmentation
Image Segmentation
Any grayscale image can be viewed as a topographic surface where high intensity
denotes peaks and hills while low intensity denotes valleys.
Watershed Algorithm
OpenCV implemented a marker-based watershed
algorithm where you specify which are all valley
points are to be merged and which are not. It is an
interactive image segmentation.
Consider the coins image below, the coins are
touching each other. Even if you threshold it, it will
be touching each other.
Watershed Algorithm
1. We start with finding an approximate estimate of the coins. For that, we can
use the Otsu’s binarization.
Result
Watershed Algorithm
2. Now we need to remove any small white noises in the image. For that we can
use morphological opening. To remove any small holes in the object, we can
use morphological closing.
3. We need to extract the area which we are sure they are coins. Erosion
removes the boundary pixels. So whatever remaining, we can be sure it is
coin.
4. Next we need to find the area which we are sure they are not coins. For that,
we dilate the result. Dilation increases object boundary to background.
Watershed Algorithm
Watershed Algorithm
The remaining regions are those which we don’t
have any idea, whether it is coins or background.
Watershed algorithm should find it. We call it
border. It can be obtained from subtracting sure_fg
area from sure_bg area.
Watershed Algorithm
Watershed Algorithm
Now our marker is ready. It is time for final step, apply watershed. Then marker image will be modified.
The boundary region will be marked with -1.
Intro to Feature Detection
Understanding Features
We are looking for specific patterns or specific
features which are unique, which can be easily
tracked, which can be easily compared.
A and B are flat surfaces, and they are spread in a lot
of area. It is difficult to find the exact location of
these patches.
C and D are much more simpler. They are edges of
the building. You can find an approximate location,
but exact location is still difficult. It is because,
along the edge, it is same everywhere. Normal to the
edge, it is different. So edge is a much better feature
compared to flat area, but not good enough.
Understanding Features
Finally, E and F are some corners of the building.
And they can be easily found out. Because at
corners, wherever you move this patch, it will look
different. So they can be considered as a good
feature.
Harris Corner Detection
Harris Corner Detector
Theory
It basically finds the difference in intensity for a displacement of (u,v) in all directions.
We have to maximize this function E(u,v) for corner detection. That means, we have to maximize the
second term. So, applying Taylor Expansion to above equation and using some mathematical steps
where
Harris Corner Detector
I͓ and are image derivatives in x and y directions respectively. (Can be easily found out using
cv2.Sobel()).
This equation will determine if a window can contain a corner or not.
Harris Corner Detector
Harris Corner Detector in OpenCV
OpenCV has the function cv2.cornerHarris() for this purpose. Its arguments are :
● img - Input image, it should be grayscale and float32 type.
● blockSize - It is the size of neighbourhood considered for corner detection
● ksize - Aperture parameter of Sobel derivative used.
● k - Harris detector free parameter in the equation.
dst = cv2.cornerHarris(gray,2,3,0.04)
Practical Demo
Object Tracker Demo
Object tracker using Template Matching
Code:
https://github.com/Karim-92/Mario-Tracking
Output:
https://www.youtube.com/watch?v=vjbInO0zvXo
Assignment
Assignment 3
● Description: Implement and Compare with OpenCV functions on the same
image
a. Hough Line and Circle Transform
b. Harris Corner Detector
c. JPEG Image Compression
● Notes:
a. Don't use any opencv function for processing just use it for loading and viewing results
■ Ask Ahmed Nasser Qassem
● Points: 5 points
● Team: 2 members
● Deliverables:
a. Jupyter (html) notebook to https://goo.gl/forms/lroYhjLHcID6lHB83
● Deadline: 31th March 2018
Project
Stanford <<<<<< ASU Image processing course :D
Project
● Description: Solve any complex problem from your real life using computer
vision.
○ Choose your own idea ( DON’T use a project from the internet- > Zero MARKS)
○ Capture or download images to work on them
○ Implement different algorithms just to proof your concept
○ Build the best algorithm on a mobile application (Java or C++ or Python).
● Team: 4 members
● Deliverables Milestones:
○ Milestone 1: Project proposal (Idea description, your plan , image samples, references)
■ Deadline: 27th March 2018
○ Milestone 2: Desktop Script
■ Deadline: 15th April 2018
○ Milestone 3: Mobile application
■ Deadline: 27th April 2018
● Points: 15 points
Have a question?!
If you have any question
● Facebook
○ You can ask me through Facebook but don’t wait for any response before 1 month.
“Simply don’t use facebook”
■ Because I hate facebook
■ I hate talking to people for (work-study) on facebook
■ I use facebook to escape from real world so I hate facebook
● Office Hours
○ Monday 3:30 to 5:00
○ Wednesday 11:30 to 12:30
● Email (Prefered)
○ aly.osama@eng.asu.edu.eg
Thank you

Weitere ähnliche Inhalte

Was ist angesagt?

Image feature extraction
Image feature extractionImage feature extraction
Image feature extraction
Rushin Shah
 

Was ist angesagt? (20)

Structure and Motion - 3D Reconstruction of Cameras and Structure
Structure and Motion - 3D Reconstruction of Cameras and StructureStructure and Motion - 3D Reconstruction of Cameras and Structure
Structure and Motion - 3D Reconstruction of Cameras and Structure
 
3D reconstruction
3D reconstruction3D reconstruction
3D reconstruction
 
Fuzzy Logic Based Edge Detection
Fuzzy Logic Based Edge DetectionFuzzy Logic Based Edge Detection
Fuzzy Logic Based Edge Detection
 
Study and Comparison of Various Image Edge Detection Techniques
Study and Comparison of Various Image Edge Detection TechniquesStudy and Comparison of Various Image Edge Detection Techniques
Study and Comparison of Various Image Edge Detection Techniques
 
Image feature extraction
Image feature extractionImage feature extraction
Image feature extraction
 
Neural Scene Representation & Rendering: Introduction to Novel View Synthesis
Neural Scene Representation & Rendering: Introduction to Novel View SynthesisNeural Scene Representation & Rendering: Introduction to Novel View Synthesis
Neural Scene Representation & Rendering: Introduction to Novel View Synthesis
 
Introduction to Computer Vision
Introduction to Computer VisionIntroduction to Computer Vision
Introduction to Computer Vision
 
Build Your Own 3D Scanner: 3D Scanning with Swept-Planes
Build Your Own 3D Scanner: 3D Scanning with Swept-PlanesBuild Your Own 3D Scanner: 3D Scanning with Swept-Planes
Build Your Own 3D Scanner: 3D Scanning with Swept-Planes
 
Camshaft
CamshaftCamshaft
Camshaft
 
Dense Image Matching - Challenges and Potentials (Keynote 3D-ARCH 2015)
Dense Image Matching - Challenges and Potentials (Keynote 3D-ARCH 2015) Dense Image Matching - Challenges and Potentials (Keynote 3D-ARCH 2015)
Dense Image Matching - Challenges and Potentials (Keynote 3D-ARCH 2015)
 
Build Your Own 3D Scanner: Conclusion
Build Your Own 3D Scanner: ConclusionBuild Your Own 3D Scanner: Conclusion
Build Your Own 3D Scanner: Conclusion
 
ALGORITHM AND TECHNIQUE ON VARIOUS EDGE DETECTION: A SURVEY
ALGORITHM AND TECHNIQUE ON VARIOUS EDGE DETECTION: A SURVEYALGORITHM AND TECHNIQUE ON VARIOUS EDGE DETECTION: A SURVEY
ALGORITHM AND TECHNIQUE ON VARIOUS EDGE DETECTION: A SURVEY
 
Build Your Own 3D Scanner: The Mathematics of 3D Triangulation
Build Your Own 3D Scanner: The Mathematics of 3D TriangulationBuild Your Own 3D Scanner: The Mathematics of 3D Triangulation
Build Your Own 3D Scanner: The Mathematics of 3D Triangulation
 
[3D勉強会@関東] Deep Reinforcement Learning of Volume-guided Progressive View Inpa...
[3D勉強会@関東] Deep Reinforcement Learning of Volume-guided Progressive View Inpa...[3D勉強会@関東] Deep Reinforcement Learning of Volume-guided Progressive View Inpa...
[3D勉強会@関東] Deep Reinforcement Learning of Volume-guided Progressive View Inpa...
 
Implementing Camshift on a Mobile Robot for Person Tracking and Pursuit_ICDM
Implementing Camshift on a Mobile Robot for Person Tracking and Pursuit_ICDMImplementing Camshift on a Mobile Robot for Person Tracking and Pursuit_ICDM
Implementing Camshift on a Mobile Robot for Person Tracking and Pursuit_ICDM
 
Camshift
CamshiftCamshift
Camshift
 
02_atiqa ijaz khan_05_2014
02_atiqa ijaz khan_05_201402_atiqa ijaz khan_05_2014
02_atiqa ijaz khan_05_2014
 
Chapter 9 morphological image processing
Chapter 9 morphological image processingChapter 9 morphological image processing
Chapter 9 morphological image processing
 
Hit and-miss transform
Hit and-miss transformHit and-miss transform
Hit and-miss transform
 
Data hiding using image interpolation
Data hiding using image interpolationData hiding using image interpolation
Data hiding using image interpolation
 

Ähnlich wie Practical Digital Image Processing 3

Machine learning for high-speed corner detection
Machine learning for high-speed corner detectionMachine learning for high-speed corner detection
Machine learning for high-speed corner detection
butest
 

Ähnlich wie Practical Digital Image Processing 3 (20)

Hardware Unit for Edge Detection with Comparative Analysis of Different Edge ...
Hardware Unit for Edge Detection with Comparative Analysis of Different Edge ...Hardware Unit for Edge Detection with Comparative Analysis of Different Edge ...
Hardware Unit for Edge Detection with Comparative Analysis of Different Edge ...
 
06 image features
06 image features06 image features
06 image features
 
LANE DETECTION USING IMAGE PROCESSING IN PYTHON
LANE DETECTION USING IMAGE PROCESSING IN PYTHONLANE DETECTION USING IMAGE PROCESSING IN PYTHON
LANE DETECTION USING IMAGE PROCESSING IN PYTHON
 
IRJET- Image Feature Extraction using Hough Transformation Principle
IRJET- Image Feature Extraction using Hough Transformation PrincipleIRJET- Image Feature Extraction using Hough Transformation Principle
IRJET- Image Feature Extraction using Hough Transformation Principle
 
Module-5-1_230523_171754 (1).pdf
Module-5-1_230523_171754 (1).pdfModule-5-1_230523_171754 (1).pdf
Module-5-1_230523_171754 (1).pdf
 
A Case Study : Circle Detection Using Circular Hough Transform
A Case Study : Circle Detection Using Circular Hough TransformA Case Study : Circle Detection Using Circular Hough Transform
A Case Study : Circle Detection Using Circular Hough Transform
 
E017443136
E017443136E017443136
E017443136
 
Augmented reality session 4
Augmented reality session 4Augmented reality session 4
Augmented reality session 4
 
Chapter10 image segmentation
Chapter10 image segmentationChapter10 image segmentation
Chapter10 image segmentation
 
Android based application for graph analysis final report
Android based application for graph analysis final reportAndroid based application for graph analysis final report
Android based application for graph analysis final report
 
Estrazione automatica delle linee in un'immagine digitale
Estrazione automatica delle linee in un'immagine digitaleEstrazione automatica delle linee in un'immagine digitale
Estrazione automatica delle linee in un'immagine digitale
 
A PROJECT REPORT ON REMOVAL OF UNNECESSARY OBJECTS FROM PHOTOS USING MASKING
A PROJECT REPORT ON REMOVAL OF UNNECESSARY OBJECTS FROM PHOTOS USING MASKINGA PROJECT REPORT ON REMOVAL OF UNNECESSARY OBJECTS FROM PHOTOS USING MASKING
A PROJECT REPORT ON REMOVAL OF UNNECESSARY OBJECTS FROM PHOTOS USING MASKING
 
CAD/CAM/CAE - Notes
CAD/CAM/CAE - NotesCAD/CAM/CAE - Notes
CAD/CAM/CAE - Notes
 
Object tracking with SURF: ARM-Based platform Implementation
Object tracking with SURF: ARM-Based platform ImplementationObject tracking with SURF: ARM-Based platform Implementation
Object tracking with SURF: ARM-Based platform Implementation
 
E41033336
E41033336E41033336
E41033336
 
Machine learning for high-speed corner detection
Machine learning for high-speed corner detectionMachine learning for high-speed corner detection
Machine learning for high-speed corner detection
 
Road signs detection using voila jone's algorithm with the help of opencv
Road signs detection using voila jone's algorithm with the help of opencvRoad signs detection using voila jone's algorithm with the help of opencv
Road signs detection using voila jone's algorithm with the help of opencv
 
I010634450
I010634450I010634450
I010634450
 
Performance of Efficient Closed-Form Solution to Comprehensive Frontier Exposure
Performance of Efficient Closed-Form Solution to Comprehensive Frontier ExposurePerformance of Efficient Closed-Form Solution to Comprehensive Frontier Exposure
Performance of Efficient Closed-Form Solution to Comprehensive Frontier Exposure
 
Circle & curve clipping algorithm
Circle & curve clipping algorithmCircle & curve clipping algorithm
Circle & curve clipping algorithm
 

Mehr von Aly Abdelkareem

Mehr von Aly Abdelkareem (13)

An Inductive inference Machine
An Inductive inference MachineAn Inductive inference Machine
An Inductive inference Machine
 
Digital Image Processing - Frequency Filters
Digital Image Processing - Frequency FiltersDigital Image Processing - Frequency Filters
Digital Image Processing - Frequency Filters
 
Deep learning: Overfitting , underfitting, and regularization
Deep learning: Overfitting , underfitting, and regularizationDeep learning: Overfitting , underfitting, and regularization
Deep learning: Overfitting , underfitting, and regularization
 
Pattern recognition 4 - MLE
Pattern recognition 4 - MLEPattern recognition 4 - MLE
Pattern recognition 4 - MLE
 
Practical Digital Image Processing 1
Practical Digital Image Processing 1Practical Digital Image Processing 1
Practical Digital Image Processing 1
 
Machine Learning for Everyone
Machine Learning for EveryoneMachine Learning for Everyone
Machine Learning for Everyone
 
How to use deep learning on biological data
How to use deep learning on biological dataHow to use deep learning on biological data
How to use deep learning on biological data
 
Deep Learning using Keras
Deep Learning using KerasDeep Learning using Keras
Deep Learning using Keras
 
Object extraction from satellite imagery using deep learning
Object extraction from satellite imagery using deep learningObject extraction from satellite imagery using deep learning
Object extraction from satellite imagery using deep learning
 
Pattern recognition Tutorial 2
Pattern recognition Tutorial 2Pattern recognition Tutorial 2
Pattern recognition Tutorial 2
 
Android Udacity Study group 1
Android Udacity Study group 1Android Udacity Study group 1
Android Udacity Study group 1
 
Java for android developers
Java for android developersJava for android developers
Java for android developers
 
Introduction to Android Development
Introduction to Android DevelopmentIntroduction to Android Development
Introduction to Android Development
 

Kürzlich hochgeladen

Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
Tonystark477637
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Christo Ananth
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
ankushspencer015
 

Kürzlich hochgeladen (20)

Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
NFPA 5000 2024 standard .
NFPA 5000 2024 standard                                  .NFPA 5000 2024 standard                                  .
NFPA 5000 2024 standard .
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICSUNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank  Design by Working Stress - IS Method.pdfIntze Overhead Water Tank  Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and Properties
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 

Practical Digital Image Processing 3

  • 1. Practical 3 - Digital Image Processing Aly Osama
  • 4. Agenda 1. Template Matching 2. Hough Transform 3. Image Segmentation 4. Intro to feature descriptors 5. Harris Corner Detection 6. Practical Demo 7. Assignment 8. Project
  • 6. Template Matching Template Matching is a method for searching and finding the location of a template image in a larger image. OpenCV comes with a function cv2.matchTemplate() for this purpose.
  • 7. Template matching Here, as an example, we will search for Messi’s face in his photo. We will try all the comparison methods
  • 10. Template matching with multiple objects Example Suppose you are searching for an object which has multiple occurrences, so,we will use thresholding.
  • 12. Hough Line Transform Hough Transform is a popular technique to detect any shape, if you can represent that shape in mathematical form. It can detect the shape even if it is broken or distorted a little bit.
  • 13. Hough Line Transform Any line can be represented in these two terms, (⍴, ). to detect a line we use the OpenCV function, cv2.HoughLines(). It simply returns an array of (⍴, ). Inputs 1. Input image should be a binary image, so apply threshold or use canny edge detection before finding applying hough transform. 2. ⍴ and accuracies respectively. 3. threshold, which means minimum vote it should get for it to be considered as a line.
  • 14. number of votes depend upon number of points on the line. So it represents the minimum length of line that should be detected.
  • 16. Probabilistic Hough Transform Probabilistic Hough Transform is an optimization of Hough Transform, It doesn’t take all the points into consideration, instead take only a random subset of points and that is sufficient for line detection. Just we have to decrease the threshold. OpenCV implementation is based on Robust Detection of Lines Using the Progressive Probabilistic Hough Transform. The function used is cv2.HoughLinesP(). It has two new arguments: ● minLineLength - Minimum length of line. Line segments shorter than this are rejected. ● maxLineGap - Maximum allowed gap between line segments to treat them as single line.
  • 18. Hough Circle Transform So OpenCV uses Hough Gradient Method which uses the gradient information of edges. The function we use here is cv2.HoughCircles().
  • 20. Image Segmentation Any grayscale image can be viewed as a topographic surface where high intensity denotes peaks and hills while low intensity denotes valleys.
  • 21. Watershed Algorithm OpenCV implemented a marker-based watershed algorithm where you specify which are all valley points are to be merged and which are not. It is an interactive image segmentation. Consider the coins image below, the coins are touching each other. Even if you threshold it, it will be touching each other.
  • 22. Watershed Algorithm 1. We start with finding an approximate estimate of the coins. For that, we can use the Otsu’s binarization. Result
  • 23. Watershed Algorithm 2. Now we need to remove any small white noises in the image. For that we can use morphological opening. To remove any small holes in the object, we can use morphological closing. 3. We need to extract the area which we are sure they are coins. Erosion removes the boundary pixels. So whatever remaining, we can be sure it is coin. 4. Next we need to find the area which we are sure they are not coins. For that, we dilate the result. Dilation increases object boundary to background.
  • 25. Watershed Algorithm The remaining regions are those which we don’t have any idea, whether it is coins or background. Watershed algorithm should find it. We call it border. It can be obtained from subtracting sure_fg area from sure_bg area.
  • 27. Watershed Algorithm Now our marker is ready. It is time for final step, apply watershed. Then marker image will be modified. The boundary region will be marked with -1.
  • 28. Intro to Feature Detection
  • 29.
  • 30. Understanding Features We are looking for specific patterns or specific features which are unique, which can be easily tracked, which can be easily compared. A and B are flat surfaces, and they are spread in a lot of area. It is difficult to find the exact location of these patches. C and D are much more simpler. They are edges of the building. You can find an approximate location, but exact location is still difficult. It is because, along the edge, it is same everywhere. Normal to the edge, it is different. So edge is a much better feature compared to flat area, but not good enough.
  • 31. Understanding Features Finally, E and F are some corners of the building. And they can be easily found out. Because at corners, wherever you move this patch, it will look different. So they can be considered as a good feature.
  • 33. Harris Corner Detector Theory It basically finds the difference in intensity for a displacement of (u,v) in all directions. We have to maximize this function E(u,v) for corner detection. That means, we have to maximize the second term. So, applying Taylor Expansion to above equation and using some mathematical steps where
  • 34. Harris Corner Detector I͓ and are image derivatives in x and y directions respectively. (Can be easily found out using cv2.Sobel()). This equation will determine if a window can contain a corner or not.
  • 36. Harris Corner Detector in OpenCV OpenCV has the function cv2.cornerHarris() for this purpose. Its arguments are : ● img - Input image, it should be grayscale and float32 type. ● blockSize - It is the size of neighbourhood considered for corner detection ● ksize - Aperture parameter of Sobel derivative used. ● k - Harris detector free parameter in the equation. dst = cv2.cornerHarris(gray,2,3,0.04)
  • 37.
  • 39. Object Tracker Demo Object tracker using Template Matching Code: https://github.com/Karim-92/Mario-Tracking Output: https://www.youtube.com/watch?v=vjbInO0zvXo
  • 41. Assignment 3 ● Description: Implement and Compare with OpenCV functions on the same image a. Hough Line and Circle Transform b. Harris Corner Detector c. JPEG Image Compression ● Notes: a. Don't use any opencv function for processing just use it for loading and viewing results ■ Ask Ahmed Nasser Qassem ● Points: 5 points ● Team: 2 members ● Deliverables: a. Jupyter (html) notebook to https://goo.gl/forms/lroYhjLHcID6lHB83 ● Deadline: 31th March 2018
  • 43. Stanford <<<<<< ASU Image processing course :D
  • 44. Project ● Description: Solve any complex problem from your real life using computer vision. ○ Choose your own idea ( DON’T use a project from the internet- > Zero MARKS) ○ Capture or download images to work on them ○ Implement different algorithms just to proof your concept ○ Build the best algorithm on a mobile application (Java or C++ or Python). ● Team: 4 members ● Deliverables Milestones: ○ Milestone 1: Project proposal (Idea description, your plan , image samples, references) ■ Deadline: 27th March 2018 ○ Milestone 2: Desktop Script ■ Deadline: 15th April 2018 ○ Milestone 3: Mobile application ■ Deadline: 27th April 2018 ● Points: 15 points
  • 46. If you have any question ● Facebook ○ You can ask me through Facebook but don’t wait for any response before 1 month. “Simply don’t use facebook” ■ Because I hate facebook ■ I hate talking to people for (work-study) on facebook ■ I use facebook to escape from real world so I hate facebook ● Office Hours ○ Monday 3:30 to 5:00 ○ Wednesday 11:30 to 12:30 ● Email (Prefered) ○ aly.osama@eng.asu.edu.eg