Having contours extracted from a binary image gives you an alternative image representation and allows you to apply contour-specific image analysis methods. In this recipe, you will learn how to find contours in a binary image.
Finding external and internal contours in a binary image
Getting ready
For this recipe, ensure that you have installed the OpenCV 3.x Python API package and the matplotlib package.
How to do it...
- Import the modules:
import cv2
import numpy as np
import matplotlib.pyplot as plt
- Load the test binary image:
image = cv2.imread('../data/BnW.png...