function r = zoomin(I)
% step 1: expand the source image into double size image
[i,j] = size(I); % get size of source image
r = uint8(zeros(i+i+1, j+j+1)); % double size image for the output
for row = 1 : i
for col = 1 : j
r(row+row, col+col) = I(row,col);
end
end
% step 2: set outer fram values
[i,j] = size(r); % get size of output image
for col = 3 : 2 : j-2
r(1, col) = uint8((r(2, col-1)+r(2, col+1))/2);
r(i, col) = uint8((r(i-1, col-1)+r(i-1, col+1))/2);
end
for row = 3 : 2 : i-2
r(row, 1) = uint8((r(row-1,2)+r(row+1, 2))/2);
r(row, j) = uint8((r(row-1, j-1)+r(row+1, j-1))/2);
end
% step 3: scan line by line the X pixels
for row = 3 : 2 : i-2
for col = 3 : 2 : j-2
ABCD = [r(row-1,col-1) r(row-1,col+1) r(row+1,col-1) r(row+1,col+1)];
r(row,col) = uint8(median(ABCD)); % X
end
end
% step 4: scan line by line the Y1 pixels
for row = 2 : 2 : i-1
for col = 3 : 2 : j-2
ABXX = [r(row,col-1) r(row,col+1) r(row-1,col) r(row+1,col)];
r(row,col) = uint8(median(ABXX)); % Y1
end
end
% step 5: scan line by line the Y2 pixels
for row = 3 : 2 : i-2
for col = 2 : 2 : j-1
XXAB = [r(row,col-1) r(row,col+1) r(row-1,col) r(row+1,col)];
r(row,col) = uint8(median(XXAB)); % Y2
end
end
% return 2row-1 x 2col-1 image
r = r(2:i-1, 2:j-1);
return