After severe infantile pneumonia accompanied by heart failure, the evaluation of cardiac function using two-dimensional speckle tracking-based ultrasonic imaging technology was looked into both before and after milrinone treatment. The study’s research subjects included 82 kids with severe pneumonia and heart failure. According to therapeutic methods, they were divided into the Conv group (conventional treatment for 31 cases) and the Milrinone group (conventional treatment combined with milrinone for 31 cases). Conventional children’s ultrasonocardiography was collected to implement wavelet threshold denoising before and after treatment. The modeling was performed using statistical methods, i.e., Canny arithmetic was used to check the edge outlines of abnormal areas. Besides, the global search block matching method was utilized to monitor three consecutive cardiac cycle images. The differences between cardiac function, right ventricular longitudinal strain after two-dimensional speckle tracking imaging, serum inflammatory factors (interleukin (IL)-6, IL-10, tumor necrosis factor (TNF)-α, and brain natriuretic peptide (BNP)), and complication rate of children were evaluated. In comparison to Gaussian low-pass filter and mean filter techniques, the results showed that mean square error (MSE), peak signal to noise ratio (PSNR), and mean structural similarity (MSSIM) of pictures following wavelet threshold denoising were all superior. When Canny arithmetic and global search block matching were used, the cardiac speckle tracking time was 0.07 ms, and the detection accuracy was 95.5%. Compared with the Conv and Milrinone groups, normal respiration, pulmonary moist rale disappearance, and liver recovery time were all shortened (P<0.05). Besides, children’s cardiac functions, including aortic peak flow velocity, left ventricular ejection fraction, corrected ejection time, and stroke volume index, significantly increased compared with those of Conv group and Milrinone group (P<0.05). Heart rate (HR), the overall longitudinal strain of right ventricle during systole, the overall longitudinal strain of the free wall, and the overall longitudinal strain of the interventricular septum were remarkably decreased (P<0.05). Compared with the Conv and Milrinone groups, serum IL-6, IL-10, TNF-α, and BNP levels of children were remarkably reduced (P<0.05). The total complication rate of the children in Conv group and Milrinone group were 16.1% (5/31) and 3.2% (1/31), respectively. The differences between the two groups were statistically significant (P<0.05). In conclusion, two-dimensional speckle tracking imaging can benefit from employing image processing technology to improve detection precision. When used as a clinical treatment for severe infantile pneumonia and heart failure, milrinone can lower the level of inflammatory factors in children’s bodies. Furthermore, it improved children’s cardiac function, reduced complication rate, and was beneficial to the prognosis of children.