Grayscale to Jet image
10 次查看(过去 30 天)
显示 更早的评论
I wrote a simple program where I stacked and put 1024 images in a matrix variable. Now, after some signal processing(hilbert transform) done on them when I am seeing those images, they are shown in grayscale. I need to convert those images to jet colormap to see some different perspective.
What I tried:
- I went to Edit>Colormap but there I see only one option of RGB which is already selected.
- Looked through MATLAB forums and found rgbImage = ind2rgb(grayImage, jet(256)); but when I tried implementing this in my code to show "bz" it gives me error like this:
??? Subscript indices must either be real positive integers or logicals.
Error in ==> ind2rgb at 27
r = zeros(size(a)); r(:) = cm(a,1);
Please help and let me know what can I do to show the image in some different colors like blue and other or preferably JET. I am using MATLAB 2010. Thanks in advance,
Cheers!
1 个评论
Walter Roberson
2017-9-18
Is grayimage in the range 0 to 1 or is it double precision used to store integers 0, 1, etc., or is it double precision used to store integers 1, 2, etc. with 0 not being possible? Or is it uint8() data?
回答(2 个)
Cam Salzberger
2017-9-18
编辑:Cam Salzberger
2017-9-18
Hello Rahul,
The reason "ind2rgb" probably failed is that it's likely a double image. That means that all the values are between 0 and 1, rather than being the necessary integer values as an indexed image would be. You could possibly use "ind2rgb" after first doing im2uint8, if you wanted to go that route.
However, this situation is kind of what imagesc is for, at least in terms of displaying it. If you call imagesc on the image, then set the colormap of the figure to jet, you may get the view you're looking for.
If you're looking to write it out to another image file, you might try my first suggestion.
-Cam
EDIT:
Walter makes a good point. You'd probably want to do im2uint8(I)+1 to put it in the range of [1 256], rather than [0 255], to allow for indexing.
1 个评论
Rahul Thakur
2017-9-18
1 个评论
Walter Roberson
2017-9-19
colormap() to change color maps.
How were you thinking that you would like to convey the complex component as color information?
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Blue 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!