Convert indexed image colormap to uint8

331 views Asked by At

I'm trying to read colormap of an image using this code:

[X, map] = imread('D:\Eye.png');

But map is rescaled to [0,1] type double. How can I get the colormap in uint8 range [0,255]?

1

There are 1 answers

0
Dev-iL On BEST ANSWER

This can be solved by simply rescaling map and casting it to uint8:

uint8(255*map);

Optionally, you can round it before casting (the default rounding scheme, as above, is floor):

uint8(round(255*map));