![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/176851/image.png)
Can anyone please answer why the pixel value changes from about 90 to about 0.23 when I apply ind2rgb function?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Surya Gnyawali
am 25 Jan. 2017
Kommentiert: Surya Gnyawali
am 26 Jan. 2017
% I have true color image (looks gray though because it is ultrasound image). I read the image.
im = imread('c1d7.JPG');
% converted the image into gray,
I = rgb2gray(im);
imshow(im);
% Then ind2rgb
rgbImage = ind2rgb(I, jet(256));
% This leads the value change as in my question from ~90 to ~0.23
What would be the solution?
Thanks
Surya
0 Kommentare
Akzeptierte Antwort
Image Analyst
am 25 Jan. 2017
Try this:
% I have true color image (looks gray though because it is ultrasound image). I read the image.
im = imread('peppers.png');
subplot(2,2,1);
imshow(im);
% Convert the image into gray scale.
I = rgb2gray(im);
subplot(2,2,2);
imshow(I);
% Then ind2rgb
rgbImage = uint8(255 * ind2rgb(I, jet(256)));
subplot(2,2,3);
imshow(rgbImage);
% Set up figure properties:
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
% Get rid of tool bar and pulldown menus that are along top of figure.
set(gcf, 'Toolbar', 'none', 'Menu', 'none');
% Give a name to the title bar.
set(gcf, 'Name', 'Demo by ImageAnalyst', 'NumberTitle', 'Off')
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/176851/image.png)
2 Kommentare
Walter Roberson
am 25 Jan. 2017
I have found that im2uint8 has a slightly different answer than uint8(255*x). I do not recall the details at the moment but I found that im2uint8 was better handling. I think it might have had to do with uint8 rounding so 0 and 255 could result with only half the probability of the other values if you use uint8 naively
Weitere Antworten (1)
Walter Roberson
am 25 Jan. 2017
Color tables used with ind2rgb must have entries in the range 0 to 1, which jet() does have. If you want the uint8 version of the colored image apply im2uint8 to it.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Convert Image Type finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!