# extract data from a graph image

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

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

– Kuba
Feb 1, 2016 at 7:18
• @Kuba thank you i'll check it out. Feb 1, 2016 at 7:19
• Here is a solution that might work for you: mathematica.stackexchange.com/a/167483/55694 Mar 8, 2018 at 23:17
• Maybe you should try plotdigitizer. You can eliminate the grid lines by masking the curve. Apr 9, 2021 at 12:29

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}];


Then simply binarize the difference:

Binarize[ImageDifference[img, grid]]