linear_filter function

Fit a linear filter over a label matrix