A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/scipy/scipy/issues/9873 below:

majority voting filter · Issue #9873 · scipy/scipy · GitHub

ndimage.filters has quite useful filters, but in my opinion one filter could be implemented:
An occurrence based filter, such as a majority filter.

The filter would go over an array, count occurrences within the given window size and take the n-ths most occuring value as an output, e.g.:

arr = [1,1,2,3,4,4,5,6,6,6,7,8,8,8]
res = occurence_filter(arr, size=5, rank=-1,  mode='valid')
# pseudocode
for i in range(len(arr)-size):
    w = arr[i:i+size]
    occurences = count_unique_values(w) # e.g [2:1,3:1,4:1,1:2]
    ranked = occurences[rank] # =1
    res[i] = ranked
    
# res = [1,4,4,4,4,4,6,6,6,6,8]

would it make sense to implement such a filter?
Or is there any other way I can express such an operation that I haven't seen yet?


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4