variable length no-refrence filter algorithm
One possible implementation would be to run two (or more) different order filters in parallel, and use a mixer to blend them by ramping the gains up and down depending on your selection criteria.