## 3 Improved TSETMF Algorithm
### Improved Self-Adaptive Median Filter  
A median filter is a common image denoising method [50] used to eliminate isolated noise by utilizing the median of each pixel value in the neighborhood area to replace the targeted pixel point. This may allow the neighborhood pixel values to be more appropriate and also enable the image detail and marginal information to be retained. Salt and pepper noise can be denoised using the median filter to acquire a satisfactory filtering effect and image edge feature [51; 52]. After median filtering occurs, the image pixel value \(f(x,y)\) at the coordinates \((x,y)\) can be expressed as:  
\[f(x,y)=median(l(x+i,y+j)) \tag{5}\]  
where \(l(x+i,y+j)\) is the neighborhood pixel values relative to the centered pixel point (\(x\), \(y\)) and \(median()\) represents the median selection of the neighborhood pixel values. During the denoising process, a two-dimensional 3 \(\times\) 3 window can be employed to filter the image. Compared with the sizes of the pixel values within a certain range, a median can be selected as the new center pixel. However, the same local window size can result in conflicts between the protection of the image detail and noise elimination [53]; thus, a modified filtering method can be applied, such as the weighted median filter [54; 55] or self-adaptive median filter [56]. As the weighted median filter can conduct fuzzy processing of an image, it may lose some of the image detail during the filtering of high-density noise. However, the self-adaptive median filter can select a window size that fits different noise levels, thus achieving denoising coupled with image detail protection. Moreover, the major density of salt and pepper noise can be filtered by the self-adaptive median filter to acquire clearer images [57]. Thus, the self-adaptive median filter can be utilized to change the window size according to the pixel values for different areas. In Figure 1, denoising principle comparisons for the improved self-adaptive median filter are presented to demonstrate the effects of this more effective filtering method. Figure 1c,d represent the processing step of central pixel value ranking and replacement by adopting the self-adaptive median filter and the improved self-adaptive median filter, respectively. The improved self-adaptive median filter can be compared to the original filter to demonstrate the denoising advantage. In the self-adaptive median filtering algorithm, the processed pixel will be not employed in the following ranking, guaranteeing the independence and stability of the filtering process; however, when the noise density becomes higher, the ranked median value may be turned into a noise value. This may result in poor denoising effects, as seen in Figure 1a,b. During the partial area processing shown in Figure 1b, pixels 0 and 255 may be regarded as noise. In a 5 \(\times\) 5 window, the pending pixel value in a random area is 255 and, then, the ranked pixel values are 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 127, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, and 255. Thus, the replaced central pixel value is still 255 when adopting the middle value, as seen in Figure 1c. The replaced pixel is still the noise, which may also lead to poor denoising effects. This may be interpreted by the effects of the larger-density salt and pepper noise that turn the ranked pixel values into noise values. Moreover, each ranked and replaced central pixel value can be realized based on the original noise image and will be not applied in the next processing step. For the sake of addressing this problem, the self-adaptive median filter can be improved by utilizing the recursion method combined with a self-adaptive window. The basic principle adopts the recursion concept to filter an image. After selecting an appropriate filtering window, the median value can be regarded as the new current pixel value by comparing the current pixel value with the neighboring pixel values.