From 8df2e5ee56c2ddac3a8d1153346b6457d71f81fa Mon Sep 17 00:00:00 2001 From: Daniel Sperka Date: Tue, 15 Apr 2025 14:39:51 -0700 Subject: [PATCH 1/2] Variable DoFigUpdates can be set to 0 so this script does not create any figures. --- textureAnalysis.m | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/textureAnalysis.m b/textureAnalysis.m index 26d3fa8..6e13605 100644 --- a/textureAnalysis.m +++ b/textureAnalysis.m @@ -28,6 +28,7 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Warn = 0; % Set to 1 if you want to see warning messages +DoFigUpdates = 0; % Set to 0 so no figures are created %% Check required args are passed if (nargin < 4) @@ -84,9 +85,11 @@ rpyr0 = real(pyr0); apyr0 = abs(pyr0); -figure(gcf) -clf -showIm(im0,'auto',1); title('Original'); drawnow +if DoFigUpdates + figure(gcf) + clf + showIm(im0,'auto',1); title('Original'); drawnow +end %% Subtract mean of magnitude: magMeans0 = zeros(size(pind0,1), 1); From f050eb2897f6d6b62a165f6594a7837c69c03452 Mon Sep 17 00:00:00 2001 From: Daniel Sperka Date: Tue, 15 Apr 2025 14:44:05 -0700 Subject: [PATCH 2/2] Version 2014b changed graphics system, this script modified to handle plotting correctly in earlier and later versions. Add DoFigUpdates variable: set to 0 for no figure updates during this script (otherwise you cannot use your desktop while this is running. Clean up figures when all done. --- textureSynthesis.m | 59 +++++++++++++++++++++++++++++++++------------- 1 file changed, 43 insertions(+), 16 deletions(-) diff --git a/textureSynthesis.m b/textureSynthesis.m index 378fbfe..dc7960a 100644 --- a/textureSynthesis.m +++ b/textureSynthesis.m @@ -41,6 +41,7 @@ % All rights reserved. Warn = 0; % Set to 1 if you want to see warning messages +DoFigUpdates = 0; % set to 0 if you don't want all the figure updates. %% Check required args are passed: if (nargin < 2) @@ -117,17 +118,36 @@ end end -imf = max(1,gcf-1); snrf = imf+1; -figure(imf); clf -subplot(1,2,1); grayRange = showIm(im,'auto',1); title('Starting image'); -drawnow -prev_im=im; - -imf = max(1,gcf-1); -figure(imf); -clf;showIm(im,'auto',1); title(sprintf('iteration 0')); +% Prior to 2014b (version 8.4), graphic handles were numeric, and one could +% do math with them. In 2014b the matlab graphics system changed +% significantly, and amongst other things, graphic handles (e.g. what is +% returned from gcf() or figure()) are objects, and the old math tricks +% don't work any more. In more recent versions, it seems that matlab has +% preserved a 'Number' property for figures, and it seems to work similarly +% to the old numeric handles. I preserved the handle 'math logic' here, +% simply doing it differently for later versions of matlab. + +if DoFigUpdates + if verLessThan('matlab','8.4') + % -- Code to run in MATLAB R2014a and earlier here -- + imf = max(1,gcf-1); snrf = imf+1; + figure(imf); clf + subplot(1,2,1); grayRange = showIm(im,'auto',1); title('Starting image'); + drawnow + + imf = max(1,gcf-1); + figure(imf); + clf;showIm(im,'auto',1); title(sprintf('iteration 0')); + else + % -- Code to run in MATLAB R2014b and later here -- + imf = figure; + % the figure drawn here in original version is overwritten in the first + % loop below, so I leave it empty for now. + end +end +prev_im=im; nq = 0; Nq = floor(log2(Niter)); imS = zeros(Ny,Nx,Nq); @@ -387,13 +407,15 @@ tmp = prev_im; prev_im=im; - figure(imf); - subplot(1,2,1); - showIm(im-tmp,'auto',1); title('Change'); - subplot(1,2,2); - showIm(im,'auto',1); title(sprintf('iteration %d/%d',niter,Niter)); - drawnow - + if DoFigUpdates + figure(imf); + subplot(1,2,1); + showIm(im-tmp,'auto',1); title('Change'); + subplot(1,2,2); + showIm(im,'auto',1); title(sprintf('iteration %d/%d',niter,Niter)); + drawnow + end + % accelerator alpha = 0.8; im = im + alpha*(im - tmp); @@ -431,6 +453,11 @@ end %END MAIN LOOP +%djs clean up +if DoFigUpdates + close(imf); +end + im = prev_im; snrP = [snr7 snr2 snr1 snr3 snr4 snr4r snr6];