

This is also pretty straightforward and involves identifying the image center coordinates as well as the centroid of each of our detected segments. Top-Left, Top-Right, Bottom-Left and Bottom-Right. The logic is pretty straightforward hence we do not need any inbuilt OpenCV or Python functions.Īnother important logic is to identify the four segments separately i.e. we look at all overlapping contours and select the one with the maximum area as the final candidate. This problem is solved using Non Maxima Suppression, i.e. It is often the case that multiple overlapping contours are detected over a segment whereas we are interested in only one. It may appear that our task is finished but there is a little bit of fine tuning required. Area is above a certain threshold (the value 7000 works fine for this example).įor the first part, we will detect the bounding rectangle of each contour using OpenCV “boundingRect()” and check whether the aspect ratio (height to width ratio) is close to 1.Now we can extract the contours in this image using OpenCV function “findContours()” and select only those contours which have the following properties: Some enhancements in the edges using OpenCV (image source author)Īs you can see, the edges are now complete and much smoother than before. 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). 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. So let us start by looking at the input image itself. in a Machine Learning model which can diagnose any health anomalies. The extracted segments can then be used in numerous applications e.g.


Our task today is to extract the desired segments from an image which contains a snapshot of a patients brain activity map. 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. We used simple OpenCV functions like inRange, findContours, boundingRect, minAreaRect, minEnclosingCircle, circle, HoughLines, line etc to achieve our objective.įor beginners in OpenCV, I would recommend to go through that post in order to get familiar with the usage of the above functions. Welcome to the second post in this series where we talk about extracting regions of interest (ROI) from images using OpenCV and Python.Īs 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. Using OpenCV for efficiently extracting ROI from images
