Generating 3D segmentation from MR or CT images