function vystup = MyMethod(vstup, dim) for I=1:size(vstup,2), for J=1:size(vstup,1), vystup(J,I)=round(MyFilter(vstup, J, I, dim)); end end return function barva = MyFilter(obrazek,py,px,dimenze) side = floor(dimenze/2); lower = -side + (1-rem(dimenze,2)); upper = side; vektor=0; count=0; min_x = max(lower + px, 1); min_y = max(lower + py, 1); max_x = min(upper + px, size(obrazek,2)); max_y = min(upper + py, size(obrazek,1)); for I=min_x:max_x, for J=min_y:max_y, count = count+1; vektor(count) = obrazek(J,I); end end % barva = median(vektor); return