% Example 9.8
% a)   Original
f=imread('book-text.tif');
imshow(f)
pause

% First part of both opening processes: Erosion 
B=ones(51,1);       % Define structuring element
fe=imerode(f,B);
figure; imshow(fe)  % Show eroded image
pause

% Dilation as part of a standard opening 
fed=imdilate(fe,B);
figure; imshow(fed);    % This is the standard "opened" image
pause

% Alternativ dilation ( reconstruction )
fobr=imreconstruct(fe,f);
figure; imshow(fobr)   % Image "opened by reconstruction
pause

close all