Skip to content

Fix handles #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions textureAnalysis.m
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down
59 changes: 43 additions & 16 deletions textureSynthesis.m
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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];