Permalink
Browse files

moved abstract method applyProx() to abstract basicProx for easier co…

…nversion between Matlab and Octave
  • Loading branch information...
LarsHaalck committed Mar 27, 2017
1 parent 8a77281 commit c29f10e48ffc35bc4f5c0394aa7ec0ca26291407
@@ -23,13 +23,13 @@
% u_2)^2 ) |_1
main = flexBox;
main.params.tryCPP = 1;
main.params.tryCPP = 0; %change, if C++ module is compiled
%add primal vars v_1,v_2
numberU1 = main.addPrimalVar(size(f1));
numberU2 = main.addPrimalVar(size(f2));
%add data-fidelities:
%add data-fidelities:
main.addTerm(L2dataTerm(1,f1),numberU1);
main.addTerm(L2dataTerm(1,f2),numberU2);
@@ -27,7 +27,7 @@
imageBlurred = reshape(concatOp * imageNoisy(:),size(image));
figure(2);imagesc(imageBlurred);axis image;colormap(gray);title('Blurred and Noisy Image')
figure(2);imagesc(real(imageBlurred));axis image;colormap(gray);title('Blurred and Noisy Image')
%% ROF deblurring
main = flexBox;
@@ -46,4 +46,4 @@
%get result
result = main.getPrimal(numberU);
figure(3);imagesc(result);axis image;colormap(gray);title('Deblurred and Denoised Image');
figure(3);imagesc(real(result));axis image;colormap(gray);title('Deblurred and Denoised Image');
@@ -22,7 +22,7 @@
imageBlurred = reshape(blurrOperator * imageNoisy(:),size(image));
figure(2);imagesc(imageBlurred);axis image;colormap(gray);title('Blurred and Noisy Image')
figure(2);imagesc(real(imageBlurred));axis image;colormap(gray);title('Blurred and Noisy Image')
%% ROF deblurring
main = flexBox;
@@ -40,4 +40,4 @@
%get result
result = main.getPrimal(numberU);
figure(3);imagesc(result);axis image;colormap(gray);title('Deblurred and Denoised Image');
figure(3);imagesc(real(result));axis image;colormap(gray);title('Deblurred and Denoised Image');
@@ -10,7 +10,7 @@
image = phantom('Modified Shepp-Logan', sizeImage);
%read MATLAB MRI example
image = im2double(imread('mri.tif'));
%image = im2double(imread('mri.tif'));
%%
%show clean input image
figure(1);imagesc(image);axis image;colormap(gray);title('Input image');
@@ -70,7 +70,7 @@
%number = addPrimalVar(dims)
%adds a primal var of dimensions #dims to FlexBox and returns
%the internal #number
if (isscalar(dims))
dims = [dims,1];
end
@@ -109,7 +109,7 @@
obj.y{end+1} = zeros(term.length{i},1);
obj.yOld{end+1} = zeros(term.length{i},1);
end
end
function showPrimal(obj,number)
@@ -195,7 +195,7 @@ function runAlgorithm(obj,varargin)
if (mod(iteration,obj.params.checkError) == 0)
error = obj.calculateError;
reverseStr = printToCmd( reverseStr,sprintf(['Iteration: #%d : Residual %.',num2str(-log10(obj.params.tol)),'f'],iteration,error) );
reverseStr = printToCmd( reverseStr,sprintf(['Iteration: #%d : Residual %.',num2str(-log10(obj.params.tol)),'f','\n'],iteration,error) );
end
if (obj.params.showPrimals > 0 && mod(iteration,obj.params.showPrimals) == 1)
@@ -1,6 +1,6 @@
% prox for Frobenius norm
% min_y 1/2\|y-x\|_2^2 + \delta_{ \|y\|_F \leq \alpha }
classdef FrobeniusProxDual < handle
classdef FrobeniusProxDual < basicProx
properties
end
@@ -1,5 +1,5 @@
%
classdef HuberDataProxDual < handle
classdef HuberDataProxDual < basicProx
properties
end
@@ -1,4 +1,4 @@
classdef HuberProxDual < handle
classdef HuberProxDual < basicProx
properties
end
@@ -1,4 +1,4 @@
classdef IdentityProxPrimal < handle
classdef IdentityProxPrimal < basicProx
properties
end
@@ -1,5 +1,5 @@
%
classdef KLDataProxDual < handle
classdef KLDataProxDual < basicProx
properties
end
@@ -1,4 +1,4 @@
classdef L1AnisoProxDual < handle
classdef L1AnisoProxDual < basicProx
properties
end
@@ -1,4 +1,4 @@
classdef L1AnisoProxDualShift < handle
classdef L1AnisoProxDualShift < basicProx
properties (Access = public, Abstract = true)
end
@@ -1,6 +1,6 @@
% prox for point-wise projection onto L1 balls
% min_y 1/2\|y-x\|_2^2 + <y,f> + \delta_{ \|y\|_2 \leq \alpha }
classdef L1DataProxDual < handle
classdef L1DataProxDual < basicProx
properties
end
@@ -1,6 +1,6 @@
% prox for point-wise projection onto L2 balls
% min_y 1/2\|y-x\|_2^2 + \delta_{ \|y\|_2 \leq \alpha }
classdef L1IsoProxDual < handle
classdef L1IsoProxDual < basicProx
properties
end
@@ -1,6 +1,6 @@
% prox for point-wise projection onto L2 balls
% min_y 1/2\|y-x\|_2^2 + \delta_{ \|y/\alpha + b\|_2 \leq 1 }
classdef L1IsoProxDualShift < handle
classdef L1IsoProxDualShift < basicProx
properties
end
@@ -1,6 +1,6 @@
% prox for L2 with additional f
% min_y 1/2\|y-x\|_2^2 + <y,f> + \alpha\|y\|_2^2
classdef L2DataProxDual < handle
classdef L2DataProxDual < basicProx
properties
end
@@ -1,4 +1,4 @@
classdef L2proxDual < handle
classdef L2proxDual < basicProx
properties
end
@@ -0,0 +1,8 @@
classdef basicProx < handle
properties
end
methods (Abstract)
applyProx(obj)
end
end
@@ -1,4 +1,4 @@
classdef constraintBoxDualized < handle
classdef constraintBoxDualized < basicProx
properties
minVal
maxVal
@@ -1,4 +1,4 @@
classdef innerProductProxDual < handle
classdef innerProductProxDual < basicProx
properties
end
@@ -1,4 +1,4 @@
classdef labelingProxDual < handle
classdef labelingProxDual < basicProx
properties
end
@@ -130,8 +130,4 @@ function xError(obj,main,dualNumbers,primalNumbers)
end
end
end
methods (Abstract)
applyProx(obj) %abstract method for prox function (see primal dual algorithm)
end
end
@@ -2,7 +2,7 @@
message = strrep(message,'%','%%');
message = strrep(message,'\','\\');
fprintf([reverseStr, message]);
fprintf([num2str(reverseStr), message]);
%find extra chars
%nof_extra = length(strfind(message,'%%'));

0 comments on commit c29f10e

Please sign in to comment.