01Chapter 1: Preparing a binary image: grayscale, blur and thresholdingAssume you know basic Python and NumPy array indexing. You should also know how to load and save images with OpenCV, and how color channels differ from grayscale pixels. The examples use OpenCV 4 and Python.2 min read
02Chapter 2: Edges as an alternative input: CannyThis chapter assumes that you can load, save, and display images with OpenCV, and that you understand grayscale images and NumPy arrays. It also assumes basic Python.2 min read
03Chapter 3: Cleaning masks with morphological operationsAssume you know basic Python, NumPy array indexing, and how to load and save OpenCV images. This chapter also assumes that you can create a grayscale or binary mask. A binary mask is an image whose pixels usually contain only 0 for background and 255 for foreground. Contour detection works best 2 min read
04Chapter 4: Finding contours with cv2.findContoursThis chapter assumes basic Python, NumPy indexing, and OpenCV image loading and saving. You should also know that a grayscale image stores one intensity value per pixel, while a binary image uses background and foreground values.2 min read
05Chapter 5: Choosing a contour approximation methodThis chapter assumes that you can load images with OpenCV, work with NumPy arrays, and prepare a binary mask. A contour is a list of points that follows the boundary of a connected region. OpenCV can store that boundary in different ways.1 min read
06Chapter 6: Retrieval modes and reading the hierarchyThis chapter assumes that you can load images with OpenCV, work with basic NumPy arrays, and understand grayscale and binary images. A contour is a curve around a connected foreground region. The retrieval mode controls which contours OpenCV returns and how it records their relationships.2 min read
07Chapter 7: Drawing and inspecting contoursAssume you can load images with OpenCV and understand grayscale images, NumPy arrays, and basic Python loops. This chapter shows how to draw detected contours and inspect them before measuring or classifying shapes.2 min read
08Chapter 8: Measuring contours: area, perimeter and centroidAssume you know basic Python, NumPy array indexing, and how to load and save images with OpenCV. You should also understand that an image is an array of pixels and that a binary mask separates foreground pixels from background pixels.2 min read
09Chapter 9: Filtering out noise by contour measurementsAssume you know basic Python, NumPy indexing, and how to load and save images with OpenCV. A contour is a curve around a connected foreground region in a binary image. Threshold noise often creates many tiny contours. Measuring each contour lets you keep meaningful objects and reject unwanted region1 min read
10Chapter 10: Bounding rectangles, circles and ellipsesThis chapter assumes that you can load images with OpenCV, work with NumPy arrays, and obtain contours from a binary mask. A contour is an ordered set of boundary points. Bounding shapes summarize that boundary with a simpler geometric object.1 min read
11Chapter 11: Simplifying contours with approxPolyDPThis chapter assumes that you know basic Python and NumPy indexing, can load and save images with OpenCV, and understand grayscale and binary images. It also assumes you have already created a clean binary mask and extracted contours with cv2.findContours.2 min read
12Chapter 12: Detecting triangles, rectangles and circlesAssume you know basic Python, NumPy indexing, and how to load and save images with OpenCV. This chapter uses OpenCV 4 and works with a clean binary mask containing dark shapes on a light background.2 min read
13Chapter 13: Convex hulls and convexity defectsAssume you know basic Python, NumPy array indexing, image loading with OpenCV, and how contours are extracted. This chapter focuses on describing whether a contour is concave or close to convex.2 min read
14Chapter 14: Comparing shapes with matchShapesThis chapter assumes that you can load images with OpenCV, work with NumPy arrays, and create binary masks. A contour is a sequence of points that follows the boundary of a connected white region in a binary image.2 min read
15Chapter 15: Common pitfalls and debugging checklistThis chapter assumes you know basic Python, NumPy indexing, image loading with OpenCV, and grayscale pixel values. It focuses on diagnosing contour results that are missing, excessive, or geometrically wrong.2 min read