Imshow(Image,Map) remap pixel intensities
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Walter Roberson
2016-3-27
MappedIntensity = MapArray(double(Intensity)+1);
image(MappedIntensity);
colormap(gray(256))
0 个评论
更多回答(1 个)
Image Analyst
2016-3-27
编辑:Image Analyst
2016-3-27
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 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!