Why the speed of for loop (drawnow) is much slower in R2025a than R2016a?

8 visualizzazioni (ultimi 30 giorni)
Why the speed of for loop (drawnow) is much slower in R2025a than R2016a?
%% Imaging reshape
for m=1:12
for n=1:12
img_index_x = (j) + (n-1)*step;
img_index_y = (i) + (m-1)*step;
if i <step && j <step %step/overscan
img_total(img_index_x,img_index_y)= temp_img(m,n);
else
current_value = img_total(img_index_x, img_index_y);
new_value = temp_img(m,n);
img_total(img_index_x, img_index_y) = max(current_value, new_value);
end
end
end
imagesc(img_total)
drawnow;
end
end
  4 Commenti
DGM
DGM il 4 Ago 2025
It looks like this is a chunk of code that used to be inside two outer loops. I see open scopes, missing variables, and magic numbers of unknown relevance. We have no idea what this does, whether it can be simplified, or why you're so sure that drawnow is the slowest part of four nested loops involving once-used graphics objects.
I'm guessing it's something like this, but I don't know what the intent would be, so I have to assume I'm probably wrong.
inpict = imread('cameraman.tif');
step = 16;
outpict = zeros(size(inpict),class(inpict));
sz = size(inpict,1:2);
for i = 1:step
for j = 1:step
for m = 1:sz(2)/step
for n = 1:sz(1)/step
idxx = (j) + (n-1)*step;
idxy = (i) + (m-1)*step;
if i < step && j < step %step/overscan
outpict(idxx,idxy) = inpict(m,n);
else
current_value = outpict(idxx,idxy);
new_value = inpict(m,n);
outpict(idxx, idxy) = max(current_value, new_value);
end
end
end
imagesc(outpict);
drawnow;
end
end
Image Analyst
Image Analyst il 4 Ago 2025
@Do Hyeon, you know that images are referenced by img_total(row, column), which is img_total(y, x), NOT img_total(x, y), right? Evidently not, because your x is the first coordinate. For a square image it doesn't matter, but just be careful because for a typical rectangular image, it does matter.

Accedi per commentare.

Risposte (1)

the cyclist
the cyclist il 3 Ago 2025
What is your default figure window style (which you can get with the following command)?
get(groot, "defaultFigureWindowStyle")
If, for example, this is "normal" and not "docked", it could be that you are getting a lot more overhead from opening multiple figure windows in R2025a than in prior releases. The default value for this is "docked", but maybe you changed it?

Categorie

Scopri di più su Just for fun in Help Center e File Exchange

Prodotti


Release

R2025a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by