0

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

Dev-iL
  • 23,742
  • 7
  • 57
  • 99
M.Sarabi
  • 51
  • 1
  • 9

1 Answers1

1

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));
Dev-iL
  • 23,742
  • 7
  • 57
  • 99