How to efficiently update an image if one matrix element is changed
이전 댓글 표시
I have a matrix in which I change only one element in every iteration of a loop. I want to display that matrix as an image using image or imagesc. What I am doing now is to update the CData property of the image handle so as to refresh the image of the matrix. With several thousands of iterations, it turned out that the bottleneck is the image/imagesc function according to the Profiler. So I thought of changing the color of the tile corresponding to the changed matrix entry. How can I do that? There would be no problem with the colormap since the matrix only contains zeros and ones.
댓글 수: 9
Matt J
2015년 10월 18일
With several thousands of iterations, it turned out that the bottleneck is the image/imagesc function according to the Profiler.
But why is image/imagesc being called repeatedly? Don't you call it just once? You said your updates are done just by altering the CData property.
Jan
2015년 10월 18일
Please post your code. Without seeing the code it is impossible to guess, why image is the bottleneck, although you do not use this command, but the more efficient updating of the CData property only.
Zoltán Csáti
2015년 10월 18일
dpb
2015년 10월 18일
The obvious slowdown in the above is
% Pause between the steps for a while
pause(0.2);
I'd think if you removed that it'd be blindingly fast (so to speak)
Zoltán Csáti
2015년 10월 18일
dpb
2015년 10월 18일
Might try just X'or the positions that change instead of setting the whole array.
Show profiler results for the code actually run
Zoltán Csáti
2015년 10월 18일
Walter Roberson
2015년 10월 18일
If you are using R2014a or earlier, EraseMode 'xor' can be used to potentially speed up drawing. As of R2014b that is no longer an option.
dpb
2015년 10월 18일
Ewwww...that's a bummer, indeed! I'd also not thought of HG2 and latest releases in performance...I understand there is, so far at least, a big dropoff there.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Graphics Object Properties에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!