% edge_template.m
% template for edge detection exploratory problem

rng(0)
nx = 62; ny = 50;

p = 0.004;
hh = ones(9,7) / sqrt(p*(1-p));
ss_tmp = (rand(nx,ny) < p) - p;
ss = conv2(ss_tmp, hh, 'same');

yy = ss + 5 * randn(size(ss));

clf, pl = @(i) subplot(330 + i);

pl(1), imagesc(1:nx,1:ny,ss'), axis xy, axis image
xlabel n, ylabel m, title 'True: s[n,m]'

pl(3), imagesc(1:nx,1:ny,yy'), axis xy, axis image
xlabel n, ylabel m, title 'Noisy: y[n,m]'

s_hat = npls_sps(yy);

pl(9)
imagesc(1:nx, 1:ny, s_hat'), axis xy, axis image
xlabel n, ylabel m, title 'NPLS output: s.hat[n,m]'

colormap(gray(256))
