## 3 Improved TSETMF Algorithm
### TSETMF Process  
According to the above-mentioned design concept, the design process of the improved TSETMF algorithm can be described as follows. Figure 2 shows a flow chart of the proposed TSETMF algorithm. The relevant steps of the improved median filter using two-dimensional maximum Shannon entropy for use with high-noise grayscale images are as follows:  
Step 1: Input a noise image \(N\) = (\(N(m,n)\)), composed by pixel \(N(m,n)\);  
Step 2: Acquire the gray-level histogram and judge the contrast ratio;  
Step 3: Filter, including five substeps;  
Substep 3.1: Set a filter window to \(3\times 3\). A threshold value \(T\) can be calculated using the two-dimensional maximum Shannon entropy threshold value method, where the entropy threshold \(T_{K}\) = \(T\), \(T\) = \(\arg\min\limits_{0<t<L-1}\left|H_{0}(s,t)-H_{1}(s,t)\right|^{2}\), and the initial \(K\) value is 0, \(K\) = \(K+1\) (\(K\) represents the number of threshold values \(T\));  
Substep 3.2: Calculate the sum of the pixel difference \(D_{1}\) = \(sum\left|a_{\bar{y}}-a_{22}\right|\). If \(D_{1}/9<T_{K}\), \(a_{22}\) is non-noise, move the filter window to the next pixel point and return to Substep 3.1;  
Substep 3.3: Otherwise, carry out the next step;  
Substep 3.4: Adjust the filter window to \(5\times 5\), update the entropy threshold \(T_{K}\), \(K\) = \(K\) + 1, and calculate \(D_{2}\) = \(sum\left|b_{\bar{y}}-b_{33}\right|\). If \(D_{2}/25<T_{K}\), b\({}_{33}\) is non-noise and, therefore, the filter window can be moved to the next pixel point. Return to Substep 3.1;  
Substep 3.5: Otherwise, replace b\({}_{33}\) by utilizing the median and, then, reserve and deliver the replaced value to conduct the next filtering step based on the recursion method. Move the filter window to the next pixel point and return to Substep 3.1;  
Step 4: The filter window traverses the whole image and finishes filtering;By analyzing the framework of the improved TSETMF, the two-dimensional maximum Shannon entropy of the inputted image can be calculated to reflect the abundant information degree in different zones of the image. Based on the computation results of the two-dimensional maximum Shannon entropy, it can be confirmed that the threshold values fit with the local areas of the image. Afterward, the image can be divided into different-sized windows according to the comparisons between the calculated threshold value and the pixel difference mean value. Here, 3 \(\times\) 3 and 5 \(\times\) 5 windows can be selected to judge the noise and, then, a median replacement can be conducted using the 5 \(\times\) 5 window. The replaced value can be reserved and delivered using the recursion method for application in the next filtering process calculations. Therefore, the improved TSETMF can more effectively fit the noise level in different zones, thus enhancing the filtering effects of high-density-noise images. Furthermore, it should be pointed out that window size selection may affect the noise judgment accuracy and median replacement effect of the algorithm. As for noise judgment, the image's local details may be judged as noise by mistake in a 3 \(\times\) 3 window; thus, a 5 \(\times\) 5 window can be selected to identify noise and non-noise values more accurately when considering more image information. As for median replacement, the ranked median values are likely to remain as noise in a 3 \(\times\) 3 window; thus, a 5 \(\times\) 5 window can be selected to conduct ranking and median replacement to increase the non-noise probability while processing high-density salt and pepper noise. Additionally, the computational effort may increase if a larger window size is selected. As a result, better denoising effects can be realized by adopting the appropriate window size to filter high-density salt and pepper noise in the improved TSETMF algorithm. Figure 2: Flow chart of the proposed TSETMF algorithm process.