Imshow(Image,Map) remap pixel intensities
14 views (last 30 days)
Show older comments
Hello,
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
0 Comments
Accepted Answer
Walter Roberson
on 27 Mar 2016
MappedIntensity = MapArray(double(Intensity)+1);
image(MappedIntensity);
colormap(gray(256))
0 Comments
More Answers (1)
Image Analyst
on 27 Mar 2016
Edited: Image Analyst
on 27 Mar 2016
There is a function specially made for this. It's called intlut. It remaps the gray levels according to a look up table (which you called map) just like you want. Here is the code:
remappedImage = intlut(originalGrayImage, map);
However it only works with integers, so for your example you'd have to multiply your map by 2 and then divide the image by 2
remappedImage = intlut(originalGrayImage, uint8(2*map)) / 2;
0 Comments
See Also
Categories
Find more on Image Processing Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!