What is the difference between RGB Image and Colormap?
13 ビュー (過去 30 日間)
古いコメントを表示
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?
0 件のコメント
採用された回答
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 件のコメント
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 Exchange で Biomedical Imaging についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!