Not perfect, but may help :-
If you have a convex polygon then the above algorithm works.
Test if you do have a convex polygon by
fill polgon with a colour not used anywhere else in image
take each vertex n and vertex n+2 and calculate midpoint
if '[man]imagecolorat[/man]' each midpoint is the polygon colour then polygon is convex and above algorithm can be applied
if concave
take a vertex n
test midpoints of vertex n and vertex n+y (y >= 2) incrementing y until colour at midpoint is the polygon colour
Place your letter at that midpoint