It took a couple of hours of digging through the docs, but I finally figured out what the difference is. This comes from the documentation for the image
function, which is eventually called after a call to imshow
:
Double-Precision Data (double Array):
Image is stored as a two-dimensional (m-by-n) array of integers in the range [1, length(colormap)]; colormap is an m-by-3 array of floating-point values in the range [0, 1].
8-Bit Data (uint8 Array) 16-Bit Data (uint16 Array):
Image is stored as a two-dimensional (m-by-n) array of integers in the range [0, 255] (uint8) or [0, 65535] (uint16); colormap is an m-by-3 array of floating-point values in the range [0, 1].
So the answer is that the uint8 data is expected to be in the range [0, 255], while the double data is expected to be in the range [1, 256]. I was able to confirm this by trying this:
[imdata, immap] = imread('ostrich.png');
imhandle = imshow(1+double(imdata),immap);
Matlab infers from the datatype how it should index the colormap. It happens to be different for uint8 vs. double, and that is why you saw the strange behavior.