imshow in GUI too slow

4 Ansichten (letzte 30 Tage)
curran
curran am 26 Apr. 2012
Hello, I've made a GUI that displays a series of images (250x500, jpg) in a portion (usually 5-10) of 36 existing axes. The axes are in a special pattern (so can not use montage) and sometimes overlapping. I am using IMSHOW to match images with axes (and imshow with blank images to erase the axes). These get updated about every 3-5 seconds, but take 2-3 seconds to display. I would like to make it display as fast as possible.
I've experimented using IMAGESC instead, but it has not sped this up at all. I've tried all three renderers and put direct buffering to no avail.
I read a very old post that reccomended not changing the image on each axis, but rather keeping the image and changing the image data using set(himage, 'CData', newdata) where new data is your MxNx3 uint8. So that I would store the images as a matrix and only update the image data. I tried this but it wouldn't cooperate with how I've written my parent code.
Although I think this may work, it would take a week to reconstruct the parent code. Are there any other methods I can try to avoid this?

Akzeptierte Antwort

Alex Taylor
Alex Taylor am 27 Apr. 2012
If performance is critical, you would do well to refresh the images via setting the 'CData' of each existing image handle rather than taking the performance hit of input parsing in imshow/imagesc and the performance hit of needing to recreate an HG image object each time you want to refresh an image.
If you are using subplot to layout the axes within your figure, you should be aware that subplot returns a handle to the axes being created/accessed.
hAxes = subplot(1,1,1);
hImage = imshow('pout.tif','Parent',hAxes);
Once you have created an HG image in a given axes using imshow, you can now refresh the 'CData' of the image object.
set(hImage,'CData',rand(200,200,3));
Note that if the size of the image data has changed, you will see alignment issues with your axes, there is no management of the position of the axes when you refresh the 'CData'.
This is all there is to what you're trying to do.
  4 Kommentare
Alex Taylor
Alex Taylor am 30 Apr. 2012
Ah, I mixed up Image Analyst's comments about subplot with your original post. My mistake. My original comment still applies, it's just a matter of laying out the figure/axes once and then refreshing the 'CData' as you need to, as you've pointed out.
curran
curran am 3 Mai 2012
Just an update, it increased performance about 12x
Crazy... thanks.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Image Analyst
Image Analyst am 26 Apr. 2012
Have you used the profiler to see that it's imshow that's the bottleneck and not imread or some other code?
  8 Kommentare
curran
curran am 1 Mai 2012
Mmm, sorry no, it wasn't per image, it was for all the entire GUI. I guess I'll live with it.
Image Analyst
Image Analyst am 1 Mai 2012
So was mine. It was for 36 images, not just one image. See where it says "imshow 36" in my message. That means it was called 36 times, just like yours.
You don't have to live with it. Perhaps you just need a newer computer, like mine.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Creating, Deleting, and Querying Graphics Objects finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by