%
% dilate filter
%
close all;
clear all;

% read image
i=imread('noise_1.gif');

% create second image
im = i;

% show image
figure;imshow(i);

% get image size
siz = size(i);

% do dilate using 3x3 matrix
for j=[2:siz(2)-1]
    for k=[2:siz(1)-1]
        med = [i(j-1,k-1),i(j-1,k),i(j-1,k+1), i(j,k-1),i(j,k),i(j,k+1),i(j+1,k-1),i(j+1,k),i(j+1,k+1)];
        im(j,k) = max(med);
    end
end

% display image after dilate
figure;imshow(im);