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

조회 수: 8 (최근 30일)
Do Hyeon
Do Hyeon 2025년 8월 3일
댓글: Image Analyst 2025년 8월 4일
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
DGM
DGM 2025년 8월 4일
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 2025년 8월 4일
@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.

댓글을 달려면 로그인하십시오.

답변 (1개)

the cyclist
the cyclist 2025년 8월 3일
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?

카테고리

Help CenterFile Exchange에서 Just for fun에 대해 자세히 알아보기

제품


릴리스

R2025a

Community Treasure Hunt

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

Start Hunting!

Translated by