imshow update in realtime, colorbar causing it to slow down

조회 수: 6 (최근 30일)
Shane
Shane 2013년 4월 17일
I am updating a display ~15 times a second using imshow. I want to display the colorbar on the side, but that seems to slow down the displaying greatly, causing other problems.
Here is my code, and how I am doing it. So this code is called multiple times over and over in a loop until the user stops something (it is taking data in from an acquisition card and displaying it). Can I make the colorbar more efficient somehow?
imshow(squeeze(sum( RawData((1:2:7),:,:,2)< ChannelD_Threshold ,1)),[],'Parent',imagePlot1, 'border','tight');
imshow(squeeze(sum( RawData((2:2:8),:,:,2)< ChannelD_Threshold ,1)),[],'Parent',imagePlot2, 'border','tight');
colormap cool
% colorbar('location','southoutside')

채택된 답변

Adam Filion
Adam Filion 2013년 4월 17일
편집: Adam Filion 2013년 4월 17일
You can make visualizations inside of loops more efficient by using handle graphics to update the underlying data rather than recreating the visualization. For example, the following piece of code creates a visualization with imshow, saves the handle to it, retrieves the color data, then sets it to a new value.
im = imread('rice.png');
h = imshow(im);
cd = get(h,'CData');
set(h,'CData',cd/4);
This speeds things up because commands like imshow and plot are doing a lot things behind the scenes that aren't necessary when you're just revisualizing inside of a loop. It can also let you set the colorbar once before the loop and not need to reissue it at every iteration.
imshow(...)
colorbar
for i=...
...
EDIT
Looks like this got covered in more detail in a similar post: http://www.mathworks.com/matlabcentral/answers/65521-make-imshow-more-efficent

추가 답변 (1개)

Shane
Shane 2013년 4월 17일
Yes, I had been doing the set handle for making other things more efficient. I did not think that would make this more efficient, but it did. Thanks.

카테고리

Help CenterFile Exchange에서 Orange에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by