This study was aimed at exploring the efficacy of morphine combined with mechanical ventilation in the treatment of heart failure with artificial intelligence algorithms. The cardiac magnetic resonance imaging (MRI) under the watershed segmentation algorithm was proposed, and the local grayscale clustering watershed (LGCW) model was designed in this study. A total of 136 patients with acute left heart failure were taken as the research objects and randomly divided into the control group (conventional treatment) and the experimental group (morphine combined with mechanical ventilation), with 68 cases in each group. The left ventricular end-diastolic diameter (LVEDD), left ventricular end-systolic diameter (LVESD), left ventricular ejection fraction (LVEF), N-terminal pro-brain natriuretic peptide (NT-proBNP), arterial partial pressure of oxygen (PaO2), and arterial partial pressure of carbon dioxide (PaCO2) were observed. The results showed that the mean absolute deviation (MAD) and maximum mean absolute deviation (max-MAD) of the LGCW model were lower than those of the fuzzy k-nearest neighbor (FKNN) algorithm and local gray-scale clustering model (LGSCm). The Dice metric was also significantly higher than that of other algorithms with statistically significant differences (
P
<
0.05
). After treatment, LVEDD, LVESD, and NT-proBNP of patients in the experimental group were significantly lower than those in the control group, and LVEF in the experimental group was higher than that in the control group (
P
<
0.05
). PaO2 of patients in the experimental group was also significantly higher than that in the control group (
P
<
0.05
). It suggested that the LGCW model had a better segmentation effect, and morphine combined with mechanical ventilation gave a better clinical efficacy in the treatment of acute left heart failure, improving the patients’ cardiac function and arterial blood gas effectively.