필터 지우기
필터 지우기

plz tell me how to choose the colormap for converting a grayscale image to rgb

조회 수: 1 (최근 30일)
tawheed jan
tawheed jan 2013년 11월 6일
답변: Image Analyst 2013년 11월 6일
plz tell me how to choose the colormap for converting a grayscale image to rgb.

답변 (2개)

Walter Roberson
Walter Roberson 2013년 11월 6일
Arbitrarily.
IM = rand(64,64); %a grayscale image
image(IM);
colormap(gray(256)); %display it in gray
pause(5)
colormap(copper(256)); %copper colormap
pause(5)
colormap(hot(256)); %hot colormap
  댓글 수: 3
Walter Roberson
Walter Roberson 2013년 11월 6일
Correct. That was example code. And arbitrary colormaps can be created.
Walter Roberson
Walter Roberson 2013년 11월 6일
If you started out with a color image, converted it to grayscale, manipulated that grayscale image, and then want to convert the manipulated image back to the original coloring, then if the manipulation creates any grayscale value that was not already present, then you cannot do the conversion back.
If you converted an image to grayscale, used that grayscale to find a region of interest (ROI), and now want to find the original colors for the pixels within the ROI, then you do not convert the grayscale image back to color: instead you use the ROI to extract pixel values from the RGB image.

댓글을 달려면 로그인하십시오.


Image Analyst
Image Analyst 2013년 11월 6일
You can get a list of predefined colormaps by looking at the colormap function in the help.
someColorMap = winter(256); % Or whatever one you want.
rgbImage = ind2rgb(grayImage, someColorMap);
But you don't need one if you want to create a gray RGB image. Just do:
rgbImage = cat(3, grayImage, grayImage, grayImage);

카테고리

Help CenterFile Exchange에서 Colormaps에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by