Edge Extraction

Another popular type of feature extraction in images includes edge extraction. This is very applicable to our dataset because cats and dogs have very distinct shapes. For example, cats usually have small pointy ears while dogs have larger floppy ears or ears that are more rounded. Furthermore, cats also have much larger whiskers compared to dogs. Therefore, if we can feed edges as extracted features into our ML models we can save a lot of computation power and time, while increasing accuracy.

To perform edge extraction on our images, we used the python CV2 library to convert images into the grayscale and then used the Canny Edge Detection Algorithm. Once we identified the edges we enhanced them so that we would be able to better distinguish between cats and dogs.

Canny Edge Detection Algorithm

The Canny Edge Detection is a popular multi-step algorithm that is used to detect various types of edges in an image. Here is a brief overview of the various steps in the algorithm.

  1. A Gaussian Filter Kernel is convolved with the image.

  • We used a 10x10 Kernel so that we would only be able to detect very large edges in our image. This is because most of our images have very noisy backgrounds and we didn't want our filter to pick up edges in those parts of the image.

  1. Find the intensity gradient of the image.

  • In this step, the algorithm uses filters to find horizontal, vertical, and diagonal edges in the image.

  1. Gradient Thresholding

  • This is used to find areas where there is the greatest change in intensity value. These areas are usually where the edges are located.

  1. Double Thresholding

  • This step is used to eliminate extra noise and make sure we only detect the most significant edges.

  1. Hysteresis Edge Tracking

  • In this step, we make edge connections using blob analysis.