End-to-end diagnosis and segmentation learning from cardiac magnetic resonance imaging