Hello - I wonder if someone could help me please?

I need to develop a GUI web application to allow users to easily edit a simple
color pallette of a defined image online.

A simple example would be a 2000 x 500 pixel image that consists of two
patterns. Pattern 1 could spell 'hello world', Pattern 2 would be the
background. With the intial colors for Pattern 1 = white, Pattern 2 = black for
example.

The available color palette could consist of all websafe colors for example.

The GUI application would allow users to change the color of each of the
patterns within the image to any of the available pallette colors, and store
the final configuration.

The actual application will involve far more complex images with up to 20
patterns per image - thus a far higher number of permutations. I will have to
code the patterns pixel by pixel manually to begin with. And was hoping to use
some sort of matrix operation to access the color of each pattern, where the
color is a variable within the overall pixel matrix or something similar. I
basically want to avoid having to create an image of each permutation and
switching between them.

What would be the best approach?
Also does anyone know of any prior art that exists that I could look at or
copy - I don't want to reinvent the wheel here ;-)

Many thanks,
Richard