Skip to content

Commit

Permalink
version 1.7.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathanael Perraudin committed Dec 29, 2015
1 parent e4d0863 commit 0f21014
Show file tree
Hide file tree
Showing 9 changed files with 164 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Contents.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
%
%
% For help, bug reports, suggestions etc. please send email to
% unlocbox-help@lists.sourceforge.net
% unlocbox (at) groupes (dot) epfl (dot) ch
%
5 changes: 4 additions & 1 deletion demos/Contents.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
% DEMO_DEQUANTIZATION - Solves a dequantization problem
%
% Other demo
% DEMO_OVERLAPING_GROUPS_STRUCTURED_SPARSITY - Demonstration of the use of overlapping groups in structured sparsity
% DEMO_ADMM - Demonstration of the use of the admm solver
% DEMO_SDMM - Demonstration of the use of the SDMM solver
% DEMO_WEIGHTED_L1 - Demonstration of the use of the bpdn solver
Expand All @@ -30,3 +29,7 @@
% For help, bug reports, suggestions etc. please send email to
% unlocbox (at) groupes (dot) epfl (dot) ch
%



% DEMO_OVERLAPING_GROUPS_STRUCTURED_SPARSITY - Demonstration of the use of overlapping groups in structured sparsity
142 changes: 142 additions & 0 deletions demos/demo_inpainting_webcam.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@

% Author : Nathanaël Perraudin
%
% This demo capture a image with the webcam and perform some inpainting
% with it.

clear;

close all;

init_unlocbox;

%% parameter

scale = 0.5; % scale for the image
imgcolor = 1;
p = 0.8 ;

verbose = 2; % Verbosity level
maxit = 30;

%%

% Close previous cam if3 any
clear('cam')

camList = webcamlist;
% Is there any cam?

if numel(camList)>1
fprintf('Please choose a webcam:\n');
for ii = 1:numel(camList)
fprintf([' ',num2str(ii),') ',camList{ii},'\n'])
end
fprintf('Camera number: ')
prompt = 1;
numCam = str2num(input('','s'));
else
numCam = 1;
end

%% Start the webcam

cam = webcam(numCam);
%% Aquire image

preview(cam);

fprintf('Push a button to aquire image... ')
pause;

% Acquire a single image.
rgbImage = snapshot(cam);
fprintf(' Done! \n')

rgbImage = imresize(rgbImage, scale);
if imgcolor
im_original = double(rgbImage)/256;
else
% Convert RGB to grayscale and rescaling.
grayImage = double(rgb2gray(rgbImage))/256;
% Original image
im_original = grayImage;
end

closePreview(cam)
clear('cam')

%%


%% Creation of the problem



% Creating the problem
A = rand(size(im_original,1),size(im_original,2));
A = A > p;

if imgcolor
A = cat(3,A,A,A);
end

% Depleted image
b = A .* im_original;


imagesc_gray(im_original, 1, 'Original image');
imagesc_gray(b, 2, 'Depleted image');

pause;

%% Defining proximal operators

% Define the prox of f2 see the function proj_B2 for more help
operatorA = @(x) A.*x;
operatorAt = @(x) A.*x;
epsilon2 = 0;
param_proj.epsilon = epsilon2;
param_proj.A = operatorA;
param_proj.At = operatorAt;
param_proj.y = b;
param_proj.verbose = verbose - 1;
f2.prox=@(x,T) proj_b2(x, T, param_proj);
f2.eval=@(x) eps;

f2.prox = @(x,T) (x - A.*x) + A.*b;


% setting the function f1 (norm TV)
param_tv.verbose = verbose - 1;
param_tv.maxit = maxit;

f1.prox = @(x, T) prox_tv(x, T, param_tv);
f1.eval = @(x) sum(norm_tv(x));

%% solving the problem

% setting different parameter for the simulation
paramsolver.verbose = verbose; % display parameter
paramsolver.maxit = maxit; % maximum iteration
paramsolver.tol = 10e-7; % tolerance to stop iterating
paramsolver.gamma = 0.1; % stepsize

% To see the evolution of the reconstruction
fig = figure(100);
paramsolver.do_sol = @(x) plot_image(x,fig,1);

sol = douglas_rachford(b,f1,f2,paramsolver);

close(100);

%% displaying the result
sol(sol<0) = 0;
sol(sol>1) = 1;
imagesc_gray(im_original, 1, 'Original image');
imagesc_gray(b, 2, 'Depleted image');
imagesc_gray(sol, 3, 'Reconstructed image');


%% Closing the toolbox
close_unlocbox();
11 changes: 6 additions & 5 deletions demos/demo_overlaping_groups_structured_sparsity.m
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@

%% Initialisation

error('Not working')
clear;
close all;

Expand Down Expand Up @@ -129,7 +130,7 @@

% setting the function f1 (l1 norm of the Gabor transform)
% set parameters
param_l12.verbose = verbose - 1;
param_l21.verbose = verbose - 1;



Expand Down Expand Up @@ -169,12 +170,12 @@

% -------------------------------------------- %

param_l12.g_t = g_t;
param_l12.g_d = g_d;
param_l12.maxit = 5;
param_l21.g_t = g_t;
param_l21.g_d = g_d;
param_l21.maxit = 5;


f1.prox=@(x, T) prox_l21(x, T*tau, param_l12);
f1.prox=@(x, T) prox_l21(x, T*tau, param_l21);
f1.eval=@(x) tau*norm_l21(x,g_d, g_t);


Expand Down
16 changes: 8 additions & 8 deletions demos/demo_tvdn.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@
%
% .. figure::
%
% First problem
% Measurements
%
%
%
% In painting with 33% of known pixel and a SNR of 30dB
%

% .. figure::
%
% Second problem
% In painting with 33% of known pixel and a SNR of 30dB
%
%
%
% Image reconstruction with 33% of the Fourier measurements and a SNR
% of 30dB.

% Author: Gilles Puy, Nathanael Perraudin
% Date: Nov. 1, 2012
Expand Down Expand Up @@ -72,7 +72,7 @@
sigma_noise = 10^(-input_snr/20)*std(im(:));
y = y + randn(size(y))*sigma_noise;
% Display the downsampled image
imagesc_gray(At(y),2,'Measured image',121);
imagesc_gray(At(y),2,'Measured image');
% Parameters for TVDN
param.verbose = 2; % Print log or not
param.gamma = 0.1; % Stepsize
Expand All @@ -88,7 +88,7 @@
% Solve TVDN problem
sol = solve_tvdn(y, epsilon, A, At, param);
% Show reconstructed image
imagesc_gray(sol, 2, 'Reconstructed image',122);
imagesc_gray(sol, 3, 'Reconstructed image');


% %% Second problem: Reconstruct from 33% of Fourier measurements
Expand Down
2 changes: 1 addition & 1 deletion prox/prox_l12.m
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
%
% See also: prox_l1 prox_linf1 prox_l21 prox_sumg
%
% Demos: demo_compress_sensing3 demo_overlaping_groups_structured_sparsity
% Demos: demo_compress_sensing3
%
% References: bach2011optimization kowalski2013social kowalski2009sparse kowalski2009sparsity
%
Expand Down
4 changes: 1 addition & 3 deletions prox/prox_l21.m
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@
%
% See also: prox_l1 prox_linf1 prox_l12 prox_sumg
%
% Demos: demo_compress_sensing3 demo_overlaping_groups_structured_sparsity
%
% References: bach2011optimization kowalski2013social kowalski2009sparse kowalski2009sparsity

% Author: Nathanael Perraudin
Expand Down Expand Up @@ -226,8 +224,8 @@
G{k}=g;
end

param4 = param;
param4.G=G;
param4.verbose=param.verbose;
sol=prox_sumg(x,gamma,param4);

end
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion unlocbox_version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.7.1
1.7.2

0 comments on commit 0f21014

Please sign in to comment.