Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 11

105 Color Images on MSX1

© 2006 Daniel Vik - daniel@vik.cc

______________________________________________________________________________________________
_
© 2006 Daniel Vik - daniel@vik.cc
Screen 2 Images
The MSX1 palette consists of 15 unique colors:

A screen 2 image is made up of 8x1 pixel sized blocks, which each has a
background and a forground color from the palette:

Max 2 colors
per 8x1 block

Background Foreground
color color
______________________________________________________________________________________________
_
© 2006 Daniel Vik - daniel@vik.cc
Interlacing
Switching between two different screen 2 images every
frame (50 times/second) creates an illusion of more
colors than available in each image alone.

For example:

+ =

______________________________________________________________________________________________
_
© 2006 Daniel Vik - daniel@vik.cc
Interlaced palette
A screen 2 image can show 15 different colors. By
interlacing two screen 2 images its possible to “mix”
colors to create a palette with up to 105 unique
colors:

______________________________________________________________________________________________
_
© 2006 Daniel Vik - daniel@vik.cc
Interlaced blocks
Since the interlaced image is constructed from two screen 2
images, the available colors in a 8x1 block are the
combination of the foreground and background colors of the
two images:
COLOR 1: background of image 1 + background of image 2
COLOR 2: background of image 1 + foreground of image 2
COLOR 3: foreground of image 1 + background of image 2
COLOR 4: foreground of image 1 + foreground of image 2

So not only do we get more colors, we also can use four


different colors instead of two in each 8x1 block.
______________________________________________________________________________________________
_
© 2006 Daniel Vik - daniel@vik.cc
Interlaced blocks example

Even Frame Odd Frame Mix

______________________________________________________________________________________________
_
© 2006 Daniel Vik - daniel@vik.cc
Encoding algorithm
Converting a 24-bit RGB bitmap into interlaced screen
2 format is done by first dividing the RGB image into
8x1 pixel sized blocks.

Objective: Find the two 8x1 screen 2 blocks


that combined give the colors
closest to the source image.

______________________________________________________________________________________________
_
© 2006 Daniel Vik - daniel@vik.cc
Cost Function
To find a color x in the 105 color palette that best matches a color y in
the source image a cost function is used:

Q(x, y) = ( xr - yr )2 + ( xg - yg )2 + ( xb - yb )2

The cost in is the Minimum Square Error calculated in the RGB space but
other cost functions can also be used.

Doing cost calculations in the YUV space sometimes give better results,
especially the intensity levels (gray tones). But it may give quite big color
errors because the MSX palette has so few colors.

A good way of getting both good color and intensity accuracy is to use
YRGB in the cost function.
______________________________________________________________________________________________
_
© 2006 Daniel Vik - daniel@vik.cc
Color Table
An interlaced 8x1 block can hold up to four different colors but not all
combinations from the 105 color palette can be used in one block. There
are only 6020 ways the foreground and background colors can be
combined in one block.

The encoding algorithm uses a table Tk,i with the 6020 different color
combinations for the 8x1 block. Each entry Tk in the table contains four RGB
values that are made up of foreground and background colors of an even
and an odd image.

______________________________________________________________________________________________
_
© 2006 Daniel Vik - daniel@vik.cc
Cost calculation
Next the cost qk of using a color combination Tk to match the 8x1 block

from the source image Bn is calculated.

The cost for one pixel n in the block is the color Tk,i that gives the lowest
cost value when compared with the pixel Bn in the source image.

The cost qk for the entire block is the sum of the cost of each individual
qk = ∑n=1..8 min( Q(Tk,1 , Bn) , Q(Tk,2 , Bn) , Q(Tk,3 , Bn) , Q(Tk,4 , Bn) )
pixel:

When the cost for all color combinations are calculated, the lowest value dk
tells which color combination T best matches the source image.
k
______________________________________________________________________________________________
_
© 2006 Daniel Vik - daniel@vik.cc
Final Steps
Once the lowest cost color combination Tbest is found, the foreground and
background colors for the even and odd screen 2 image that made up the
RGB values in Tbest are saved.

The patterns of the two images are calculated indirectly in the cost
calculation, but given the index i of the color with the lowest cost Tbest,i it is
possible to tell whether a foreground or background color should be used
for a pixel in the two screen 2 images.

______________________________________________________________________________________________
_
© 2006 Daniel Vik - daniel@vik.cc

You might also like