Color Reduction in Aseprite?

I’m trying to convert an RGB bitmap to an indexed sprite with a 9-bit RGB (512 colors) color palette, let’s say a PC Engine or Genesis color palette.

I tried to load the said color palette, and then perform a color conversion to Indexed, and the image turned yellow-ish.

It seems like, Aseprite can only read 256 colors from the palette.

Is there any better solution to color reduction in Aseprite ?

or is there a plugin where it can generate palette from sprite while also taking a reference from active color palette ?

Aseprite indexed color mode images are 1 byte per pixel, meaning [0, 255] is the limit, even if you load a palette greater than that. RGB color mode images do not support variable bits per channel; it’s 4 bytes per pixel in active memory, 1 byte per channel.

Two suggestions would be (1.) Create an indexed image that uses a subset of the 9-bit RGB palette. (2.) Create a 32-bit RGB color mode image that simulates 9-bit by compressing and then re-expanding each color channel.

Step Decimal Hex Diff
0 0 00
1 36 24 36
2 73 49 37
3 109 6D 36
4 146 92 37
5 182 B6 36
6 219 DB 37
7 255 FF 36

The expansions depend on what you use as a reference. Sometimes I see a consistent step of 36 that sums to 252 rather than the alternating 36, 37 step above. A Wikipedia reference image uses 0, 36, 72, 109, 145, 182, 218, 255. I’ve also seen a step of 34 here.

If you’re interested in those options, there are some scripts here that might be useful. The test image is from the Nasa Webb telescope. Looks like this forum has converted some of these images to jpegs, though, so the exact result will not carry across. :person_shrugging:

:arrow_up: Aseprite palette matching result, no dither, 256 colors.

:arrow_up: Quantize color. No reference palette needed. 223 out of 512 colors used.

:arrow_up: Palette to cel, no dither. 179 out of 512 used.

:arrow_up: Floyd-Steinberg dither with SR LAB 2 color model. 202 out of 512 used.

If you extract the palette from option 2 and the palette is within the 256 color limit, then you can use that as a basis for option 1. Aseprite has a built-in palette from sprite feature in the palette options menu. The scripts repo linked above also has a palette from cel script.

I know that the ppm file format supports custom channel maximums. This means that your image would actually be stored in 9-bit RGB, 3-bits per channel, if you used a max of 7, as 2 ^ 3 - 1. It’s up to the importer to expand that color data as needed. There’s a Lua script to import and export to ppm files at this Github repo.

Krita has a palettize filter which doesn’t change the color mode, but looks like it does a decent job. It also has dither pattern options. GIMP has the same limitation as Aseprite. You can convert an image to indexed, but can’t even select palettes of more than 256 colors.

1 Like

Oh wow I didn’t know that Krita has a palettize filter !

I think that’s what I’m looking for.

This is the result :arrow_down:

HW 9-bit palette turned out a bit green-ish, but I think using Genesis palette is doable for PC Engine style (?)

Thanks a lot for the help !