How to import xdmf mesh generated by gmsh into fenics

As i do not know what meshing tool you use to go from an image to a mesh, it is hard to give you any specific tips.

If you use Gmsh for this, there might be a tutorial on their webpage:
https://gmsh.info/

The second option doesn’t take many lines of Python to program. See for instance: