MATLAB: Imshow(Image,Map) remap pixel intensities


I have an image and a map which is a column vector with 256 rows. Each row says what the new pixel value should be for example below.
row – pixel intensity
1 – 0
2 – 0.5
3 – 1
So for the above, a pixel with intensity 0 should get mapped to 0 and pixel intensity of 1 should get mapped to 0.5 because matlab indexing starts from 1. I tried using matlab function imshow(image,map) but it does not work. Help please

Best Answer

MappedIntensity = MapArray(double(Intensity)+1);