Grayscale to Jet image
12 ビュー (過去 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 件のコメント
Walter Roberson
2017 年 9 月 18 日
ind2rgb knows about data types to know whether to add 1 automatically
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!