1
$\begingroup$

I would like to detect a curve in a grid. Example (hand-drawn):

https://imgur.com/a/WsE85

I would like to detect the intersects of the curve with the vertical gridlines marked with the "x" symbols. I already managed to get a decent solution when the curve and the grid have different colors (purely based on color separation and an explicit declaration of the horizontal coordinates to measure at).

What I am struggling with is doing the same when grid and curve have the same color (and mostly same color intensity/thickness of lines).

What methods could I look into to solve this? Is there a proven approach for this type of problem?

NB: So far I have worked with OpenCV and Python.

TIA Matt

$\endgroup$
1
$\begingroup$

Conceptually, I would go for the following steps:

  1. Perform thresholding of the image to create black/white image.

  2. Detect the grid in the image. How you do this depends on the image properties. For example, will the grid lines always be horizontally and vertically or can the grid also be rotated? If it's always horizontal, you can simply add up the pixel values in all rows or in all columns, and you will see the grid lines in the sums. Also, you can detect the grid lines using Hough Transform.

  3. Remove the grid lines from image, e.g. by setting all pixels that belong to the grid to 0.

  4. Use dilation to close the gaps in the curve, where the grid lines were removed.

  5. check, where the curve crosses the grid lines by checking, where the grid image and the dilated image are both 1.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.