Extremely slow imshow() when using 16-bit images

I'm starting by taking a matrix of data from a DICOM file and making it indexed (so that I can apply a user-specified colormap).
shades = 2^bit_val
grayData = mat2gray(dicomData);
% Limiting to shades-1 to allow for a special mark-up color
indexedData = gray2ind(data, shades-1);
%Then code to calculate cmap with the special color at the end
...
imshow(indexedData, cmap, handles.Axes);
If bit_val is 8, then the code takes 0.01 seconds to display which is fine. However, if bit_val is 16, then it takes nearly a whole second to display.
The primary issue is that I want to be able to quickly/smoothly switch between different slices being displayed.
Is there any way to improve the rendering time?
Edit:
Under Windows, "When a given application intends to output colorized graphics and/or images, it can set their own logical palette, that is, its own private selection of colors (up to 256)."
Perhaps this explains why an 8-bit color map (with only 256 colors) displays faster than a 16-bit color map (with 65536 colors) on Windows.

3 Kommentare

Which platform are you using? I have read that MS Windows is not designed to be able to handle colormaps with more than 256 entries.
How are you timing it?
Christopher
Christopher am 14 Dez. 2012
@Walter: I am, indeed, using Windows. (XP to be precise. Company isn't upgrading to Windows 7 until next year.)
@Sean: With tic and toc.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Sean de Wolski
Sean de Wolski am 12 Dez. 2012
Bearbeitet: Sean de Wolski am 12 Dez. 2012

0 Stimmen

X = uint16(rand(1000)*60000);
t = 0;
figure;ax = axes;
for ii = 1:10
tic;
imshow(X,'parent',ax);
drawnow;
t = t+toc;
cla;
drawnow;
end
disp(t/10);
% 0.0335 on my system
Also Have you seen implay()?
doc implay

4 Kommentare

Christopher
Christopher am 14 Dez. 2012
Bearbeitet: Christopher am 14 Dez. 2012
I'm getting about the same when running that code.
However, with my code, I have:
disp(toc(tstart));
iH = imshow(indexedSlice, [cvalues; highlight], 'Parent', handles.([type 'Axes']));
disp(toc(tstart));
For 8-bit colormaps, this gives:
0.0021
0.0162
For 16-bit colormaps, this gives:
0.0047
0.4363
Yesterday, it was giving 0.9. Maybe something was running in the background.
Image Analyst
Image Analyst am 14 Dez. 2012
You don't need to put tic and toc inside a disp() function.
@Christopher: Put this in a loop (like I did) and run it in a script file. That way you don't get any overhead that may be introduced by the command window.
Christopher
Christopher am 17 Dez. 2012
Bearbeitet: Christopher am 17 Dez. 2012
@Sean: Your script doesn't use an indexed image with a colormap. If I use just a grayscale version of the image with imshow(), it's very fast. However, the slowdown is in adding/applying the colormap.
Could you tell me what you get for:
X = uint16(rand(1000)*60000);
X = mat2gray(X);
X = gray2ind(X, 2^16);
cmap = gray(2^16);
t = 0;
figure;ax = axes;
for ii = 1:10
tic;
imshow(X, cmap,'parent',ax);
drawnow;
t = t+toc;
cla;
drawnow;
end
disp(t/10);
I get an average of 1.75
Edit: I've even tried displaying the indexed image (without the colormap as it was already set) and this doesn't seem to have increased the speed all that much.
Edit2: I noticed this from "help image":
For uint8 and uint16 matrices, color intensities are on the range [0, 255].

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Images finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 12 Dez. 2012

Community Treasure Hunt

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

Start Hunting!

Translated by