## 2 Fuzzy Stretching with Trapezoid Membership Function in Image Enhancement  
Fuzzy stretching is performed in the first place to obtain better image enhancement. Image enhancement is a process of converting the visual appearance of the image into a better image compared with the original image. It is usually used as a support for better analysis results [24; 25]. Furthermore, in many cases of such human organ ultrasonography, the area of the target organ is often too dark, meaning that there can be important information loss after binarization, which may affect later object forming processes. This was the motivation for developing a more contrast-sensitive membership function for this ganglion cyst extraction problem. The first step is to compute the average brightness value by using this formula:  
\[x_{m}\ =\ \sum_{i=\ 0}^{255}x_{i}\frac{1}{MN} \tag{1}\]  
where \(M\) and \(N\) denote the width and length of the image. Then, the distances between the brighter area, the darker area and the average area are computed. \[d_{max}\ =\ |x_{h}-x_{m}| \tag{2}\]  
\[d_{min}\ =\ |x_{m}-x_{l}| \tag{3}\]  
where \(x_{h}\) and \(x_{l}\) are the highest and lowest intensity pixel values, respectively. The brightness value is adjusted using the following rule:  
\[ \begin{array}{l}\text{If }(x_{m}>128)\ ad\ =\ 255-x_{m}\\ else\ if\ (x_{m}\leq d_{min})\ ad\ =\ d_{min}\\ else\ if\ (x_{m}\leq d_{max})\ ad\ =\ d_{max}\\ else\ ad\ =\ x_{m}\\ I_{max}\ =\ x_{m}+ad\\ I_{min}\ =\ x_{m}-ad\end{array}  \tag{4}\]  
where \(I_{max}\) and \(I_{min}\) are maximum and minimum intensity, respectively. Then, we designed a trapezoid type of membership function, as shown in Figure 1b. Previously, we used a typical triangle-type function with dynamic control [13], as shown in Figure 1a. However, that stretching algorithm experienced some information loss in the process, so that the cyst object had been underestimated when the background intensity was similar to that of the cyst object. The trapezoid membership function was more robust in cases such as Lumber Sociosis X-ray and Lipoma Ultrasonography [26]. Thus, the membership degree (\(\mu(I)\)) is computed as Equation (5) over the interval [\(I_{min}\), \(I_{max}\)]. In Figure 1b, the red lines denote overlapped membership functions, which are explained in Figure 2, and the membership degree is qualitatively categorized as one of L(low), M(middle), and H(high). \[ \begin{array}{l}I_{mid}\ =\ \frac{I_{max}+I_{min}}{2}\\ I_{mid}\ =\ \frac{I_{mid}+I_{min}}{2}\\ I_{mid}\ =\ \frac{I_{max}+I_{mid}}{2}\end{array}  \tag{5}\]  
Figure 1: Fuzzy membership function for fuzzy brightness stretching. (**a**) Triangle membership function [24], (**b**) trapezoid membership function (proposed). Previously, the upper limit value (\(\beta\)) and the lower limit value (\(\alpha\)) are defined as the highest and lowest \(X_{i}\) among pixels that have higher membership degrees. However, in this proposed trapezoid membership function, we designed an input membership function as shown in Figure 2 where there are decreasing and increasing lower limits (Figure 2a,b) and upper limits that represent the left and right parts of Figure 1b. Figure 3 represents the output function with respect to the membership degree for the lower and upper limits based on the trapezoid structure. In Figure 3, \(W_{min}=I_{min}\), \(W_{mid1}=I_{mid1}\), \(W_{mid2}=I_{mid2}\), \(W_{max}=I_{max}\). Then, we made a set of fuzzy inference rules to decide the final stretched result, as shown in Table 1 where I-U and I-U denote the lower and upper limit parts of the membership function value \(\mu(I)\). W denotes the output value where its qualitative category is shown in Figure 3.  
Then, the final \(\alpha\) and \(\beta\) values are defuzzified by Equation (6) as follows:  
\[\alpha\ =\ \frac{\sum_{i=0}^{mid}u(W_{i})W_{i}}{\sum_{i=0}^{mid}u(W_{i})},\beta\ =\ \frac{\sum_{j=\ mid}^{max}u(W_{j})W_{j}}{\sum_{j=\ mid}^{max}u(W_{j})} \tag{6}\]