, , 2D-. , . : , , , , . , 3 x 3, , imfilter conv2, . , , 1 , , conv2. (yuck), ( ), , , 2, , 4.
, :
n = 500;
Mat_new = rand(n);
error = 1;
h = [0 1 0; 1 0 1; 0 1 0]; % // Define filter here
while error > 0.000001
Mat_Old = Mat_new;
Mat_new = conv2(Mat_Old, h, 'valid');
Mat_new = abs(Mat_new + 2) / 4; %//Take the output, add 2, absolute then divide by 4
%// Pad border with zeroes
Mat_new = padarray(Mat_new, [1 1]);
error = max(abs(Mat_Old(:) - Mat_new(:))); %// Calculate maximum error
end
, , for. , conv2. Mat_new , , for. , abs 2 , 4. , padarray. , error, max. , .
, while ( ...) . . - .... while. , for , .
, , , !