workspace;
format longg;
format compact;
fontSize = 20;
c = 128;
map = jet(c);
pO2value=double(109);
r = ceil(map(pO2value,1)*c)
g = ceil(map(pO2value,2)*c)
b = ceil(map(pO2value,3)*c)
grayImage = imread('cameraman.tif');
handleToFigure2 = figure;
subplot(2,2,1);
imshow(grayImage);
title('Gray Image', 'FontSize', fontSize);
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
rgbImage = cat(3, grayImage, grayImage, grayImage);
hsv = rgb2hsv(rgbImage);
hsvOfThisPixel = rgb2hsv([r g b])
hsv(:, :, 1) = hsvOfThisPixel(1);
hsv(:, :, 2) = 1;
singleHueRGBImage = uint8(255*hsv2rgb(hsv));
subplot(2, 2, 2);
imshow(singleHueRGBImage);
title('New, Single Hue Color Image', 'FontSize', fontSize);
message = sprintf('Done with demo.');
uiwait(msgbox(message));
Best Answer