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]
?
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));