# 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.

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