In this chapter, we will cover the following recipes:
- Binarization of grayscale images using the Otsu algorithm
- Finding external and internal contours in a binary image
- Extracting connected components from a binary image
- Fitting lines and circles into two-dimensional point sets
- Calculating image moments
- Working with curves - approximation, length, and area
- Checking whether a point is within a contour
- Computing the distance to a two-dimensional point set from every pixel
- Image segmentation using the k-means algorithm
- Image segmentation using segment seeds, the watershed algorithm