Refer to rank filters from morphology functions

WT...

min here was correct, but min for dilation wrong... should be fixed now...