Commit a9acc35e by alexander.dornheim

### Added graphic output for JWST

parent 43e79d32
 # JWST_graphics.m # written on May 23, 2012 by # Russell Luke # Inst. Fuer Numerische und Angewandte Mathematik # Universitaet Gottingen # # # DESCRIPTION: Script driver for viewing results from projection # algorithms on various toy problems # # INPUT: # algorithm = character string for the algorithm used. # true_object = the original image # u_0 = the initial guess # u = the algorithm "fixed point" # change = the norm square of the change in the # iterates # error = squared set distance error at each # iteration # noneg = the norm square of the nonnegativity/support # constraint at each iteration # gap = the norm square of the gap distance, that is # the distance between the projections of the # iterates to the sets # # OUTPUT: graphics # USAGE: JWST_graphics(algorithm_input,algorithm_output) # ############################################################# from matplotlib.pyplot import subplots, show from numpy import real,angle def JWST_graphics(config, output): algorithm=config['algorithm']; if 'beta_0' in config: beta0 = config['beta_0'] beta_max = config['beta_max'] elif config['algorithm'] =='ADMMPlus': beta0=config['stepsize'] beta_max=beta0 else: beta0=1 beta_max=1 u_0 = config['u_0'] u = output['u1'] u2 = output['u2'] iter = output['iter'] change = output['change'] gap = output['gap'] f, ((ax1, ax2), (ax3, ax4)) = subplots(2, 2) im=ax1.imshow(abs(u),cmap='gray') f.colorbar(im, ax=ax1) ax1.set_title('best approximation - physical domain') im = ax2.imshow(abs(u2), cmap='gray') f.colorbar(im, ax=ax2) ax2.set_title('best approximation - Fourier constraint') ax3.semilogy(gap); ax3.set_xlabel('iteration') ax3.set_ylabel('\$||x^{2k+2}-x^{2k}||\$') ax4.semilogy(change); ax4.set_xlabel('iteration') ax4.set_ylabel('\$||x^{2k+1}-x^{2k}||\$') g, ((bx1, bx2), (bx3, bx4)) = subplots(2, 2) im = bx1.imshow(real(u),cmap='gray') f.colorbar(im, ax=bx1) bx1.set_title('best approximation - physical constraint') im = bx2.imshow(angle(u),cmap='gray') f.colorbar(im, ax=bx2) bx2.set_title('best approximation - pysical constraint') im = bx3.imshow(abs(u2),cmap='gray') f.colorbar(im, ax=bx3) bx3.set_title('best approximation - Fourier constraint') im = bx4.imshow(angle(u2),cmap='gray') f.colorbar(im, ax=bx4) bx4.set_title('best approximation phase - Fourier constraint') show(); ''' subplot(2,2,1); imagesc(abs(u)); colormap gray; axis equal tight; colorbar; title('best approximation - physical domain'); drawnow; subplot(2,2,2); imagesc(abs(u2)); colormap gray; axis equal tight; colorbar; title('best approximation - Fourier constraint'); drawnow; #caxis([4.85,5.35]); subplot(2,2,3); semilogy(change),xlabel('iteration'),ylabel(['||x^{2k+2}-x^{2k}||']) label = ['Algorithm: ',algorithm, ', \beta=',num2str(beta0),' to ',num2str(beta_max)]; title(label) subplot(2,2,4); semilogy(gap),xlabel('iteration'),ylabel(['||x^{2k+1}-x^{2k}||']) label = ['Algorithm: ',algorithm, ', \beta=',num2str(beta0),' to ',num2str(beta_max)]; title(label) figure(904), colormap('gray') subplot(2,2,1), imagesc(real(u)), colorbar xlabel('best approximation - physical constraint') label = ['Algorithm: ',algorithm, ', \beta=',num2str(beta0),' to ',num2str(beta_max)]; title(label) subplot(2,2,2); imagesc(angle(u)); colormap gray; axis equal tight; colorbar; title('best approximation phase - physical constraint'); caxis([-0.9 -0.4]); drawnow; #caxis([4.85,5.35]); subplot(2,2,3); imagesc(abs(u2)); colormap gray; axis equal tight; colorbar; title('best approximation - Fourier constraint'); drawnow; #caxis([4.85,5.35]); subplot(2,2,4); imagesc(angle(u2)); colormap gray; axis equal tight; colorbar; title('best approximation phase - Fourier constraint'); caxis([-0.9 -0.4]); drawnow; #caxis([4.85,5.35]); '''
 ... ... @@ -4,6 +4,7 @@ from proxtoolbox.Problems.problems import Problem from proxtoolbox import Algorithms from proxtoolbox import ProxOperators from proxtoolbox.ProxOperators.proxoperators import ProxOperator from proxtoolbox.Problems.Phase.JWST_graphics import JWST_graphics from numpy.linalg import norm from numpy import square, sqrt, nonzero ... ... @@ -196,16 +197,18 @@ class Phase(Problem): """ # algorithm = self.config['algorithm'](self.config) self.u1,self.u2,self.iters,self.change,self.gap = \ self.output = dict(); self.output['u1'],self.output['u2'],self.output['iter'],self.output['change'],self.output['gap'] = \ self.algorithm.run(self.config['u_0'],self.config['TOL'],self.config['MAXIT']) print(self.iters) #print(self.iters) #print(nonzero(self.u1)) #print(self.u1[self.u1.nonzero()]); print(norm(self.u1)); print(self.u1[64,16]); print(norm(self.u2)); print(self.u1[71,46]); #print(norm(self.u1)); #print(self.u1[64,16]); #print(norm(self.u2)); #print(self.u1[71,46]); #print(self.gap); #print(self.change); ... ... @@ -214,6 +217,7 @@ class Phase(Problem): """ Processes the solution and generates the output """ JWST_graphics(self.config,self.output) ... ...
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!