# NOT RUN {
I = lena_crop #use a smaller image as an example
## add noise
sigma=20;m=64
I_noise=AddNoise(I,sigma)
## spliting image into patches
Y_nc = ImageSplit(I_noise,sqrt(m),sqrt(m));
mu=colMeans(Y_nc)
Y=Y_nc-rep(mu,each=nrow(Y_nc))
## learning dictionary
# }
# NOT RUN {
dictionary=gscad.DL(Y,p0=256,sigma=sigma)
# }
# NOT RUN {
I=lena_crop
## corrupt 30% of the image
out_corrupt=AddHoles(I,0.3)
I_corrupt=out_corrupt$corruptedImage
I_mask=out_corrupt$maskImage
## split image
m=64
Y_nc = ImageSplit(I_corrupt,sqrt(m),sqrt(m));
M = ImageSplit(I_mask,sqrt(m),sqrt(m));
mu=colSums(Y_nc*M)/colSums(M)
Y=Y_nc-M*rep(mu,each=nrow(Y_nc))
mask = matrix(as.logical(M),ncol=ncol(M))
## learn dictionary for inpainting, this function is slow
# }
# NOT RUN {
dic=gscad.DLmask(Y, mask, p0=100, sigma=1)
# }
Run the code above in your browser using DataLab