Welcome to the second post in this series where we talk about extracting regions of interest (ROI) from images using OpenCV and Python.

As a recap, in the first post of this series we went through the steps to extract balls and table edges from an image of a pool table. We used simple OpenCV functions like inRange, findContours, boundingRect, minAreaRect, **minEnclosingCircle, circle, HoughLines, line etc **to achieve our objective.

For beginners in OpenCV, I would recommend to go through that post in order to get familiar with the usage of the above functions.

In this post we will look at a somewhat more complex problem and explore some methods which we can use to obtain the desired results.

Our task today is to extract the desired segments from an image which contains a snapshot of a patients brain activity map. The extracted segments can then be used in numerous applications e.g. in a Machine Learning model which can diagnose any health anomalies.

So let us start by looking at the input image itself. It is a typical report generated by medical instruments used in the field of Neurological Science which use sensors to detect signals from a patients brain and display them as colored maps. Typically there are four maps, all of which depict a certain feature and are analyzed together for diagnosis (further details are out of current scope).

Image for post

Our target image for this exercise containing the four brain maps (image source author)

From the above image, we want to extract only the regions corresponding to the four maps (head scans) leaving everything else out. So lets get going.

The first step is detecting the edges of the segments we want to extract. This is a multi step process as mentioned below:

  1. Convert the RGB image to gray-scale using “cvtColor()”
  2. Remove noise from the gray-scale image by applying a blurring function “GaussianBlur()”
  3. Finally applying the “Canny()” function to the blurred image to obtain the edges

#opencv #python #image-processing #computer-vision

Extracting regions of interest from images
22.45 GEEK