I think it's arguable that the purpose of imagesc() involves the handling of arbitrarily-scaled data as images. On that assumption, there's no reason to expect that the working image/data will be suitable to be treated as an indexed image directly. Similarly, there's nothing about the transformation which would perform the colormapping based on the data extrema. Contrary to the goal of emulating imagesc() with its 'scaled' CDataMapping, using ind2rgb() is akin to using image() with its default 'direct' CDataMapping.
If you want to emulate the behavior of imagesc(), you would need to normalize and quantize your image/data according to the following expectations:
- the mapping corresponds to image extrema (this satisfies the 'scaled' CDataMapping)
- the quantization corresponds to the length of the colormap (necessary treated as an indexed image)
Consider the example:
inpict = imread('pout.tif');
inrange = imrange(inpict)
outpict = ind2rgb(inpict,CT);
outpict = gray2ind(mat2gray(inpict),nlevels);
outpict = ind2rgb(outpict,CT);