Help with efficiency on image overlaying on multi-slice images (GUI)

4 views (last 30 days)
For this project I'm working on, I have a GUI that displays multi-slice images (3D matrices), and via a slider\mouse wheel, scrolls through the different slices and displays one slice at a time.
This part works, but the problem occurs on the next step, when I'm overlaying a map of p-values on top of the original MR scans. To do this, I use the 'subimage' function to show the original scan in grayscale, hold the image, and overlay the p-values (As a 3D matrix of the same size, one slice at a time) with 'imshow' (Set to the 'hot' scale. 'subimage' is used so that I can display two colormaps in one window), where I set values above a certain threshold to be fully transparent via setting the 'AlphaData' property according to a desired pattern.
A short version of the code looks like this:
subimage(handles.img);
hold on;
imh = imshow(handles.pmap,[]); colormap(flipud(hot));
set(imh, 'AlphaData', handles.transparent);
The problem is... it takes several significant seconds (approx. 5) before the next image (comprised of two images) loads, whereas this does not occur when only the original multi-slice image is scrolled through, similar to 'imshow3D' that can be found on the file exchange here.
How can I solve this speed issue? I'm using MATLAB 2012b. Thanks in advance.

Accepted Answer

Walter Roberson
Walter Roberson on 22 Apr 2014
If you set the figure Renderer property to OpenGL before trying with the old code (the one that is currently a decent speed) then does it slow down the same? If it does then the difficulty is in transparency forcing OpenGL. You could cross-check some of that by forcing the renderer to something else with the new code and commenting out setting the alpha.
You should also try
opengl software
to see if software opengl makes a speed difference for you.
  1 Comment
Tom Vizel
Tom Vizel on 22 Apr 2014
Software rendering seems to do the trick, it starts loading both images immediately after scrolling, and after a little scrolling it slows down, but not as slow as hardware rendering. It's still a significant improvement.
Thank you.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!