% Image Epitome Example % Demonstrates the computation of the epitome of an image and % reconstruction of an image from its epitome within the context of % denoising. % % See also LearnEpitome, EpitomeReconstruct % Reference: % % 1. V. Cheung, B. J. Frey, and N. Jojic. Video epitomes. In Proc. % IEEE Conf. Computer Vision and Pattern Recognition (CVPR), 2005. % % 2. N. Jojic, B. J. Frey, and A. Kannan. Epitomic analysis of appearance % and shape. In Proc. IEEE Conf. Computer Vision (ICCV), 2003. % Copyright (C) 2005 Vincent Cheung (vincent@psi.toronto.edu, http://www.psi.toronto.edu/~vincent/) % % This program is free software; you can redistribute it and/or % modify it under the terms of the GNU General Public License % as published by the Free Software Foundation; either version 2 % of the License, or (at your option) any later version. % % This program is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. % % $Revision: 0.9 $ $Date: Sept. 30, 2005 $ clear all; % read in an image x = double(imread('128 Dog.png'))/255; % the filename of the results resultsFilename = 'DogDenoising'; % add noise x = min(max(x + randn(size(x))*0.1, 0), 1); figure, imagesc(x), title('Noisy'); imwrite(x, [resultsFilename 'Noisy.png']); save([resultsFilename 'Noisy.mat'], 'x'); % the size of the epitome and patch sizes eSize = [50 50]; patchSize = [8 8]; numIterations = 10; % learn the epitome [eMean, eVar] = LearnEpitome(x, eSize, patchSize, numIterations); figure, imagesc(eMean), title('Epitome'); imwrite(eMean, [resultsFilename 'Epitome.png']); save([resultsFilename 'Epitome.mat'], 'eMean', 'eVar', 'patchSize', 'numIterations'); % reconstruct from the epitome r = EpitomeReconstruct(x, eMean, eVar, patchSize); figure, imagesc(r), title('Denoised'); imwrite(r, [resultsFilename 'Reconstruction.png']); save([resultsFilename 'Reconstruction.mat'], 'r');