What is the difference between RGB Image and Colormap?

13 ビュー (過去 30 日間)
Karthik14590
Karthik14590 2013 年 9 月 21 日
What is the difference between RGB Image and Colormap? Why we need to use [X,map] = imread('trees.tif') in colormap when compared to I = imread('board.tif'); J = rgb2gray(I); in RGB?

採用された回答

Walter Roberson
Walter Roberson 2013 年 9 月 21 日
In an RGB image, each pixel is individually supplied with the information about what its Red, Green, and Blue components are. The image can be painted directly.
In a pseudocolor image, each pixel is a single value which is a color number. The color numbers have no independent meaning: color #8 might be completely different than #7 or #9. The color numbers are references to a table of colors that say what the R, G, B components are for each color number. So two pixels that both have color #8 will be looked up in the same table location, and pixels with color #7 would be looked up in an adjacent table location, but the RGB values for the adjacent entries can be completely different.
pseudocolor is a "Paint By Number" set.
You can make a pseudocolor image look quite different visually by changing the colormap without changing the color numbers.
Color numbers do not themselves have any gray-level information; color numbers are just arbitrary. "I'll take whatever color is behind door #3, Bob." RGB images, on the other hand, directly have all the information needed in order to calculate brightness (gray) level.
  2 件のコメント
Karthik14590
Karthik14590 2013 年 9 月 21 日
Thanks for the Info Walter, I also have a another doubt on this. Suppose If i use the function I = imread('board.tif'); J = rgb2gray(I ) for a Color Map then the MATLAB is showing the following error' Error using rgb2gray>parse_inputs (line 81) MAP must be a m x 3 array '. So, I tried using the function * [X,MAP]=imread('trees.tif'); * and after that it was working. How can I identify a Image whether it's colormap or RGB(May be just by seeing it)?
Walter Roberson
Walter Roberson 2013 年 9 月 21 日
If you have a colormapped image that you want to convert to grayscale then ue
[I, MAP] = imread('board.tif');
J = rgb2gray(I, MAP);
To determine whether an image is RGB or not, test ndims(I) . RGB images will have 3 dimensions, never 2, and size(I,3) (the number of bit planes in the third dimension) will be 3. If you encounter a file that is 3 dimensions and size(I,3) is 4, then it might be a CMYK file, which is possible but not very common in most use. If you encounter a file that is 3 dimensions and size(I,3) is 4 or more, then the file is either multispectral data (such as satellite images), or it is a time series of grayscale images (perhaps a "black and white" animation, or some kinds of medical images such as ultrasound), or it is 3D grayscale images such as MRI. If ndims(I) is 4 and size(I,3) is 3, then the file is probably an RGB movie.
You can always use the two-output form of imread(); if you do that on a file that is RGB to start with, then the colormap will be output as [].

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeBiomedical Imaging についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by