Tuesday, November 15, 2011

Indexed color images



After RGB images, indexed color images are another way to display/work with colors in ImageJ.




1- Indexed color image via a LookUp Table (LUT)

A gray-level image can be displayed as a color image. I say "displayed" and not transformed because the pixel values aren't modified. This is possible thanks to the use of a color table called lookup table (LUT) in ImageJ. Each pixel value (from 0 to 255) points to an indexed color table containing a R, G, and B values.
 The LUTs are available in Image > Lookup Tables.



In Fig.1, the 'Fire' LUT was used to display the clown (previously converted in 8-bit) with a gradient of blue and yellow. For example, all the pixel values with a gray level of 200 are displayed as a RGB color of (255,217,0) as shown in the table Results containing the LUT triplets.

Fig.1: Gray-level image displayed with the lookup table 'Fire'.

Note: To print the LUT (R,G,B) triplets in the table Results in Fig. 1, I use this script.

2- 8-bit color images

A 8-bit color image is similar to an indexed image, because this is a gray-level image where each pixel value corresponds to an index of a lookup table. Thus, only the appearance of the image is in color, the low-level pixel values are single values (equivalent to gray levels). In this case, the LUT is specifically calculated from the pixel values distribution of the original image.

Fig. 2 : 8-bit color indexed image. Each pixel value is an index corresponding to an entry in a color table. Here, the pixel (110,78) contains the value 48 (an index) corresponding to the RGB color (123,79,54).
Why using 8-bit color image?
When the number of colors used in an image is rather small (in ImageJ,  ≤256), a 200x200 RGB image occupies 120,000 bytes (200x200x3 bytes) whereas with a 256-color indexed image, we get 40,768 bytes (200x200x1 + 256*3 ). Thus, an indexed image saves memory space compared to its equivalent in RGB.

Note: Don't use these kind of images for image processing. Historically, they were used to save memory or space on hard disks. Now, all the common computers can work with full RGB images.

No comments:

Post a Comment