% Video Epitome Example % Demonstrates the computation of the epitome of a video and % reconstruction of a video 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.1 $ $Date: Sept. 30, 2005 $ clear all; load VideoEpitomeExampleData.mat resultsFilename = 'PlantDenoising'; % only look at a portion of the data for a faster demo x = x(1:floor(end/2), floor(end/3):floor(end*2/3), floor(end/3):floor(end*2/3), :); % add noise x = min(max(x + randn(size(x))*0.1, 0), 1); clear M; for i = 1 : size(x, 1) M(i) = im2frame(squeeze(x(i, :, :, :))); end movie2avi(M, [resultsFilename 'Noisy.avi'], 'FPS', 15, 'compression', 'none'); save([resultsFilename 'Noisy.mat'], 'x'); % the size of the epitome and patch size to use eSize = [6 60 45]; patchSize = [2 15 15]; numIterations = 5; % learn the epitome of "x", the noisy video [eMean, eVar] = LearnEpitome(x, eSize, patchSize, numIterations); clear M; for i = 1 : size(eMean, 1) M(i) = im2frame(squeeze(eMean(i, :, :, :))); end movie2avi(M, [resultsFilename 'Epitome.avi'], 'FPS', 1, 'compression', 'none'); save([resultsFilename 'Epitome.mat'], 'eMean', 'eVar', 'patchSize', 'numIterations'); % reconstruct in order to denoise r = EpitomeReconstruct(x, eMean, eVar, patchSize); clear M; for i = 1 : size(r, 1) M(i) = im2frame(squeeze(r(i, :, :, :))); end movie2avi(M, [resultsFilename 'Reconstruction.avi'], 'FPS', 15, 'compression', 'none'); save([resultsFilename 'Reconstruction.mat'], 'r');