%f: original image
%radius: size of the structuring element
%iter: number of reconstruction iteration
function f_reconstruct = opening_reconstruction(f,radius,iter)
    %erosion
    se = strel('disk',radius);
    f_erode = imerode(f,se);
    figure;
    imshow(f_erode);

    %reconstruction
    se = strel('disk',1);
    f_reconstruct = f_erode;
    for i = 1:iter
        f_open = imdilate(f_reconstruct,se);
        f_reconstruct = (f_open<f).*f_open + (f_open>=f).*f;
    end
    figure;
    imshow(f_reconstruct);