Step 1) A 2-D window “Sxy ” of size 3*3 is selected. Assume the pixel to be processed is P(X, Y).
Step 2) The pixel values inside the window are sorted, and Pmin, Pmax, and Pmed are determined as follows.
- The entire matrix of an window is are arranged in ascending order with the u-sort.
- The total elements are been considered in Pmin, Pmax, and Pmed with U-sort.
Case 1) The P(X,Y) is an uncorrupted pixel if Pmin<P(X,Y)<Pmax,Pmin>0, and Pmax<255; the pixel being processed is left unchanged. Otherwise, P(X,Y) is a corrupted pixel.
Case 2) If P(X,Y) is a corrupted pixel, it is replaced by its median value if and .
Case 3) If is not satisfied or , then is a noisy pixel. In this case, the P(X,Y) is replaced by the value of neighborhood pixel value.
Step 4) Steps 1 to 3 are repeated until the processing is completed for the entire image.
Step 5) Here we count the number of times that each number repeats in the given input value.