%Using REDUCE and EXPAND

I= imread('lena_bw.gif');
figure; imshow(I)

R = Reduce(I, [ 0.05, 0.25, 0.4, 0.25, 0.05]);
Rd = Reduce(I, [ 0.05, 0.25, 0.4, 0.25, 0.05]);

Ri = uint8(Rd);
figure; imshow(Ri)

Ed = Expand(Ri, [ 0.05, 0.25, 0.4, 0.25, 0.05]);
Ei = uint8(Ed);
figure; imshow(Ei)

Ld= double(I) - Ed;

figure; imagesc(Ld)