Watch this Author's files
could you please add more comments for each line of code ?
whenever we execute the code 3 images are opened without closing the previous three images,
in order to avoid this you should add this line of code into your file,
imtool close all; % Close all imtool figures.