Here are some posts about how to update vertex colors of a mesh:
Its up to you to filter which vertex should be which color.
To fix it too are more smooth color you maybe should increase the total numbers of vertexes of your mesh.
The more vertexes the more smooth it will render.