Fundamentals of image contours

Evergreen Technologies
4 min readJan 2, 2020

What is image contour?

Image contouring is process of identifying structural outlines of objects in an image which in turn can help us identify shape of the object.

Consider an example below. On the left we have a hollow rectangle and solid circle. When we apply contouring with Red color, what we get is image on the right. As you can see it has identified 3 objects, 2 rectangles and a circles and their borders have been drawn with red color.

Here is the code for finding and drawing contours

Bounding Boxes:

Bounding boxes are rectangular (or circular) area that encloses the object. For rectangle object it coincides with contour but for circular objects it draws container clearly as shown in example below. Bounding boxes are useful for showing face boundaries in face recognition application.

Here is the code for drawing bounding box

Contour Properties:

contour properties like aspect ratio, extent, solidity are useful for detecting the shape.

aspect ratio : width/height. For rectangle shape aspect ratio < 1 or > 1 but for square aspect ration is 1

extent: contour area/bounding box area. for rectangle or square extent is close to 1. For irregular sign like lightning symbol, extent < 1 as shown below

convex hull and solidity:

convex hull is minimum convex area that encompasses all the points in set T. It is like mathematical rubber band as shown in picture below.

--

--

Evergreen Technologies

Decades of experience in Blog writing, Technical Advisory and Online Training. Read more about me @ https://evergreenllc2020.github.io/about.html