1. noise_filter(data, n): /parameter n refers to the packet size/ |
2. length <- length of data |
3. /group data/ |
4. group[ ] <- each group contains n consecutive signals |
5. /filter noise/ |
6. noise_filter_data = [] |
7. for goup_data in the group do |
8. low_num <- the factor with the ranking percentage of B% |
9. high_num <- the factor with the ranking percentage of A% |
10. temp_data = noise_filter_and_replace(goup_data, low_num, high_num) |
11. noise_filter_data.append(tem_data) /Merge all denoised groups/ |
12. return noise_filter_data |
13. |
14. /delete outliers and fill the blank places/ |
15. noise_filter_and_replace(data, low_num, high_num): |
16. /If the noise points exist in the first position or the last position, they need to be processed separately/ |
17. for index <-1 to len(data-1) do |
18. if data[index] is noise point then |
19. Find the nearest two non noise points data[first_weight] and data[second_weight] to the left and right |
20. Calculate the distance x, y to the point |
21. first_weight <- y / (x + y) |
22. second_weight <- x / (x + y) |
23. data[index] <- data[first_weight] first_weight + data[second_weight] second_weight |
24. return data |