backgroundModels: clean up and optimise

Big speed-up (~9x) on calling PolygonBackground.fromImage()
and .getImage().