How to detect a curve in a B&W image with a background grid?

Solution 1:

After several experiments (based on these examples) and tests, I ended up with this code:

let src = cv.imread('canvasInput');
let dst = new cv.Mat();
let M = cv.Mat.ones(3, 3, cv.CV_8U);
let anchor = new cv.Point(-1, -1);

cv.dilate(src, dst, M, anchor, 1, cv.BORDER_CONSTANT, cv.morphologyDefaultBorderValue());
cv.imshow('canvasOutput', dst);
src.delete(); dst.delete(); M.delete();

Probably it is possible to get even better results by concatenating multiple further filters, anyway already in this way I have acceptable results.

Full source image: Source

Edited, but data untouched:

annotated

Processed by above code ("dilate"):

processed

Submitted to webplotdigitizer (look at settings on the right; yellow area is the only one processed by webplotdigitizer):

submitted to webplotdigitizer

Raw processing by webplotdigitizer ; some stray points appear, but they can be easily manually deleted:

digitized

Cleaned up:

cleaned

Re-plotted:

replotted

Note: in original image, horizontal and vertical scales are different: horizontal one is 4x w.r.t vertical one; resizing vertically 4x I get:

resized

Overlaying final image on source image, we can see it matches perfectly:

overlay

Of course it would be better to have digitization inside the same source code, but this is another story...