## 3 Materials and Methods
### Contrast Enhancement of the ROI Using the Fuzzy Stretching Technique  
Endoscopy images exhibit irregular distributions of brightness values for the microvessels and background due to the reflections and shadows that occur during the examination; IPCLs cannot be extracted sometimes due to the low contrast between the objects and background. Therefore, in this study, the contrast of endoscopy images is emphasized/enhanced using a stretching technique. Figure 3: Proposed IPCL feature extraction and measurement process for analysis of magnifying endoscopy images of superficial esophageal squamous cell carcinoma. Among the stretching techniques, fuzzy stretching determines the brightness adjustment rate by calculating the distance between the lowest and highest pixel values based on the average brightness value of the images. Using these brightness adjustment rates, the upper and lower limits of the triangular membership function are calculated to set the membership function of the fuzzy set, which is then applied to the image for contrast stretching [12]. \[X_{m}^{r}=\sum_{i=0}^{255}X_{i}^{r}*\frac{1}{M*N},\ \ X_{m}^{g}=\sum_{i=0}^{255}X_{i}^{g}* \frac{1}{M*N},\ \ X_{m}^{b}=\sum_{i=0}^{255}X_{i}^{b}*\frac{1}{M*N} \tag{8}\]  
In Equation (8), \(X_{i}^{r}\), \(X_{i}^{g}\), and \(X_{i}^{b}\) are the RGB values, and \(M\) and \(N\) are the horizontal and vertical lengths of the image, respectively. The middle brightness values \(X_{m}^{r}\), \(X_{m}^{g}\), and \(X_{m}^{b}\) can be determined by applying Equation (8). \[ \begin{array}{l}D_{max}^{r}=\left|X_{h}^{r}-X_{m}^{r}\right|,\ \ D_{min}^{r}=\left|X_{m}^{r}-X_{l}^{r}\right|\\ D_{max}^{g}=\left|X_{h}^{g}-X_{m}^{g}\right|,\ \ D_{min}^{g}=\left|X_{m}^{g}-X_{l}^{g}\right|\\ D_{max}^{b}=\left|X_{h}^{b}-X_{m}^{b}\right|,\ \ D_{min}^{b}=\left|X_{m}^{b}-X_{l}^{ b}\right|\end{array}  \tag{9}\]  
The distance values of the brightest pixels, \(D_{max}^{r}\), \(D_{max}^{g}\), and \(D_{max}^{b}\), and those of the darkest pixels, \(D_{min}^{r}\), \(D_{min}^{g}\), and \(D_{min}^{b}\), can be calculated from Equation (9) using the middle brightness values, \(X_{m}^{r}\), \(X_{m}^{g}\), and \(X_{m}^{b}\), determined from Equation (8). \[ \begin{array}{l}if\left(X_{m}^{r}>128\right)\ adjustment^{r}=255-X_{m}^{r} \\ else\ if\left(X_{m}^{r}<D_{min}^{r}\right)\ adjustment^{r}=D_{min}^{r}\\ else\ if\left(X_{m}^{r}>D_{max}^{r}\right)\ adjustment^{r}=D_{max}^{r}\\ if\left(X_{m}^{g}>128\right)\ adjustment^{g}=255-X_{m}^{g}\\ else\ if\left(X_{m}^{g}<D_{min}^{g}\right)\ adjustment^{g}=D_{min}^{g}\\ else\ if\left(X_{m}^{g}>D_{max}^{g}\right)\ adjustment^{g}=D_{max}^{g}\\ if\left(X_{m}^{b}>128\right)\ adjustment^{b}=255-X_{m}^{b}\\ else\ if\left(X_{m}^{b}<D_{min}^{b}\right)\ adjustment^{b}=D_{min}^{b}\\ else\ if\left(X_{m}^{b}>D_{max}^{b}\right)\ adjustment^{b}=D_{max}^{b}\\ \end{array}  \tag{10}\]  
The \(D_{min}^{r}\), \(D_{min}^{g}\), \(D_{min}^{b}\), \(D_{max}^{r}\), \(D_{max}^{g}\), and \(D_{max}^{b}\) values determined from Equation (9) are then applied to Equation (10) to determine the brightness adjustment rate (\(adjustment^{r}\), \(adjustment^{g}\), \(adjustment^{b}\)). \[ \begin{array}{l}I_{max}^{r}=X_{m}^{r}+adjustment^{r},\ I_{min}^{r}=X_{m}^{r}-adjustment ^{r}\\ l_{max}^{g}=X_{m}^{g}+adjustment^{g},\ I_{min}^{g}=X_{m}^{g}-adjustment^{g}\\ l_{max}^{b}=X_{m}^{b}+adjustment^{b},\ I_{min}^{b}=X_{m}^{b}-adjustment^{b}\\ \end{array}  \tag{11}\]  
The middle brightness value (\(X_{m}^{r}\), \(X_{m}^{g}\), \(X_{m}^{b}\)) and brightness adjustment rate (\(adjustment^{r}\), \(adjustment^{g}\), \(adjustment^{b}\)) are applied to Equation (11) to determine the maximum brightness value (\(I_{max}^{r}\), \(l_{max}^{g}\), \(l_{max}^{b}\)) and minimum brightness value (\(I_{min}^{r}\), \(l_{min}^{g}\), \(l_{min}^{b}\)).