Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve or replace the palette generation algorithm #86

Open
Rangi42 opened this issue Aug 8, 2024 · 2 comments
Open

Improve or replace the palette generation algorithm #86

Rangi42 opened this issue Aug 8, 2024 · 2 comments

Comments

@Rangi42
Copy link
Owner

Rangi42 commented Aug 8, 2024

Given this input image:

image

(Or this equivalent one which I find easier to look at):

image

It could be done with just two palettes:

{ 001f, 03f0, 7fe0, 7c10, }
{ 02ff, 23e0, 7d00, 5c1f, }

But Tilemap Studio (and superfamiconv) do it in six:

84ff00 ffbd00 00ff42 ff0000
ffbd00 00ffff ff0000 0042ff
ffbd00 ff00bd ff0000 8400ff
84ff00 00ffff 00ff42 0042ff
84ff00 00ff42 ff00bd 8400ff
00ffff ff00bd 8400ff 0042ff

(Extending the input to one which could fit in 8 palettes but for which we fail to do so is left as an exercise for the reader.)

@Rangi42
Copy link
Owner Author

Rangi42 commented Aug 8, 2024

@ISSOtm found this example in gbdev/rgbds#1451. We may want to use the Overload-and-Remove algorithm from rgbgfx.

@ISSOtm
Copy link

ISSOtm commented Aug 8, 2024

(Extending the input to one which could fit in 8 palettes but for which we fail to do so is left as an exercise for the reader.)

Here you go chief:

Image that fails to fit within 8 palettes

Correct answer:

{ 03f0, 7fe0, 001f, 7c10, }
{ 02cb, 5ac0, 0016, 580b, }
{ 02ff, 23e0, 5c1f, 7d00, }
{ 0216, 16c0, 4016, 58a0, }

SuperFamiconv (requires -P 12 or higher):

[["#b50000","#ffbd00","#5ab500","#00ff42"],
 ["#ff0000","#b58400","#00b529","#00ffff"],
 ["#b50000","#ffbd00","#00b5b5","#0042ff"],
 ["#ff0000","#b58400","#0029b5","#8400ff"],
 ["#b50000","#ffbd00","#5a00b5","#ff00bd"],
 ["#ff0000","#b58400","#84ff00","#b50084"],
 ["#5ab500","#00ff42","#00b5b5","#0042ff"],
 ["#84ff00","#00b529","#0029b5","#8400ff"],
 ["#5ab500","#00ff42","#5a00b5","#ff00bd"],
 ["#00b529","#00ffff","#8400ff","#b50084"],
 ["#5a00b5","#00b5b5","#0042ff","#ff00bd"],
 ["#84ff00","#00ffff","#0029b5","#b50084"]]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants