Idea for math experts...

페이지 3/9
1 | 2 | | 4 | 5 | 6 | 7 | 8

By smart duck

Master (152)

smart duck의 아바타

09-05-2007, 20:21

By dvik

Prophet (2200)

dvik의 아바타

09-05-2007, 21:02

Am I missing something?

I don't think existing tools try to minimize the error over all scan lines. The basic encoder, just pick whats best for the first scanline and then encodes the second one, then the third.
Color reduction can be done in several ways but the common methods are quite fast.

The result could most likely be improved by taking all scanlines into account.

By dvik

Prophet (2200)

dvik의 아바타

09-05-2007, 22:26

Btw, I think it is possible to change 8 colors on each scanline without any problem. Not sure if it would make much difference on the result though.

By ARTRAG

Enlighted (6543)

ARTRAG의 아바타

09-05-2007, 22:34

Am I missing something?

I don't think existing tools try to minimize the error over all scan lines. The basic encoder, just pick whats best for the first scanline and then encodes the second one, then the third.
Color reduction can be done in several ways but the common methods are quite fast.

The result could most likely be improved by taking all scanlines into account.

Actually my computation was about only ONE scanline.

The optimal encoder has to select 8 colors among the 12 from the previous line and 4 from the palette.
This leads, per each scanline, to 12! / 8! /(12-8)! *512^4 combinations per scanline.

By dvik

Prophet (2200)

dvik의 아바타

09-05-2007, 23:22

Is it known what algorithm DamageX tool is using?

By NYYRIKKI

Enlighted (5875)

NYYRIKKI의 아바타

10-05-2007, 01:56

@ARTRAG No, you are calculating some sort of "safe line", that is not needed.

Let's still assume that 4 color changes is the way to go.

If we have 16 colors (0=always black = 15 adjustable colors) we can use "all the colors that are not needed to be changed for next line" freely. This means that every line should be able to use at least 12 colors. If there is no need for change there might be even more colors available.

This also means, that you need to start selecting of colors from last line and not from first line.

Think it like this:
- Take away 4 least used colors (for next line)
- Replace these colors with 4 most used colors not already in palette. (for next line)
- Use all other colors to represent this line

By DamageX

Master (217)

DamageX의 아바타

13-05-2007, 06:39

oh wait, you're saying that you want to change 4 colors that aren't being used on the current scanline? so a line can only use colors won't be changed before the next line?

On the Amiga, color changes can all happen during the H-blank so Hamlab assumes all 16 colors are usable at once. There is no possibility to restrict it to 12 colors, although 8 colors per line is possible (could all 8 colors then be changed for every line like dvik suggests?)

I found this documentation on IFF images:
http://www.newtek.com/lightwave/developer/LW80/8lwsdk/docs/filefmts/ilbm.html

there is some simple RLE encoding in there

BTW, how the heck do you read bytes from a file in MSX-BASIC?

By ARTRAG

Enlighted (6543)

ARTRAG의 아바타

13-05-2007, 08:06

oh wait, you're saying that you want to change 4 colors that aren't being used on the current scanline? so a line can only use colors won't be changed before the next line?

YES
AFAIK The z80 cannot change the palette of 4 colors in the H-blank
@NYYRIKKI do you agree on this point ?


On the Amiga, color changes can all happen during the H-blank so Hamlab assumes all 16 colors are usable at once. There is no possibility to restrict it to 12 colors, although 8 colors per line is possible (could all 8 colors then be changed for every line like dvik suggests?)

This is why we need a new algorithm

I found this documentation on IFF images:
http://www.newtek.com/lightwave/developer/LW80/8lwsdk/docs/filefmts/ilbm.html

there is some simple RLE encoding in there

BTW, how the heck do you read bytes from a file in MSX-BASIC?

look at the command "open" in the manual

By dvik

Prophet (2200)

dvik의 아바타

13-05-2007, 08:53


AFAIK The z80 cannot change the palette of 4 colors in the H-blank
@NYYRIKKI do you agree on this point ?

With very good timing you can change three colors in h-blank, but its hard. And four is not possible

This is why we need a new algorithm
Just a small modification of the amiga tool would be enough, or?

By DamageX

Master (217)

DamageX의 아바타

13-05-2007, 09:57

This is why we need a new algorithm
Yes, I thought so too, and I went to work on it right after my post actually Smile

color reduction is a bit complicated and I'm not sure of the best way but this is what I've come up with.

step 1: a bitmap Running Naked in a Field of Flowers
http://www.hyakushiki.net/msx/becki5.bmp
step 2: reduce to 512 colors with simple dithering
http://www.hyakushiki.net/msx/out512.bmp
step 3: reduce to 12 colors per line
http://www.hyakushiki.net/msx/out513.bmp

of course, I still need to make sure only 4 or so colors change per line. But it's 4AM so I'll get to that later.

페이지 3/9
1 | 2 | | 4 | 5 | 6 | 7 | 8