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!