Updated fast_median from FEX

Signed-off-by: Oleg Komarov <o.komarov11@imperial.ac.uk>
Refactoring selection/filtering

Signed-off-by: Oleg Komarov <o.komarov11@imperial.ac.uk>