This is too long for a comment.
The difficulty with the example image is that it is not "clean" in the sense that it contains pixel gradients. There are 256 colors present despite the fact that there are only 50 triangles. This is why you get the imperfect output from EdgeDetect
, and it is going to make any image processing more difficult.
We can see this problem if we try a naïve conversion with ColorRules
:
img = Import["http://i.imgur.com/Y87duSz.jpg"];
colors = DeleteDuplicates[Flatten[ImageData[img], 1]];
newColors = ColorData["AvocadoColors"] /@ Rescale[Range[Length@colors]];
Colorize[img, ColorRules -> MapThread[Rule, {colors, newColors}]]

In this case, sorting the source colors (because the replacement colors are sequential) makes this less obvious:
colors2 = Sort@DeleteDuplicates[Flatten[ImageData[img], 1]];
Colorize[img, ColorRules -> MapThread[Rule, {colors2, newColors}]]

You can use ColorRules
to control how shapes get colored, but that will require some manual input or some other logic based on the particular image. The rules can involve patterns.
By way of comparison, look at this "clean" image:
Flatten[Table[{x, y}, {x, 0, 5}, {y, 0, 5}], 1];
MeshPrimitives[DelaunayMesh[%], 2];
Riffle[%, ColorData["AvocadoColors"] /@ Rescale[Range@Length@%]] // Graphics;
Image[%]

EdgeDetect[%, 1, .05]

Colorize[%%]
