How many ways are there to fill a 3 × 3 grid with 0s and 1s?

Use Burnside's lemma. The number of symmetries of the matrix is eight:

  • the identity, leaving $2^8$ admissible matrices unchanged (the centre cell being fixed)
  • two 90° rotations leaving $2^2$ matrices unchanged each
  • a 180° rotation leaving $2^4$ matrices unchanged
  • four reflections leaving $2^5$ matrices unchanged each

So the number of possible matrices up to symmetry is $$\frac{2^8+2\cdot2^2+2^4+4\cdot2^5}8=32+1+2+16=51$$