How to convert textures into materials per each triangle in blender
It is not what did you ask for, but might be helpful. Add-on Bake to Vertex Color takes image texture with UV map coordinates and creates (bake) colors into vertex color (you can find it under Data Properties &gt; Vertex Color. It doesn't take an average, but certain pixel under vertex.




Note:

To generate average color usually ends with a braun color :)
There can be also stored color per face instead vertex, but I'm not experienced with that.