Learning affinity functions for image segmentation: combining patch-based and gradient-based approaches | Synapse