I'd like to take an photograph, subdivide it into a tesselation, either of squares, or (ideally), hexagons, and then find the centre of gravity (or, if you prefer, centre of mass) of each cell of the tesselation.

The output, for any image, would be a matrix of points. For the attached diagram, something like this (in polar coordinates - $(r,\theta)$ ):

(5,5Π/4) (0,0) (1,7Π/4) (1,5Π/4)
     (5,3Π/4) (0,0) (5,Π/2) 
(0.0) (0,0) (0.0) (0,0)  

I've attached an image showing what I mean.

Hexagonal tesselation. The black circles are the centres of gravity of each cell - in clear, or monochrome, cells it is in the centre of the cell. In those with a green splodge, the cog is pulled towards the splodge

My question, to put it simply, is the best method to use to calculate the cog, in this tessellation... For squares, it'd be easy to calculate the weighted mean for each row, but that would be too rough an approximation. What's a good way to iterate either a general tessellation (ideal), or an hexagonal one?

  • $\begingroup$ Could you explain what you mean by mass in this context? Does it depend on the colour values of the hexagonal cells? Are you trying to find the centre of the light pixels/dark pixels/a particular specified colour? This is likely to affect the answer so it's worth giving as much detail as you have. $\endgroup$ Sep 9, 2016 at 11:50
  • $\begingroup$ Good question. Yes colour value is good enough. Actually I'll be working with B&W, so its really the cog of the ink. $\endgroup$ Sep 9, 2016 at 14:32


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.