Where to find a pixel to tile converter?

I’m looking for a program that can replace pixels with tiles, does it exist?
If there is an 8x8 pixel image with green, blue and brown, the program would replace all the green with grass, blue with water and brown with dirt tiles that the user could set with a ‘browse’ button, or from a tileset.

Here’s an image to show you what I mean:

  • Mike