To explore the utilization of the convolutional neural network (CNN) and wavelet transform in ultrasonic image denoising and the influence of the optimized wavelet threshold function (WTF) algorithm on image denoising, in this exploration, first, the imaging principle of ultrasound images is studied. Due to the limitation of the principle of ultrasound imaging, the inherent speckle noise will seriously affect the quality of ultrasound images. The denoising principle of the WTF based on the wavelet transform is analyzed. Based on the traditional threshold function algorithm, the optimized WTF algorithm is proposed and applied to the simulation experiment of ultrasound images. By comparing quantitatively and qualitatively with the traditional threshold function algorithm, the advantages of the optimized WTF algorithm are analyzed. The results suggest that the image is denoised by the optimized WTF. The mean square error (MSE), peak signal-to-noise ratio (PSNR), and structural similarity index measurement (SSIM) of the images are 20.796 dB, 34.294 dB, and 0.672 dB, respectively. The denoising effect is better than the traditional threshold function. It can denoise the image to the maximum extent without losing the image information. In addition, in this exploration, the optimized function is applied to the actual medical image processing, and the ultrasound images of arteries and kidneys are denoised separately. It is found that the quality of the denoised image is better than that of the original image, and the extraction of effective information is more accurate. In summary, the optimized WTF algorithm can not only remove a lot of noise but also obtain better visual effect. It has important value in assisting doctors in disease diagnosis, so it can be widely applied in clinics.