[N-World Contents] [Book Contents] [Prev] [Next] [Index]

Color Reduction


Most game platforms are limited in the number of colors they can display. N-Paint acknowledges these restrictions, and includes powerful tools for reducing the number of colors in an image without sacrificing detail or overall image quality. Color reduction changes full-color images to color mapped images.


In this Chapter

In this chapter, we'll cover:


Color Reduction

Color reduction is the process of mapping the colors in one image to a palette which contains a smaller number of colors. It is an important feature of N-Paint, since many game platforms are limited in the number of colors they can display. Before color reduction, each pixel might require as many as four bytes for color definition (in the case of a 64-bit, four-component image). In a color reduced image, each pixel's color is defined by a pointer 1 byte or less in size, reducing by over 75% the amount of memory needed to store color information.

In N-Paint's color reduction system, each color in the image is mapped to a pointer that references a slot in the reduced palette. The pointer is a one-byte (8 bit) data structure, so it can accommodate a maximum of 256 colors.

How Color Reduction Works

The first step in the color reduction process is to create a histogram portraying the relative frequency of given RGB values in terms of the number of pixels which have these values. RGB colors are defined by three values, but to illustrate the concept we'll consider a grey scale image, where "color" is really just a shade of grey, and is represented in memory by a single (or one dimensional) intensity value. Specifically, we'll take a 5-bit grey scale image, whose pixels have one of 32 different intensities, or "shades of grey", and reduce it to a 2-bit (4-color) image.

Figure 7.1 Number of pixels per Intensity Value in the original, 4-bit greyscale image

To create the histogram, the algorithm first assigns each pixel to one of 4 groups (one group for each color "slot" in the reduced palette). Each "group" must contain the same quantity of pixels, so if our image contains 10,000 pixels (as would an image 100 x 100 pixels in size) then each group contains 10,000/4, or 2500 pixels. Figure 7.2 shows the resulting distribution of groups:

Figure 7.2 The pixel population diagram, divided into groups

The next step is to determine the weighted average intensity value for each group. These values translate directly to slot values in the reduced palette, as shown in Figure 7.3.

Figure 7.3 Mapping the average intensity value to the reduced palette

Obviously, the procedure for accomplishing this reduction is much more complex in the three-dimensional RGB color space. It isn't necessary to understand how the histogram is produced in this 3D color space, but you do need to be aware of its role in the generation of the reduced palette.

The Reduced Palette

The reduced palette (which is called a Color Lookup Table, or CLUT) itself consists of a predefined number of slots. Each pixel in the reduced image has a pointer value which references one of these slots. The slots themselves are arranged according to a specific index, determined by the color-reduction algorithm. You can perform operations on the slots in the palette, including sorting them by their color values, deleting, or inserting slots. When you do this, however, the values referenced by each pixels pointer can change, resulting in changes in the appearance of the image.


Using Color Reduction

(CLICK-L) on the Color Reduction button in the Paint Modes menu to enter Color Reduction mode.

Figure 7.1 The Color Reduction menu

File Operations

You can perform file operations using the magenta Image edit field. (CLICK-L) on the Image field to reveal the Image Operations pop-up menu. Table 7.1 summarizes each of these operations.

Figure 7.2 The Image Operations pop-up menu

Table 7.1 Color Reduction File and Canvas Operations
Operation Description
Select Image & Palette

allows you to select a full-color image from among those loaded into memory. Any associated palette is loaded as well, or, in the case of a full color image, is created.

Select Image Only

lets you select an image from among those loaded into memory. No palette is loaded or created with the image.

Open Image & Palette

lets you open an image file, and load the image into memory.

Open Image Only

lets you open an image file and load it onto the Color Reduction canvas, but without creating or loading a palette.

Browse

lets you use a browser to select image files.

Revert

lets you reload an image from disk. This has the effect of erasing all changes made since the last time the image was saved.

Save Reduced Image

lets you save the reduced version of the current image to disk.

Save Full Image

lets you save the full-color version of the current image to disk.

Save Full Image As

lets you save the full-color version of the current image to a different directory and filename, which you specify.

Save Many

lets you save several images at once.

Rename

lets you choose a new name for the current image.

Copy

lets you create a copy of the current image in memory.

Delete

lets you delete images from memory (but not from disk).

Load Matte

lets you load a matte from an image in memory onto the current image.

Save Matte

allows you to save the matte component of the current image to file.

Saving Reduced Images and Palettes

When you (CLICK-L) on Image>Save Reduced Image, you can choose between one of three color-mapped image formats:

Palette Operations

The current palette is displayed in the central portion of the Color Reduction menu. Several controls in this area provide ways for you to manage this palette, or select another palette.

Palette

You can use this field to select from among those palettes currently loaded into memory, or to perform several palette operations. (CLICK-L) on the Palette edit field to reveal the Palette Operations pop-up menu:

Figure 7.3 The Palette Operations pop-up menu

Size

The size of the palette refers to its size in bits. The essence of color reduction lies in reducing the size of a palette. When a large palette is reduced in size, N-Paint's color reduction algorithms can calculate a new palette which provides a "best fit" for the colors in the original palette.

(CLICK-L) on the Size field to reveal the Choose Palette Size pop-up menu

Figure 7.4 The Choose Palette Size pop-up menu

Slot

This field shows the currently selected slot. The value to the right are the RGB values for the color stored in that slot. You can edit these values directly if you choose.

BPG

Bits per Gun. This field controls the depth of each color in each slot of the palette. By default, this is set to 8 bits each for the R, G, and B channels (symbolized RGB 888).

Note: Currently this is the only color space option available, but NGI plans to release plugins to provide additional color spaces in the near future.

Using the Palette Menu

The current palette is displayed in the central portion of the Color reduction menu.

Figure 7.5 The current palette

The next section describes the operations you can perform on palette slots. Should your actions result in an unwanted change to the current palette, you can undo your changes with a (CLICK-L) on the UnDo button. Should you change your mind about undoing an action, (CLICK-L) on ReDo to undo your undo.

Manipulating Slots

You can manipulate slots directly with the mouse:

Figure 7.6 A selected slot

Figure 7.7 The Edit Selected Slots(s) pop-up menu

Figure 7.8 Locked Slots

Figure 7.9 Restricted Slots

Note: Restrict and Lock seem very similar. However, LOCK is used when a certain region of the image has been reduced to a certain group of slots, and you want to work on other parts of the image/palette without altering these slots. Restrict is used to prevent certain slots from being used at all. for example, it may be desirable to have a color appear in the palette, but not be used anywhere in the image.

Figure 7.10 The Sort By pop-up menu

(CLICK-L) on a parameter to select it. You can also use the UP and DOWN buttons to control the direction of the sort.

Note: If Auto Highlight is toggled on in the N-Paint setup menus, pixels on the canvas which match selected slots will ALWAYS be highlighted. To review how to change this parameter, see "Auto Highlight," on page 2-8.

The Scratch Palette

The Scratch Palette serves as a permanent clipboard. You can cut or copy colors from slots in the current palette, then paste them onto the Scratch Palette. You can't save the scratch-palette, nor can you apply it to an image.

Color Reduction Operations

The right side of the color reduction menu contains the controls you'll use to specify images to reduce, and also to execute color reduction operations on the current canvas.

Image

(CLICK-L) on this field to select an image file from those currently loaded into memory, and load it onto the canvas.

Target

Each game platform has unique gamma correction and gain values for each color component. You can choose from between several predefined platforms, or define your own. (CLICK-L) on this field to select a platform from a pop-up menu:

Figure 7.11 Platform operations menu.

Note: Changing the Target Platform in the Color Reduction menus applies the gamma and gain corrections for that platform to all N-Paint displays. In other words, it is equivalent to changing the default the Target Platform in the N-Paint Setup menu.

Figure 7.12 Create New Platform dialog

Note: The gamma value affects only the display, not the actual color values of the pixels in the image. This is intended to allow you to preview the image as it will appear on the target platform.

Display

You can view either the original, full-color image, or the image as it appears with colors mapped to the current palette. To select a view, (CLICK-L) on one of the buttons in the Display section of the Color Reduction menu.

Dithering and Matte Options

You can control how N-Paint dithers images, as well as control the matte from the Color Reduction Menus.

Figure 7.13 Matte and DIther level controls

Dithering

When toggled, automatically dithers the colors on the canvas as they are remapped. Enter a number between 0 and 1 to control the level of dithering applied to the canvas.

Note: The dithering method used is specified in the N-Paint Setup menu. To learn more about how to set this parameter, see "Color Reduction Parameters," on page 2-8.

Matte

Controls whether the matte is used to control which areas of the canvas are affected by the Color Reduction operation. (CLICK-L) on the Matte toggle to activate the matte.

The Clip at variable controls the global opacity of the matte for color reduction operations. For example, if your image has a matte which varies in opacity, but you wish to use it to influence color reduction operations, you can override its native opacity and specify a new value in the Clip at field.

Matte Display

The Matte Display button brings up the Matte Display pop -up menu. You can use this menu to change the appearance attributes of the matte (color, tranparency, etc.). The behavior of these options is exactly the same as for the Matte Display button in the Tools menu. To review these options, see "Display," on page 3-5.

Oper

(CLICK-L) on the Oper (operations) field to reveal the Color-Reduction Operation menu:

Figure 7.14 The Select Color-Reduction Operation pop-up menu

Each operation has it's own set of parameters, and the menu changes to reflect this. To execute an operation:

1. Select the operation from the Color-Reduction pop-up menu.

2. Configure the parameters for that operation.

3. (CLICK-L) on Do it.

Color Reduction Operations

Set Palette Slots & Remap

This operation generates the color histogram for the selected area (see "Canvas" below), sets the selected slots (see "Slots" below) to these color values, and then remaps the colors on the canvas to match those in the newly generated palette.

Slots

Canvas

Shapes

N-Paint remembers shapes that you define when you use the Rect or Poly options to define a canvas area. When these canvas options are selected, four new commands are available next to the Do It button:

Remap Canvas to Palette

This operation remaps colors on the canvas using the current palette. Unlike the Set Palette & Remap operation, it does not generate a new palette based on the canvas first.

The parameters for this operation are identical to those described above.

Note: When the Auto Remap parameter is toggled on in the N-Paint Setup menu, images are automatically remapped to the current palette when they are loaded or selected.

Histogram Operations

Set Palette Slots & Remap Canvas and Remap Canvas to Palette create a new histogram each time they are invoked. Sometimes, though, you'll want to build a histogram and reduced palette from more than one image. For example, you may wish to create your histogram from a series of number image files in an animation. You can use histogram operations to build such a cumulative histogram.

Clear Histogram

This operation deletes the current histogram from memory.

Add Colors to Histogram

This operation adds pixel color/population information to the current histogram, and automatically recalculates the weighted average for each group.

Canvas

Set Palette Slots from Histogram

Sets selected palette slots from values in the current histogram.

Palette Operations

Each pixel in the reduced image is mapped to a slot in the reduced palette. These slots can be sorted or rearranged by a variety of operations. This can result in unpredictable changes in an image's appearance.

Reorder Image Indexes

Redirects pointers from their current slot to the slot which contained the color they pointed to originally. This original state is reinitialized by Reset Index History. You'll need to perform this operation if you move slots from their original positions.

Note: If Auto Remap is selected in the Paint Setup menus, then palette slot indices are reordered automatically.

Reset Index History

Redefines base state for pointer assignments. After you reset Index history, Reorder Image Indexes returns to this new order.



[N-World Contents] [Book Contents] [Prev] [Next] [Index]

Another fine product from Nichimen documentation!

Copyright © 1996, Nichimen Graphics Corporation. All rights reserved.