How do I convert the following image graph into data (if possible into function)?

enter image description here

I checked this answer and found that my problem is grid and plot have same color.


1 Answer 1


If the problem is only to remove the grid, that's relatively easy. You just remove everything but the grid, then take the difference.

You can use Closing with a rectangular structuring element to remove everything but the horizontal / vertical grid lines, like this:

img = Import["http://i.stack.imgur.com/TkvSR.png"];    
hFilter = Closing[img, BoxMatrix[{10, 0}]];
vFilter = Closing[img, BoxMatrix[{0, 10}]];

then take the pixel-wise min to get the full grid:

grid = ImageApply[Min, {hFilter, vFilter}];

enter image description here

Then simply binarize the difference:

Binarize[ImageDifference[img, grid]]

enter image description here

(From here, you should be able to use code from the answers already linked.)


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.