MATLAB: Potts filter