Initial checkin for local min/max filter

What if `r == 0`?