105 Color Images on MSX 1 2006 Daniel

  • Slides: 11
Download presentation
105 Color Images on MSX 1 © 2006 Daniel Vik - daniel@vik. cc ________________________________________________

105 Color Images on MSX 1 © 2006 Daniel Vik - daniel@vik. cc ________________________________________________ © 2006 Daniel Vik - daniel@vik. cc

Screen 2 Images The MSX 1 palette consists of 15 unique colors: A screen

Screen 2 Images The MSX 1 palette consists of 15 unique colors: A screen 2 image is made up of 8 x 1 pixel sized blocks, which each has a background a forground color from the palette: Max 2 colors per 8 x 1 block Background color Foreground color ________________________________________________ © 2006 Daniel Vik - daniel@vik. cc

Interlacing Switching between two different screen 2 images every frame (50 times/second) creates an

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

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

Interlaced blocks Since the interlaced image is constructed from two screen 2 images, the available colors in a 8 x 1 block are the combination of the foreground and background colors of the two images: COLOR 1: background of image 1 COLOR 2: background of image 1 COLOR 3: foreground of image 1 COLOR 4: foreground of image 1 + background of image 2 + foreground of image 2 So not only do we get more colors, we also can use four different colors instead of two in each 8 x 1 block. ________________________________________________ © 2006 Daniel Vik - daniel@vik. cc

Interlaced blocks example Even Frame Odd Frame Mix ________________________________________________ © 2006 Daniel Vik -

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

Encoding algorithm Converting a 24 -bit RGB bitmap into interlaced screen 2 format is done by first dividing the RGB image into 8 x 1 pixel sized blocks. Objective: Find the two 8 x 1 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

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 8 x 1 block can hold up to four different

Color Table An interlaced 8 x 1 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 8 x 1 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

Cost calculation Next the cost qk of using a color combination Tk to match the 8 x 1 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 pixel: qk = ∑n=1. . 8 min( Q(Tk, 1 , Bn) , Q(Tk, 2 , Bn) , Q(Tk, 3 , Bn) , Q(Tk, 4 , Bn) ) When the cost for all color combinations are calculated, the lowest value dk tells which color combination Tk best matches the source image. ________________________________________________ © 2006 Daniel Vik - daniel@vik. cc

Final Steps Once the lowest color combination Tbest is found, the foreground and background

Final Steps Once the lowest 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