SlideShare una empresa de Scribd logo
1 de 53
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
Contours
A contour is an assembled collection of edges that (hopefully) represent one object in
the image.
• Can be used to automatically segment the different objects present in an image.
Preprocessing for cv2.findContours
Can use canny edges
• Images created by cvCanny
Can use thresholded image where edges are boundaries between white and black
• Images created by cvThreshold or cvAdaptiveThreshold
Call cv2.findContours on result of Canny or thresholding.
Contour Hierarchy
Parent – Child Hierarchy
0
1
2
3
4
0
1
2
3
4
Contour Hierarchy
cvContour can represent data as a contour tree.
0 and 2 are the contours represented at the root, or parent,
nodes.
Other contours are represented as children of 0 or 2.
0
1
2
3
4
cvFindContours
Input needs to be 8-bit binary image.
Make a copy of the image before using cvFindContours
• The original image will be written over by
cvFindContours
OpenCV represents the contour hierarchy as an array:
[next, previous, first_child, parent]
0
1
2
3
4
Method Variable: Arguments to Find Contours
Method clarifies how the contour is being computed.
CV_CHAIN_CODE
 Output = sequence of vertices (Freeman chain code)
CV_CHAIN_APPROX_NONE
 All chain code points = contour points
CV_CHAIN_APPROX_SIMPLE
 Endpoints of horizontal, vertical, diagonal segments
CV_CHAIN_APPROX_TC89_L1
 Teh_Chin chain algorithm
CV_LINK_RUNS
 Links horizontal segments of 1s
 Limited to CV_RETR_LIST
Mode Variable
Mode clarifies what contours should be found and desired format for return
value.
Finds contours and uses horizontal and vertical links to link the found
contours.
Mode options:
CV_RETR_EXTERNAL
CV_RETR_LIST
CV_ RETR_CCOMP
CV_RETR_TREE
CV_RETR_LIST
All contours are put into a list
This list does not have parent – child
relationships
Uses horizontal links
All contours are on same level (no actual
hierarchy)
0
1
2
3
4
CV_RETR_EXTERNAL
Extreme outer contours
0
1
CV_RETR_CCOMP
All contours are used to
generate a 2-level hierarchy
• Top-level hierarchy = external
• Bottom-level = internal
• Horizontal and vertical linkers
0 1
2 3
4
CV_RETR_TREE
All contours are used to generate a
full hierarchy
0
1
2
3
4
Drawing Contours
Lets look at a new image and draw contours with cv2.drawContours
Original Edges Edges used to compute
contours
Hull Borders
Compute a convex hull
cv2.convexHull()
Hull Borders
Compute convexity defects
cv2.convexityDefects
Checks contours to see if it is convex.
Length and Area
Length
• cv2.ContourPerimeter
Returns length of a contour
You can summarize length and area as a bounding structure
• Boxes
• Circles
• Ellipses
Bounding Boxes
cv2.BoundingRect()
• Returns rectangle that bounds the contour
• Red box in image
cv2.MinAreaRec2()
• Returns smallest rectangular bound
• Green box in image
Note green box is rotated for best fit
Circles and Ellipses
cv2.MinEnclosingCirlce()
• Similar to cv2.BoundingRect() in that it bounds the contour, but not a best fit
• Needs radius as input
• Red circle in image
cv2.FitEllipse2()
• Allows us to get a best fit bound
• Green circle image
Geometric Toolkits/Checks
cv2.maxRect()
• Two input rectangles are used to compute a new rectangle
cv2.BoxPoints()
• Computers corner points of cvBox2D structure
cv2.PointPolygonTest()
• Test: is point in polygon?
Contour Statistics
𝐴𝑠𝑝𝑒𝑐𝑡 𝑅𝑎𝑡𝑖𝑜𝑛 =
𝑊𝑖𝑑𝑡ℎ
𝐻𝑒𝑖𝑔ℎ𝑡
𝐸𝑥𝑡𝑒𝑛𝑡 =
𝑂𝑏𝑗𝑒𝑐𝑡 𝐴𝑟𝑒𝑎
𝐵𝑜𝑢𝑛𝑑𝑖𝑛𝑔 𝑅𝑒𝑐𝑡𝑎𝑛𝑔𝑙𝑒 𝐴𝑟𝑒𝑎
𝑆𝑜𝑙𝑖𝑑𝑖𝑡𝑦 =
𝐶𝑜𝑛𝑡𝑜𝑢𝑟 𝐴𝑟𝑒𝑎
𝐶𝑜𝑛𝑣𝑒𝑥 𝐻𝑢𝑙𝑙 𝐴𝑟𝑒𝑎
𝐸𝑞𝑢𝑖𝑣𝑎𝑙𝑒𝑛𝑡 𝐷𝑖𝑎𝑚𝑒𝑡𝑒𝑟 =
4 𝑥 𝐶𝑜𝑛𝑡𝑜𝑢𝑟 𝐴𝑟𝑒𝑎
𝜋
𝑂𝑟𝑖𝑒𝑛𝑡𝑎𝑡𝑖𝑜𝑛 𝐴𝑛𝑔𝑙𝑒 = 𝑐𝑣2. 𝑓𝑖𝑡𝐸𝑙𝑙𝑖𝑝𝑠𝑒(𝑐𝑛𝑡)
𝑥, 𝑦, 𝑤, ℎ = 𝑐𝑣2. 𝑏𝑜𝑢𝑛𝑑𝑖𝑛𝑔𝑅𝑒𝑐𝑡(𝑐𝑜𝑛𝑡)
𝑎𝑟𝑒𝑎 = 𝑐𝑣2. 𝑐𝑜𝑛𝑡𝑜𝑢𝑟𝐴𝑟𝑒𝑎(𝑐𝑜𝑛𝑡)
ℎ𝑢𝑙𝑙 = 𝑐𝑣2. 𝑐𝑜𝑛𝑣𝑒𝑥𝐻𝑢𝑙𝑙(𝑐𝑜𝑛𝑡)
ℎ𝑢𝑙𝑙_𝑎𝑟𝑒𝑎 = 𝑐𝑣2. 𝑐𝑜𝑛𝑡𝑜𝑢𝑟𝐴𝑟𝑒𝑎(ℎ𝑢𝑙𝑙)
Finding Extreme Points: Min/Max
Min/Max is computed with NumPy.
Extreme points of the cross are min/max left/right and up/down.
Foreground/Background Separation
Separate foreground from background
Send foreground on for further analysis
• Cars in security camera
• Skin within an image (reduces complexity of finding faces)
Superpixels
• Groups of pixels in same object/type of object
Methods: Image Pyramids
Collection of images where each subsequent image is a downsampling of
the previous.
Gaussian pyramid
 Used to downsample
 Removes even rows and columns
 Will give you higher resolution
Laplacian pyramid
 Used to upsample
 Works with lower-resolution images and allows for faster computations
Gaussian Pyramid
Use cvPyrDown() with a 5x5 Guassian kernel
• Start with G0 (original image)
• Convolve G0 with Gaussian kernel
• Gi is ¼ size of G0 because we removed even-numbered rows and
columns from G0
• Repeat for all desired Gi+1
Laplacian Kernel
Use cvPyrUp()
Notice the relationship between Gausian and Laplacian
In OpenCV we see this as:
Lapi = Gausi – PyrUp(Gausi+1 )
Remember, we saw this in Week 3!
Methods to Segment an Image
cvPyrSegmentation ()
• Generates an image pyramid
• Associates pyramid layers to parent-child relationships
• Map pixels between Gi+1 and Gi
• Perform segmentation on lower-resolution images
• Note: Start image must be divisible by 2 for each layer of the pyramid
Mean Shift Clustering Over Color
pyrMeanShiftFiltering()
Peak of color-spatial distribution over space
Data dimensions are:
Spatial (x, y)
Color (blue, green, red)
Parameters are spatialRadius, colorRadius, max_level, and CvTermCriteria.
Watershed
Used to separate objects when you do not have a separate background image.
Input is a grayscale image or a smoothed color image.
Can cause oversegmentation or undersegmentation
• If you make too many basins or too few
Lines converted to peaks; uniform regions to catchment basins.
Watershed Method
Take the gradient of intensity image.
Marker points, or known areas of region of interest, are defined by user.
Basins get connected to marker points to create segments.
Watershed: Example
Step 1: Threshold a color image
Watershed: Example
Step 2: Remove noise with cv2.morphologyEx
Watershed: Example
Step 3: Sure background area with cv2.dilate()
Watershed: Example
Step 4: Find sure foreground area with cv2.distanceTransform() and cv2.threshold()
Watershed: Example
Step 5: Find unknown region with cv2.subtract()
Grabcut: Graph Cutting Techniques
Pixel-based energy function
Basic binary segmentation algorithm to identify object
Iteratively recalculates the region statistics (Gaussians) to perform segmentation
GrabCut Procedure
(1) Assign background and unknown
Unknown becomes potential foreground
(2) Create five probabilistic clusters (each) of foreground and background
(3) Assign every background pixel to a cluster of background
Do the same for foreground
(4) Compute cluster statistics for all clusters
GrabCut Procedure (continued)
(5) Create a graph where:
Pixels are linked to their neighbors and to two special nodes
 Nodes represent foreground and background
The weights of the links are related to neighbor similarity and class probability
GrabCut Procedure (continued)
(6) Apply a classic computer science graph theory algorithm min-cut to the
graph
The net result cuts the connections from each pixel to one of the two
special nodes.
In turn, this gives us a new assignment for foreground/background to the
pixels.
(7) Until convergence, we loop back to Step 4 and repeat
Classifications remain similar enough from one round to the next.
Contour Moments: Matching Contours
Compare statistical moments of contours:
In statistics, first moment is the mean, second moment is the variance, and so
on.
Moments are used to compare two contours (outlines) for similarity.
Another technique: Compute rough contour characteristic computed by
summation of all pixels over contour boundary:
p: x-order q: y-order
Normalized moments are better for comparing similar shapes of different sizes.
𝑚 𝑝,𝑞 =
𝑖=1
𝑛
𝐼 𝑥, 𝑦 𝑥 𝑝 𝑦 𝑞
Statistical Moments
In classical statistics, we use mean, variance, skew, and kurtosis.
cvMoments()
cvGetCentralMoment()
invariant with respect to translation
cvGetNormalizedMoment()
invariant with respect to scale
cvGetHuMoments()
invariant with respect to rotation
Normalized Moments
Central moments normalized with respect to a function intensity.
First need to calculate central moment:
Then you can calculate normalized moments:
𝜂 𝑝,𝑞 =
𝜇 𝑝,𝑞
𝑚00 𝑝 + 𝑞 /2 + 1
𝜇𝑝, 𝑞 =
𝑥,𝑦
𝐼 𝑥, 𝑦 𝑥 − 𝑥𝑎𝑣𝑔 𝑝 𝑦 − 𝑦𝑎𝑣𝑔 𝑞
Hu Invariant Moments
Linear combinations of centralized moments.
Use central moments to get invariant functions
• Invariant to scale, rotation, and reflection
cvGetHuMoments()
ℎ1 = 𝜂20 + 𝜂02
ℎ4 = (𝜂30+ 𝜂12)2 + (𝜂21 + 𝜂03)2
Template Matching Overview
Use cvMatchTemplate() to find one image within another.
Uses the actual image of matching object instead of a histogram
• This is called an image patch
Input image
• 8-bit, floating point plane, or color image
Output
• Single-channel byte or floating point image
Template Matching Methods
Squared difference
CV_TM_SQDIFF_NORMED
Correlation
CV_TM_CCORR_NORMED
Correlation coefficient
CV_TM_CCOEFF_NORMED
𝑅 𝑠𝑞𝑑𝑖𝑓𝑓 𝑥, 𝑦 =
𝑅 𝑠𝑞𝑑𝑖𝑓𝑓(𝑥, 𝑦)
𝑍(𝑥, 𝑦)
𝑅 𝑐𝑐𝑜𝑟𝑟 𝑥, 𝑦 =
𝑅 𝑐𝑐𝑜𝑟𝑟(𝑥, 𝑦)
𝑍(𝑥, 𝑦)
𝑅 𝑐𝑐𝑜𝑒𝑓𝑓 𝑥, 𝑦 =
𝑅 𝑐𝑐𝑜𝑒𝑓𝑓(𝑥, 𝑦)
𝑍(𝑥, 𝑦)
Histogram Backprojection
Uses a histogram model to match pixels (or patches of pixels) to approach object
recognition.
Histogram Backprojection
Better thought of as segmentation to foreground ROIs used for further
analysis.
If you have a histogram of the ROI, we can use that to find the object in
another image.
Use histogram from one image to match to histogram profile from another
image
Normalize to pixel number
Find matching object, or ROI
cvCalcBackProjectPatch()
Histogram Backprojection
Given a color, we want to know the probability of foreground/background.
Approximate probability that a particular color belongs to a particular object
You can also make a ratio histogram where you de-emphasize colors not in the ROI.
𝑝 𝑜𝑏𝑗𝑒𝑐𝑡 𝑐𝑜𝑙𝑜𝑟 =
𝑝 𝑐𝑜𝑙𝑜𝑟 𝑜𝑏𝑗𝑒𝑐𝑡 ∗ 𝑝(𝑜𝑏𝑗𝑒𝑐𝑡)
𝑝(𝑐𝑜𝑙𝑜𝑟)
~ 𝑝 𝑐𝑜𝑙𝑜𝑟 𝑜𝑏𝑗𝑒𝑐𝑡
Backprojection Method
1. Calculate ROI histogram
2. Normalize histogram
3. Apply cv2.calcBackProject
4. Convolve with circular disc
5. Duplicate threshold

Más contenido relacionado

La actualidad más candente

Feature detection and matching
Feature detection and matchingFeature detection and matching
Feature detection and matchingKuppusamy P
 
Understanding Convolutional Neural Networks
Understanding Convolutional Neural NetworksUnderstanding Convolutional Neural Networks
Understanding Convolutional Neural NetworksJeremy Nixon
 
Feature detection - Image Processing
Feature detection - Image ProcessingFeature detection - Image Processing
Feature detection - Image ProcessingRitesh Kanjee
 
Content Based Image Retrieval
Content Based Image Retrieval Content Based Image Retrieval
Content Based Image Retrieval Swati Chauhan
 
Image Representation & Descriptors
Image Representation & DescriptorsImage Representation & Descriptors
Image Representation & DescriptorsPundrikPatel
 
Neural Networks: Multilayer Perceptron
Neural Networks: Multilayer PerceptronNeural Networks: Multilayer Perceptron
Neural Networks: Multilayer PerceptronMostafa G. M. Mostafa
 
Image segmentation
Image segmentationImage segmentation
Image segmentationDeepak Kumar
 
Application of machine learning in industrial applications
Application of machine learning in industrial applicationsApplication of machine learning in industrial applications
Application of machine learning in industrial applicationsAnish Das
 
multiple object tracking using particle filter
multiple object tracking using particle filtermultiple object tracking using particle filter
multiple object tracking using particle filterSRIKANTH DANDE
 
Semantic Segmentation - Fully Convolutional Networks for Semantic Segmentation
Semantic Segmentation - Fully Convolutional Networks for Semantic SegmentationSemantic Segmentation - Fully Convolutional Networks for Semantic Segmentation
Semantic Segmentation - Fully Convolutional Networks for Semantic Segmentation岳華 杜
 
OCR Presentation (Optical Character Recognition)
OCR Presentation (Optical Character Recognition)OCR Presentation (Optical Character Recognition)
OCR Presentation (Optical Character Recognition)Neeraj Neupane
 
Deep neural networks
Deep neural networksDeep neural networks
Deep neural networksSi Haem
 
AlexNet, VGG, GoogleNet, Resnet
AlexNet, VGG, GoogleNet, ResnetAlexNet, VGG, GoogleNet, Resnet
AlexNet, VGG, GoogleNet, ResnetJungwon Kim
 
Face Recognition Methods based on Convolutional Neural Networks
Face Recognition Methods based on Convolutional Neural NetworksFace Recognition Methods based on Convolutional Neural Networks
Face Recognition Methods based on Convolutional Neural NetworksElaheh Rashedi
 
What is computer vision?
What is computer vision?What is computer vision?
What is computer vision?Qentinel
 
Introduction to object detection
Introduction to object detectionIntroduction to object detection
Introduction to object detectionBrodmann17
 

La actualidad más candente (20)

Feature detection and matching
Feature detection and matchingFeature detection and matching
Feature detection and matching
 
Understanding Convolutional Neural Networks
Understanding Convolutional Neural NetworksUnderstanding Convolutional Neural Networks
Understanding Convolutional Neural Networks
 
Edge detection
Edge detectionEdge detection
Edge detection
 
Feature detection - Image Processing
Feature detection - Image ProcessingFeature detection - Image Processing
Feature detection - Image Processing
 
Content Based Image Retrieval
Content Based Image Retrieval Content Based Image Retrieval
Content Based Image Retrieval
 
Image Representation & Descriptors
Image Representation & DescriptorsImage Representation & Descriptors
Image Representation & Descriptors
 
Neural Networks: Multilayer Perceptron
Neural Networks: Multilayer PerceptronNeural Networks: Multilayer Perceptron
Neural Networks: Multilayer Perceptron
 
Computer vision
Computer visionComputer vision
Computer vision
 
Image segmentation
Image segmentationImage segmentation
Image segmentation
 
Application of machine learning in industrial applications
Application of machine learning in industrial applicationsApplication of machine learning in industrial applications
Application of machine learning in industrial applications
 
multiple object tracking using particle filter
multiple object tracking using particle filtermultiple object tracking using particle filter
multiple object tracking using particle filter
 
Semantic Segmentation - Fully Convolutional Networks for Semantic Segmentation
Semantic Segmentation - Fully Convolutional Networks for Semantic SegmentationSemantic Segmentation - Fully Convolutional Networks for Semantic Segmentation
Semantic Segmentation - Fully Convolutional Networks for Semantic Segmentation
 
OCR Presentation (Optical Character Recognition)
OCR Presentation (Optical Character Recognition)OCR Presentation (Optical Character Recognition)
OCR Presentation (Optical Character Recognition)
 
Deep neural networks
Deep neural networksDeep neural networks
Deep neural networks
 
AlexNet, VGG, GoogleNet, Resnet
AlexNet, VGG, GoogleNet, ResnetAlexNet, VGG, GoogleNet, Resnet
AlexNet, VGG, GoogleNet, Resnet
 
Face Recognition Methods based on Convolutional Neural Networks
Face Recognition Methods based on Convolutional Neural NetworksFace Recognition Methods based on Convolutional Neural Networks
Face Recognition Methods based on Convolutional Neural Networks
 
What is computer vision?
What is computer vision?What is computer vision?
What is computer vision?
 
Object detection
Object detectionObject detection
Object detection
 
image compression ppt
image compression pptimage compression ppt
image compression ppt
 
Introduction to object detection
Introduction to object detectionIntroduction to object detection
Introduction to object detection
 

Similar a 05 contours seg_matching

Efficient anomaly detection via matrix sketching
Efficient anomaly detection via matrix sketchingEfficient anomaly detection via matrix sketching
Efficient anomaly detection via matrix sketchingHsing-chuan Hsieh
 
3D Reconstruction from Multiple uncalibrated 2D Images of an Object
3D Reconstruction from Multiple uncalibrated 2D Images of an Object3D Reconstruction from Multiple uncalibrated 2D Images of an Object
3D Reconstruction from Multiple uncalibrated 2D Images of an ObjectAnkur Tyagi
 
EE660_Report_YaxinLiu_8448347171
EE660_Report_YaxinLiu_8448347171EE660_Report_YaxinLiu_8448347171
EE660_Report_YaxinLiu_8448347171Yaxin Liu
 
Templateless Marked Element Recognition Using Computer Vision
Templateless Marked Element Recognition Using Computer VisionTemplateless Marked Element Recognition Using Computer Vision
Templateless Marked Element Recognition Using Computer Visionshivam chaurasia
 
CS345-Algorithms-II-Lecture-1-CS345-2016.pdf
CS345-Algorithms-II-Lecture-1-CS345-2016.pdfCS345-Algorithms-II-Lecture-1-CS345-2016.pdf
CS345-Algorithms-II-Lecture-1-CS345-2016.pdfOpenWorld6
 
various methods for image segmentation
various methods for image segmentationvarious methods for image segmentation
various methods for image segmentationRaveesh Methi
 
svm-proyekt.pptx
svm-proyekt.pptxsvm-proyekt.pptx
svm-proyekt.pptxElinEliyev
 
06 image features
06 image features06 image features
06 image featuresankit_ppt
 
Parallel Computing 2007: Bring your own parallel application
Parallel Computing 2007: Bring your own parallel applicationParallel Computing 2007: Bring your own parallel application
Parallel Computing 2007: Bring your own parallel applicationGeoffrey Fox
 
02 image processing
02 image processing02 image processing
02 image processingankit_ppt
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manualAnkit Kumar
 
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 StructureGiovanni Murru
 
Two marks with answers ME6501 CAD
Two marks with answers ME6501 CADTwo marks with answers ME6501 CAD
Two marks with answers ME6501 CADPriscilla CPG
 
426 Lecture5: AR Registration
426 Lecture5: AR Registration426 Lecture5: AR Registration
426 Lecture5: AR RegistrationMark Billinghurst
 
Kulum alin-11 jan2014
Kulum alin-11 jan2014Kulum alin-11 jan2014
Kulum alin-11 jan2014rolly purnomo
 
Variational Autoencoders For Image Generation
Variational Autoencoders For Image GenerationVariational Autoencoders For Image Generation
Variational Autoencoders For Image GenerationJason Anderson
 

Similar a 05 contours seg_matching (20)

Efficient anomaly detection via matrix sketching
Efficient anomaly detection via matrix sketchingEfficient anomaly detection via matrix sketching
Efficient anomaly detection via matrix sketching
 
Module-3_SVM_Kernel_KNN.pptx
Module-3_SVM_Kernel_KNN.pptxModule-3_SVM_Kernel_KNN.pptx
Module-3_SVM_Kernel_KNN.pptx
 
3D Reconstruction from Multiple uncalibrated 2D Images of an Object
3D Reconstruction from Multiple uncalibrated 2D Images of an Object3D Reconstruction from Multiple uncalibrated 2D Images of an Object
3D Reconstruction from Multiple uncalibrated 2D Images of an Object
 
EE660_Report_YaxinLiu_8448347171
EE660_Report_YaxinLiu_8448347171EE660_Report_YaxinLiu_8448347171
EE660_Report_YaxinLiu_8448347171
 
Templateless Marked Element Recognition Using Computer Vision
Templateless Marked Element Recognition Using Computer VisionTemplateless Marked Element Recognition Using Computer Vision
Templateless Marked Element Recognition Using Computer Vision
 
CS345-Algorithms-II-Lecture-1-CS345-2016.pdf
CS345-Algorithms-II-Lecture-1-CS345-2016.pdfCS345-Algorithms-II-Lecture-1-CS345-2016.pdf
CS345-Algorithms-II-Lecture-1-CS345-2016.pdf
 
various methods for image segmentation
various methods for image segmentationvarious methods for image segmentation
various methods for image segmentation
 
Support Vector Machines ( SVM )
Support Vector Machines ( SVM ) Support Vector Machines ( SVM )
Support Vector Machines ( SVM )
 
svm-proyekt.pptx
svm-proyekt.pptxsvm-proyekt.pptx
svm-proyekt.pptx
 
06 image features
06 image features06 image features
06 image features
 
Parallel Computing 2007: Bring your own parallel application
Parallel Computing 2007: Bring your own parallel applicationParallel Computing 2007: Bring your own parallel application
Parallel Computing 2007: Bring your own parallel application
 
02 image processing
02 image processing02 image processing
02 image processing
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manual
 
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
 
svm.pptx
svm.pptxsvm.pptx
svm.pptx
 
Two marks with answers ME6501 CAD
Two marks with answers ME6501 CADTwo marks with answers ME6501 CAD
Two marks with answers ME6501 CAD
 
Report
ReportReport
Report
 
426 Lecture5: AR Registration
426 Lecture5: AR Registration426 Lecture5: AR Registration
426 Lecture5: AR Registration
 
Kulum alin-11 jan2014
Kulum alin-11 jan2014Kulum alin-11 jan2014
Kulum alin-11 jan2014
 
Variational Autoencoders For Image Generation
Variational Autoencoders For Image GenerationVariational Autoencoders For Image Generation
Variational Autoencoders For Image Generation
 

Más de ankit_ppt

Deep learning summary
Deep learning summaryDeep learning summary
Deep learning summaryankit_ppt
 
08 neural networks
08 neural networks08 neural networks
08 neural networksankit_ppt
 
04 image transformations_ii
04 image transformations_ii04 image transformations_ii
04 image transformations_iiankit_ppt
 
03 image transformations_i
03 image transformations_i03 image transformations_i
03 image transformations_iankit_ppt
 
01 foundations
01 foundations01 foundations
01 foundationsankit_ppt
 
Text similarity measures
Text similarity measuresText similarity measures
Text similarity measuresankit_ppt
 
Text generation and_advanced_topics
Text generation and_advanced_topicsText generation and_advanced_topics
Text generation and_advanced_topicsankit_ppt
 
Nlp toolkits and_preprocessing_techniques
Nlp toolkits and_preprocessing_techniquesNlp toolkits and_preprocessing_techniques
Nlp toolkits and_preprocessing_techniquesankit_ppt
 
Matrix decomposition and_applications_to_nlp
Matrix decomposition and_applications_to_nlpMatrix decomposition and_applications_to_nlp
Matrix decomposition and_applications_to_nlpankit_ppt
 
Machine learning and_nlp
Machine learning and_nlpMachine learning and_nlp
Machine learning and_nlpankit_ppt
 
Latent dirichlet allocation_and_topic_modeling
Latent dirichlet allocation_and_topic_modelingLatent dirichlet allocation_and_topic_modeling
Latent dirichlet allocation_and_topic_modelingankit_ppt
 
Intro to nlp
Intro to nlpIntro to nlp
Intro to nlpankit_ppt
 
Ot regularization and_gradient_descent
Ot regularization and_gradient_descentOt regularization and_gradient_descent
Ot regularization and_gradient_descentankit_ppt
 
Ml10 dimensionality reduction-and_advanced_topics
Ml10 dimensionality reduction-and_advanced_topicsMl10 dimensionality reduction-and_advanced_topics
Ml10 dimensionality reduction-and_advanced_topicsankit_ppt
 
Ml9 introduction to-unsupervised_learning_and_clustering_methods
Ml9 introduction to-unsupervised_learning_and_clustering_methodsMl9 introduction to-unsupervised_learning_and_clustering_methods
Ml9 introduction to-unsupervised_learning_and_clustering_methodsankit_ppt
 
Ml8 boosting and-stacking
Ml8 boosting and-stackingMl8 boosting and-stacking
Ml8 boosting and-stackingankit_ppt
 
Ml6 decision trees
Ml6 decision treesMl6 decision trees
Ml6 decision treesankit_ppt
 

Más de ankit_ppt (20)

Deep learning summary
Deep learning summaryDeep learning summary
Deep learning summary
 
08 neural networks
08 neural networks08 neural networks
08 neural networks
 
07 learning
07 learning07 learning
07 learning
 
04 image transformations_ii
04 image transformations_ii04 image transformations_ii
04 image transformations_ii
 
03 image transformations_i
03 image transformations_i03 image transformations_i
03 image transformations_i
 
01 foundations
01 foundations01 foundations
01 foundations
 
Word2 vec
Word2 vecWord2 vec
Word2 vec
 
Text similarity measures
Text similarity measuresText similarity measures
Text similarity measures
 
Text generation and_advanced_topics
Text generation and_advanced_topicsText generation and_advanced_topics
Text generation and_advanced_topics
 
Nlp toolkits and_preprocessing_techniques
Nlp toolkits and_preprocessing_techniquesNlp toolkits and_preprocessing_techniques
Nlp toolkits and_preprocessing_techniques
 
Matrix decomposition and_applications_to_nlp
Matrix decomposition and_applications_to_nlpMatrix decomposition and_applications_to_nlp
Matrix decomposition and_applications_to_nlp
 
Machine learning and_nlp
Machine learning and_nlpMachine learning and_nlp
Machine learning and_nlp
 
Latent dirichlet allocation_and_topic_modeling
Latent dirichlet allocation_and_topic_modelingLatent dirichlet allocation_and_topic_modeling
Latent dirichlet allocation_and_topic_modeling
 
Intro to nlp
Intro to nlpIntro to nlp
Intro to nlp
 
Ot regularization and_gradient_descent
Ot regularization and_gradient_descentOt regularization and_gradient_descent
Ot regularization and_gradient_descent
 
Ml10 dimensionality reduction-and_advanced_topics
Ml10 dimensionality reduction-and_advanced_topicsMl10 dimensionality reduction-and_advanced_topics
Ml10 dimensionality reduction-and_advanced_topics
 
Ml9 introduction to-unsupervised_learning_and_clustering_methods
Ml9 introduction to-unsupervised_learning_and_clustering_methodsMl9 introduction to-unsupervised_learning_and_clustering_methods
Ml9 introduction to-unsupervised_learning_and_clustering_methods
 
Ml8 boosting and-stacking
Ml8 boosting and-stackingMl8 boosting and-stacking
Ml8 boosting and-stacking
 
Ml7 bagging
Ml7 baggingMl7 bagging
Ml7 bagging
 
Ml6 decision trees
Ml6 decision treesMl6 decision trees
Ml6 decision trees
 

Último

Katarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School CourseKatarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School Coursebim.edu.pl
 
Industrial Safety Unit-IV workplace health and safety.ppt
Industrial Safety Unit-IV workplace health and safety.pptIndustrial Safety Unit-IV workplace health and safety.ppt
Industrial Safety Unit-IV workplace health and safety.pptNarmatha D
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
home automation using Arduino by Aditya Prasad
home automation using Arduino by Aditya Prasadhome automation using Arduino by Aditya Prasad
home automation using Arduino by Aditya Prasadaditya806802
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvLewisJB
 
DM Pillar Training Manual.ppt will be useful in deploying TPM in project
DM Pillar Training Manual.ppt will be useful in deploying TPM in projectDM Pillar Training Manual.ppt will be useful in deploying TPM in project
DM Pillar Training Manual.ppt will be useful in deploying TPM in projectssuserb6619e
 
System Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event SchedulingSystem Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event SchedulingBootNeck1
 
Energy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptxEnergy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptxsiddharthjain2303
 
Mine Environment II Lab_MI10448MI__________.pptx
Mine Environment II Lab_MI10448MI__________.pptxMine Environment II Lab_MI10448MI__________.pptx
Mine Environment II Lab_MI10448MI__________.pptxRomil Mishra
 
Input Output Management in Operating System
Input Output Management in Operating SystemInput Output Management in Operating System
Input Output Management in Operating SystemRashmi Bhat
 
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfg
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfgUnit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfg
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfgsaravananr517913
 
Crushers to screens in aggregate production
Crushers to screens in aggregate productionCrushers to screens in aggregate production
Crushers to screens in aggregate productionChinnuNinan
 
Engineering Drawing section of solid
Engineering Drawing     section of solidEngineering Drawing     section of solid
Engineering Drawing section of solidnamansinghjarodiya
 
National Level Hackathon Participation Certificate.pdf
National Level Hackathon Participation Certificate.pdfNational Level Hackathon Participation Certificate.pdf
National Level Hackathon Participation Certificate.pdfRajuKanojiya4
 
US Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionUS Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionMebane Rash
 
11. Properties of Liquid Fuels in Energy Engineering.pdf
11. Properties of Liquid Fuels in Energy Engineering.pdf11. Properties of Liquid Fuels in Energy Engineering.pdf
11. Properties of Liquid Fuels in Energy Engineering.pdfHafizMudaserAhmad
 

Último (20)

Katarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School CourseKatarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School Course
 
Industrial Safety Unit-IV workplace health and safety.ppt
Industrial Safety Unit-IV workplace health and safety.pptIndustrial Safety Unit-IV workplace health and safety.ppt
Industrial Safety Unit-IV workplace health and safety.ppt
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
home automation using Arduino by Aditya Prasad
home automation using Arduino by Aditya Prasadhome automation using Arduino by Aditya Prasad
home automation using Arduino by Aditya Prasad
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvv
 
DM Pillar Training Manual.ppt will be useful in deploying TPM in project
DM Pillar Training Manual.ppt will be useful in deploying TPM in projectDM Pillar Training Manual.ppt will be useful in deploying TPM in project
DM Pillar Training Manual.ppt will be useful in deploying TPM in project
 
System Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event SchedulingSystem Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event Scheduling
 
Energy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptxEnergy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptx
 
young call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Serviceyoung call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Service
 
Mine Environment II Lab_MI10448MI__________.pptx
Mine Environment II Lab_MI10448MI__________.pptxMine Environment II Lab_MI10448MI__________.pptx
Mine Environment II Lab_MI10448MI__________.pptx
 
Input Output Management in Operating System
Input Output Management in Operating SystemInput Output Management in Operating System
Input Output Management in Operating System
 
Designing pile caps according to ACI 318-19.pptx
Designing pile caps according to ACI 318-19.pptxDesigning pile caps according to ACI 318-19.pptx
Designing pile caps according to ACI 318-19.pptx
 
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfg
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfgUnit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfg
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfg
 
Crushers to screens in aggregate production
Crushers to screens in aggregate productionCrushers to screens in aggregate production
Crushers to screens in aggregate production
 
Engineering Drawing section of solid
Engineering Drawing     section of solidEngineering Drawing     section of solid
Engineering Drawing section of solid
 
National Level Hackathon Participation Certificate.pdf
National Level Hackathon Participation Certificate.pdfNational Level Hackathon Participation Certificate.pdf
National Level Hackathon Participation Certificate.pdf
 
POWER SYSTEMS-1 Complete notes examples
POWER SYSTEMS-1 Complete notes  examplesPOWER SYSTEMS-1 Complete notes  examples
POWER SYSTEMS-1 Complete notes examples
 
Design and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdfDesign and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdf
 
US Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionUS Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of Action
 
11. Properties of Liquid Fuels in Energy Engineering.pdf
11. Properties of Liquid Fuels in Energy Engineering.pdf11. Properties of Liquid Fuels in Energy Engineering.pdf
11. Properties of Liquid Fuels in Energy Engineering.pdf
 

05 contours seg_matching

  • 1.
  • 2. 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
  • 3.
  • 4. Contours A contour is an assembled collection of edges that (hopefully) represent one object in the image. • Can be used to automatically segment the different objects present in an image.
  • 5. Preprocessing for cv2.findContours Can use canny edges • Images created by cvCanny Can use thresholded image where edges are boundaries between white and black • Images created by cvThreshold or cvAdaptiveThreshold Call cv2.findContours on result of Canny or thresholding.
  • 6. Contour Hierarchy Parent – Child Hierarchy 0 1 2 3 4 0 1 2 3 4
  • 7. Contour Hierarchy cvContour can represent data as a contour tree. 0 and 2 are the contours represented at the root, or parent, nodes. Other contours are represented as children of 0 or 2. 0 1 2 3 4
  • 8. cvFindContours Input needs to be 8-bit binary image. Make a copy of the image before using cvFindContours • The original image will be written over by cvFindContours OpenCV represents the contour hierarchy as an array: [next, previous, first_child, parent] 0 1 2 3 4
  • 9. Method Variable: Arguments to Find Contours Method clarifies how the contour is being computed. CV_CHAIN_CODE  Output = sequence of vertices (Freeman chain code) CV_CHAIN_APPROX_NONE  All chain code points = contour points CV_CHAIN_APPROX_SIMPLE  Endpoints of horizontal, vertical, diagonal segments CV_CHAIN_APPROX_TC89_L1  Teh_Chin chain algorithm CV_LINK_RUNS  Links horizontal segments of 1s  Limited to CV_RETR_LIST
  • 10. Mode Variable Mode clarifies what contours should be found and desired format for return value. Finds contours and uses horizontal and vertical links to link the found contours. Mode options: CV_RETR_EXTERNAL CV_RETR_LIST CV_ RETR_CCOMP CV_RETR_TREE
  • 11. CV_RETR_LIST All contours are put into a list This list does not have parent – child relationships Uses horizontal links All contours are on same level (no actual hierarchy) 0 1 2 3 4
  • 13. CV_RETR_CCOMP All contours are used to generate a 2-level hierarchy • Top-level hierarchy = external • Bottom-level = internal • Horizontal and vertical linkers 0 1 2 3 4
  • 14. CV_RETR_TREE All contours are used to generate a full hierarchy 0 1 2 3 4
  • 15. Drawing Contours Lets look at a new image and draw contours with cv2.drawContours Original Edges Edges used to compute contours
  • 16. Hull Borders Compute a convex hull cv2.convexHull()
  • 17. Hull Borders Compute convexity defects cv2.convexityDefects Checks contours to see if it is convex.
  • 18. Length and Area Length • cv2.ContourPerimeter Returns length of a contour You can summarize length and area as a bounding structure • Boxes • Circles • Ellipses
  • 19. Bounding Boxes cv2.BoundingRect() • Returns rectangle that bounds the contour • Red box in image cv2.MinAreaRec2() • Returns smallest rectangular bound • Green box in image Note green box is rotated for best fit
  • 20. Circles and Ellipses cv2.MinEnclosingCirlce() • Similar to cv2.BoundingRect() in that it bounds the contour, but not a best fit • Needs radius as input • Red circle in image cv2.FitEllipse2() • Allows us to get a best fit bound • Green circle image
  • 21. Geometric Toolkits/Checks cv2.maxRect() • Two input rectangles are used to compute a new rectangle cv2.BoxPoints() • Computers corner points of cvBox2D structure cv2.PointPolygonTest() • Test: is point in polygon?
  • 22. Contour Statistics 𝐴𝑠𝑝𝑒𝑐𝑡 𝑅𝑎𝑡𝑖𝑜𝑛 = 𝑊𝑖𝑑𝑡ℎ 𝐻𝑒𝑖𝑔ℎ𝑡 𝐸𝑥𝑡𝑒𝑛𝑡 = 𝑂𝑏𝑗𝑒𝑐𝑡 𝐴𝑟𝑒𝑎 𝐵𝑜𝑢𝑛𝑑𝑖𝑛𝑔 𝑅𝑒𝑐𝑡𝑎𝑛𝑔𝑙𝑒 𝐴𝑟𝑒𝑎 𝑆𝑜𝑙𝑖𝑑𝑖𝑡𝑦 = 𝐶𝑜𝑛𝑡𝑜𝑢𝑟 𝐴𝑟𝑒𝑎 𝐶𝑜𝑛𝑣𝑒𝑥 𝐻𝑢𝑙𝑙 𝐴𝑟𝑒𝑎 𝐸𝑞𝑢𝑖𝑣𝑎𝑙𝑒𝑛𝑡 𝐷𝑖𝑎𝑚𝑒𝑡𝑒𝑟 = 4 𝑥 𝐶𝑜𝑛𝑡𝑜𝑢𝑟 𝐴𝑟𝑒𝑎 𝜋 𝑂𝑟𝑖𝑒𝑛𝑡𝑎𝑡𝑖𝑜𝑛 𝐴𝑛𝑔𝑙𝑒 = 𝑐𝑣2. 𝑓𝑖𝑡𝐸𝑙𝑙𝑖𝑝𝑠𝑒(𝑐𝑛𝑡) 𝑥, 𝑦, 𝑤, ℎ = 𝑐𝑣2. 𝑏𝑜𝑢𝑛𝑑𝑖𝑛𝑔𝑅𝑒𝑐𝑡(𝑐𝑜𝑛𝑡) 𝑎𝑟𝑒𝑎 = 𝑐𝑣2. 𝑐𝑜𝑛𝑡𝑜𝑢𝑟𝐴𝑟𝑒𝑎(𝑐𝑜𝑛𝑡) ℎ𝑢𝑙𝑙 = 𝑐𝑣2. 𝑐𝑜𝑛𝑣𝑒𝑥𝐻𝑢𝑙𝑙(𝑐𝑜𝑛𝑡) ℎ𝑢𝑙𝑙_𝑎𝑟𝑒𝑎 = 𝑐𝑣2. 𝑐𝑜𝑛𝑡𝑜𝑢𝑟𝐴𝑟𝑒𝑎(ℎ𝑢𝑙𝑙)
  • 23. Finding Extreme Points: Min/Max Min/Max is computed with NumPy. Extreme points of the cross are min/max left/right and up/down.
  • 24.
  • 25. Foreground/Background Separation Separate foreground from background Send foreground on for further analysis • Cars in security camera • Skin within an image (reduces complexity of finding faces) Superpixels • Groups of pixels in same object/type of object
  • 26. Methods: Image Pyramids Collection of images where each subsequent image is a downsampling of the previous. Gaussian pyramid  Used to downsample  Removes even rows and columns  Will give you higher resolution Laplacian pyramid  Used to upsample  Works with lower-resolution images and allows for faster computations
  • 27. Gaussian Pyramid Use cvPyrDown() with a 5x5 Guassian kernel • Start with G0 (original image) • Convolve G0 with Gaussian kernel • Gi is ¼ size of G0 because we removed even-numbered rows and columns from G0 • Repeat for all desired Gi+1
  • 28. Laplacian Kernel Use cvPyrUp() Notice the relationship between Gausian and Laplacian In OpenCV we see this as: Lapi = Gausi – PyrUp(Gausi+1 ) Remember, we saw this in Week 3!
  • 29. Methods to Segment an Image cvPyrSegmentation () • Generates an image pyramid • Associates pyramid layers to parent-child relationships • Map pixels between Gi+1 and Gi • Perform segmentation on lower-resolution images • Note: Start image must be divisible by 2 for each layer of the pyramid
  • 30. Mean Shift Clustering Over Color pyrMeanShiftFiltering() Peak of color-spatial distribution over space Data dimensions are: Spatial (x, y) Color (blue, green, red) Parameters are spatialRadius, colorRadius, max_level, and CvTermCriteria.
  • 31. Watershed Used to separate objects when you do not have a separate background image. Input is a grayscale image or a smoothed color image. Can cause oversegmentation or undersegmentation • If you make too many basins or too few Lines converted to peaks; uniform regions to catchment basins.
  • 32. Watershed Method Take the gradient of intensity image. Marker points, or known areas of region of interest, are defined by user. Basins get connected to marker points to create segments.
  • 33. Watershed: Example Step 1: Threshold a color image
  • 34. Watershed: Example Step 2: Remove noise with cv2.morphologyEx
  • 35. Watershed: Example Step 3: Sure background area with cv2.dilate()
  • 36. Watershed: Example Step 4: Find sure foreground area with cv2.distanceTransform() and cv2.threshold()
  • 37. Watershed: Example Step 5: Find unknown region with cv2.subtract()
  • 38. Grabcut: Graph Cutting Techniques Pixel-based energy function Basic binary segmentation algorithm to identify object Iteratively recalculates the region statistics (Gaussians) to perform segmentation
  • 39. GrabCut Procedure (1) Assign background and unknown Unknown becomes potential foreground (2) Create five probabilistic clusters (each) of foreground and background (3) Assign every background pixel to a cluster of background Do the same for foreground (4) Compute cluster statistics for all clusters
  • 40. GrabCut Procedure (continued) (5) Create a graph where: Pixels are linked to their neighbors and to two special nodes  Nodes represent foreground and background The weights of the links are related to neighbor similarity and class probability
  • 41. GrabCut Procedure (continued) (6) Apply a classic computer science graph theory algorithm min-cut to the graph The net result cuts the connections from each pixel to one of the two special nodes. In turn, this gives us a new assignment for foreground/background to the pixels. (7) Until convergence, we loop back to Step 4 and repeat Classifications remain similar enough from one round to the next.
  • 42.
  • 43. Contour Moments: Matching Contours Compare statistical moments of contours: In statistics, first moment is the mean, second moment is the variance, and so on. Moments are used to compare two contours (outlines) for similarity. Another technique: Compute rough contour characteristic computed by summation of all pixels over contour boundary: p: x-order q: y-order Normalized moments are better for comparing similar shapes of different sizes. 𝑚 𝑝,𝑞 = 𝑖=1 𝑛 𝐼 𝑥, 𝑦 𝑥 𝑝 𝑦 𝑞
  • 44. Statistical Moments In classical statistics, we use mean, variance, skew, and kurtosis. cvMoments() cvGetCentralMoment() invariant with respect to translation cvGetNormalizedMoment() invariant with respect to scale cvGetHuMoments() invariant with respect to rotation
  • 45. Normalized Moments Central moments normalized with respect to a function intensity. First need to calculate central moment: Then you can calculate normalized moments: 𝜂 𝑝,𝑞 = 𝜇 𝑝,𝑞 𝑚00 𝑝 + 𝑞 /2 + 1 𝜇𝑝, 𝑞 = 𝑥,𝑦 𝐼 𝑥, 𝑦 𝑥 − 𝑥𝑎𝑣𝑔 𝑝 𝑦 − 𝑦𝑎𝑣𝑔 𝑞
  • 46. Hu Invariant Moments Linear combinations of centralized moments. Use central moments to get invariant functions • Invariant to scale, rotation, and reflection cvGetHuMoments() ℎ1 = 𝜂20 + 𝜂02 ℎ4 = (𝜂30+ 𝜂12)2 + (𝜂21 + 𝜂03)2
  • 47.
  • 48. Template Matching Overview Use cvMatchTemplate() to find one image within another. Uses the actual image of matching object instead of a histogram • This is called an image patch Input image • 8-bit, floating point plane, or color image Output • Single-channel byte or floating point image
  • 49. Template Matching Methods Squared difference CV_TM_SQDIFF_NORMED Correlation CV_TM_CCORR_NORMED Correlation coefficient CV_TM_CCOEFF_NORMED 𝑅 𝑠𝑞𝑑𝑖𝑓𝑓 𝑥, 𝑦 = 𝑅 𝑠𝑞𝑑𝑖𝑓𝑓(𝑥, 𝑦) 𝑍(𝑥, 𝑦) 𝑅 𝑐𝑐𝑜𝑟𝑟 𝑥, 𝑦 = 𝑅 𝑐𝑐𝑜𝑟𝑟(𝑥, 𝑦) 𝑍(𝑥, 𝑦) 𝑅 𝑐𝑐𝑜𝑒𝑓𝑓 𝑥, 𝑦 = 𝑅 𝑐𝑐𝑜𝑒𝑓𝑓(𝑥, 𝑦) 𝑍(𝑥, 𝑦)
  • 50. Histogram Backprojection Uses a histogram model to match pixels (or patches of pixels) to approach object recognition.
  • 51. Histogram Backprojection Better thought of as segmentation to foreground ROIs used for further analysis. If you have a histogram of the ROI, we can use that to find the object in another image. Use histogram from one image to match to histogram profile from another image Normalize to pixel number Find matching object, or ROI cvCalcBackProjectPatch()
  • 52. Histogram Backprojection Given a color, we want to know the probability of foreground/background. Approximate probability that a particular color belongs to a particular object You can also make a ratio histogram where you de-emphasize colors not in the ROI. 𝑝 𝑜𝑏𝑗𝑒𝑐𝑡 𝑐𝑜𝑙𝑜𝑟 = 𝑝 𝑐𝑜𝑙𝑜𝑟 𝑜𝑏𝑗𝑒𝑐𝑡 ∗ 𝑝(𝑜𝑏𝑗𝑒𝑐𝑡) 𝑝(𝑐𝑜𝑙𝑜𝑟) ~ 𝑝 𝑐𝑜𝑙𝑜𝑟 𝑜𝑏𝑗𝑒𝑐𝑡
  • 53. Backprojection Method 1. Calculate ROI histogram 2. Normalize histogram 3. Apply cv2.calcBackProject 4. Convolve with circular disc 5. Duplicate threshold

Notas del editor

  1. Recall: White is the object and black is the background.
  2. Quick test for students: What would happen if there were a box around everything?
  3. We have only drawn the contour for the last lightning bolt.
  4. NOTE: Green points are the defects. Defects are points furthest from the outer contour. For example, the top-right green is furthest from the top-right red contour.
  5. Calculated using NumPy, not built-ins.
  6. Image url?
  7. Probabilistic clusters are components of a Gaussian mixture model. The class node probabilities can be set to 100% FG/BG, which guarantees the pixel keeping its association with that class after min-cutting.
  8. NOTE: Equality is from Bayes’ Theorem. Approximation is made by assuming p(o)/p(c) is a constant, which, if we normalize probabilities, can be dropped.