A learning-based material decomposition pipeline for multi-energy x-ray imaging