Converting an indexed image in uint32 to double

2.8k views Asked by At

I read the following in the documentation of im2double

Class Support:

Intensity and truecolor images can be uint8, uint16, double, logical, single**, or int16. Indexed images can be uint8, uint16, double or logical. Binary input images must be logical. The output image is double

I am working on a 64 bit machine (i.e. MATLAB uses 8 bytes to represent variables of type double). I have an indexed image of type uint32 and I believe I should be able to convert it to type double, but im2double doesn't seem to support it, i.e. I get the following error:

Error using im2double Expected input number 1, Image, to be one of these types:

double, logical, uint8, uint16, int16, single

Instead its type was uint32.

So, how can I convert a matrix (an indexed image) of type uint32 to double?

This is all on MATLAB 2012a

1

There are 1 answers

1
Amro On

According to this page (some info here as well):

Indexed (Also known as a pseudocolor image)

Array of class logical, uint8, uint16, single, or double whose pixel values are direct indices into a colormap. The colormap is an m-by-3 array of class double.

For single or double arrays, integer values range from [1, p]. For logical, uint8, or uint16 arrays, values range from [0, p-1].

therefore MATLAB does not support indexed images of class uint32. I guess you'll have to do some sort of color quantization.