Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

OpenCV has great tools to solve this. Extract the red channel from the color image (2nd image below). Threshold this image with a threshold value of about 220 (3rd image below). Do a couple rounds of dilation to fill in holes left by threshold (4th image below) After this, get the contours and pick out the top one (smallest center y value). Divide this top contour in half to get 2 contours - a left side and a right side. Then look at the aspect ratios of these 2 contours. A flat line will have a larger wd/ht ratio.

image description