What are indexed image?
Ältere Kommentare anzeigen
I read the details for indexed images in the matlab help all i get to know is that the color map and image are directly mapped 1 to 1 but what`s the use of indexed image. What is the purpose of color map ? And the figure in the matlab help what does 5 mean? please guide in detail someone

3 Kommentare
Image Analyst
am 28 Jul. 2015
Did you really find that in the MATLAB help? If so, what version. I can't find it in R2015a for the help for colormap. Perhaps they corrected that error. If not, I'll have a talk with them. See this demo:
m = uint8(randi([0, 6], 10,8))
colors = [0,0,0; % 0=black
1,0,0; % 1 = red
0,1,0; % 2 = green
0,0,1; % 3 = blue
1,1,0; % 4 = yellow in row 5
1,0,1; % 5 = magenta in row6
0,1,1] % 6 = cyan
imshow(m, [], 'InitialMagnification', 800)
axis on;
colormap(colors)
colorbar;
% 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')
The important thing to note is that the color that a 5 gets mapped into from row 6 of the colormap, not row 5 like that says. Because row 1 is for gray level 0, row 2 is for gray level 1, row 3 is for gray level 2, row 4 is for gray level 3, row 5 is for gray level 4, and row 6 (not row 5) is for gray level 5. Hopefully they've fixed that but I'd like to know where in the help you got that from.
aamir shabbir hussain
am 30 Jul. 2015
Antworten (3)
Guillaume
am 27 Jul. 2015
2 Stimmen
There are two different reasons why you'd use an indexed image.
1) if the numbers of different colours in your image is fairly low, then an indexed image uses less memory / disk space than a coloured image. That's because encoding colour takes three times as much space as encoding an index. For example, a 500 x 500 indexed image with 256 8-bit colours takes: 500*500*1 (indexed image) + 256*3 (palette) bytes = 25 kb, whereas the same encoded as an rgb image takes 500*500*3 = 75kb. If you reduce the number of colours to less than 256, then the advantage of indexing the image is even greater.
2) You actually don't really care what the colours are as long as they are different. For example, imagine your image consist of three shapes. You just want to say that the triangle is colour 1, the circle colour 2, and the square colour 3 (background is 0). So you store these indices in the image, and alongside you store a colour palette where 0 is black, 1 is red, 2 is blue and 3 is green. Later on, you can just change the mapping by editing the colour palette without touching the image itself. For example set the square to pink by just change the colour of index 3 in the palette.
The "colormap" is a list of colors. The colors are store in the "rgb-format", which means one value between 0 and 1 per red, green and blue channel. Therefore the color table has 3 columns.
The 5 means, that the corresponding pixel has the fifth color of the colormap: it is the fifth line.
aamir shabbir hussain
am 28 Jul. 2015
0 Stimmen
2 Kommentare
Walter Roberson
am 28 Jul. 2015
numcolors = 20; %for example
[X,map] = rgb2ind(TheRGBArray, numcolors);
This will pick the 20 most representative colors -- the ones leading to the smallest difference in color between actual color and represented color.
If you want to create a colormap with one entry for every unique R, G, B combination, then
M = reshape(TheRGBArray, [], 3);
[map, ~, ind_vect] = unique(M, 'rows');
X = reshape(ind_vect, size(TheRGBArray,1), []);
This does have some uses, but it will not usually save memory unless there are fewer than about 64 distinct R, G, B combinations in the image.
Image Analyst
am 28 Jul. 2015
aamir, can you tell me why you'd want to do that? Why not just deal with the original RGB image? What good does an indexed image do you? You're throwing away information to be able to use a pseudocolor look up table, but why? That won't help you find, segment, or classify anything. If you just want to color certain things you found in the image you can use normal segmentation methods and use an overlay or assignment or outlines to indicate the region(s) you found.
Kategorien
Mehr zu Image Arithmetic finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!