In this project, algorithm-based image processing methods in 3D endoscopic image processing endoscopic retrograde cholangiopancreatography (ERCP) were analyzed. To enhance local information of images, an adaptive histogram equalization method with limited contrast is introduced. The influences of the algorithm on 3D endoscopic image peak signal-to-noise ratio (PSNR), image discrete information entropy (DE), and average mean brightness error (AMBE) of images before and after the optimization before were compared. A total of 92 patients receiving ERCP at Yuhuangding Hospital between December 2019 and December 2021 were selected and divided into the control group (fentanyl+propofol) and the observation group (remimazolam benzenesulfonate+esketamine). Mean arterial pressure heart rate (HR), oxygen saturation (SpO2), and respiratory rate (RR) of the patients at each time point including the entry into the operation room (T0), 2 minutes after the beginning of medication (T1), after endoscopy (T2), endoscopy withdrawal (T3), and postoperative awakening (T4) were recorded. The comparison of MAP between T1, T2, T3, and T4 and T0 among patients in the observation group and the control group showed statistical differences (
P
<
0.05
). Besides, HR and RR at T4 in the observation group were obviously higher than those in the control group (
P
<
0.05
). The comparison of SpO2 at T3 and T4 and that at T0 both showed statistical differences (
P
<
0.05
). Awakening time and VAS scores in the observation group were obviously lower than those in the control group (
P
<
0.05
). The incidence of bradycardia, nausea, vomiting, and chill in the observation group was all lower than that in the control group (
P
<
0.05
). The results indicated that an effective endoscopic image processing method was established based on an image enhancement algorithm, and the combination of remimazolam benzenesulfonate and esketamine showed high safety and efficacy in ERCP.