CSE 232 Spring 2003 Notes on the color table and 7/12/2016

advertisement
CSE 232 Spring 2003
Notes on the color table and
indexed color concept
7/12/2016
Stockman CSE/MSU S03
General idea





Images can consume a large amount of
storage space – in main or disk memory
Gray scale or labeled image needs only small
integer pixels ([0, 255] range is good)
RGB color image can be 3X as large
Can use a color table to convert an integer
label L to color code R[L], G[L], B[L]
Just need to make a “table” so that color
codes can be obtained using index L
7/12/2016
Stockman CSE/MSU S03
Color table: cheaper graphics


512 x 512 RGB image with 3x8-bit color
values requires 750K Bytes.
512 x 512 8-bit codes = 256K Bytes
+ 256 x 3x8-bit color table =257K Bytes
7/12/2016
Stockman CSE/MSU S03

image has 8bit pixels
each 8-bit
number is an
index into a
color look up
table
can change
colors without
changing
image
Color Table concept
int pixel
image (P2)
Color
table
RGB pixel
image (P3)
7/12/2016
Stockman CSE/MSU S03
GIF image format =
image+table (plus other stuff)







7/12/2016
header information
color table
image pixels (up to 8 bits each) LZW compressed
RGB data is stored in the color table and NOT in
the image pixels themselves
get good compression and ability to quickly
change the colors
there are only 256 different colors for any single
image, but table RGB triples can be changed
gif files are very good for line drawings
Stockman CSE/MSU S03
ColorTable ADT



model is an ADT array of up to 256
colors
array index is an int in [0, 255], which
we’ll call a “pseudo color” or “color
index”
operations are create, destroy, add
new entry, (see P2 specs for others)
7/12/2016
Stockman CSE/MSU S03
Types of compression




Lossless: no information is lost; every bit of the original
image can be recovered.
if an image has no more than 256 different color triples
in it, then color table can exactly recreate it.
Lossy: information is approximated; the original image
cannot be recovered exactly.
Suppose there are 1000 color triples in the original
image but we replace each by the closest one of a set of
256 triples in color table;
e.g. (218, 58, 150)  (220, 60, 150)
7/12/2016
Stockman CSE/MSU S03
Download