function [ResIm , ResIm_OMPonly] = rtt2012(trueIm, Im , Mask , noiseSig, DCTdict)

% Params
param.patchSize = [36 36];
param.noiseSig = noiseSig;
param.errorGoal = 0.04;
param.maxAtoms = 40;
param.nAtoms = 100;
param.IgnoreUnmasked = (noiseSig <= 2);

% Break image to columns (mask as well)
trueimPatches = im2col(trueIm , param.patchSize , 'sliding');
imPatches = im2col(Im , param.patchSize , 'sliding');
maskPatches = im2col(Mask , param.patchSize , 'sliding');

% Run specialized OMP

% Dictionary training param
param.method = 'KSVD';
param.nAtoms = 100; %64

param.nIterations = 10; 
param.useLessAtoms = [0.1 0.1 0.2 0.2 0.4 0.4 0.7 0.7 1 1 1 1 1 1 1];

param.initType = 'RandomPatches'; 
param.initType = 'DCT'; 


% DCTdict = Train_Dictionary(trueimPatches, param);

% DCTdict = Build_DCT_Overcomplete_Dictionary(param.nAtoms , param.patchSize);


resPatches = OMP_Inpaint(DCTdict , imPatches , maskPatches, param);
resPatches=min(max(resPatches,0),255);

% Reconstruct image
ResIm_OMPonly = Average_Overlapping_Patches(resPatches, size(Im) , param.patchSize);

% Set the known pixels to the input values
% This should be used only when the noise is very weak
ResIm = ResIm_OMPonly;
ResIm(Mask) = Im(Mask);

% Finished
return;

