Book Image

Learning OpenCV 3 Computer Vision with Python (Update)

Book Image

Learning OpenCV 3 Computer Vision with Python (Update)

Overview of this book

Table of Contents (16 chapters)
Learning OpenCV 3 Computer Vision with Python Second Edition
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
6
Retrieving Images and Searching Using Image Descriptors
Index

Object segmentation using the Watershed and GrabCut algorithms


Calculating a disparity map can be very useful to detect the foreground of an image, but StereoSGBM is not the only algorithm available to accomplish this, and in fact, StereoSGBM is more about gathering 3D information from 2D pictures, than anything else. GrabCut, however, is a perfect tool for this purpose. The GrabCut algorithm follows a precise sequence of steps:

  1. A rectangle including the subject(s) of the picture is defined.

  2. The area lying outside the rectangle is automatically defined as a background.

  3. The data contained in the background is used as a reference to distinguish background areas from foreground areas within the user-defined rectangle.

  4. A Gaussians Mixture Model (GMM) models the foreground and background, and labels undefined pixels as probable background and foregrounds.

  5. Each pixel in the image is virtually connected to the surrounding pixels through virtual edges, and each edge gets a probability of being foreground...