I am trying to use the imwrite() function to create and save a .bmp file using a custom colormap, 'myMap'. The colormap contains values between 0 and 1 and is a variable of type double with size [51 3]. My image matrix is of type double and contains values 0 to 1. When I produce this image with imagesc() it comes out fine:
figureimagesc(myImage)axis equalaxis tightcolormap(myMap)
However, when I use imwrite to save it as a .bmp file the image is saved in all one dark grey color:
imwrite(myImage, myMap, 'grid.bmp')
I have tried converting myImage to uint8 format and scaling myMap into [256 3] size, but neither works. What am I doing wrong? Thanks.
Best Answer