Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Zipster

Creating an accurate palette

This topic is 5958 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Basically, I have my image in 24-bit format, so an RGB for each pixel. However, the current requirements for my project are that all the images be in 8-bit palettized format. The reason I was even using 24-bit format was so that I could do some alpha blending. The good thing about this situation is that the original image was in 8-bit format with a palette. Basically, I changed my 8-bit image into 24-bit, changed some RGB values, and now I''m trying to go back and reconfigure my palette. I''m trying to find an algorithm to create a palette that matches most of the colors I am using. I already had a palette before, but I want to renegerate a completely new one based on the final data I have. My first thoughts were to find out which colors were used most in the image. The fact that the image was originally in 8-bit palettized mode means that a lot of the 24-bit data should match when I compare them. Whenever I found two colors that changed, I would try to find an index that wasn''t used in the original palette and place my new color there. However, considering the source of my images, most of the indexes in the original palette would be used by nature, and there wouldn''t be a very good chance that an empty index would appear. So, if anyone knows of any good algorithms for generating a best fit palette from 24-bit data, make sure to let me know

Share this post


Link to post
Share on other sites
Advertisement
There are several methods to do that. One important question arises: what about the performance ? Is it important, that the quantization process is fast (but lower quality), or do you prefer highest quality but slower execution time ?

The best 24->8 bit quantization algorithm I''ve seen (and used) so far, is NeuQuant by Anthony Dekker. It uses a neural net that is trained onto the 24bit source image, and then outputs an optimal matching palette. Due to the nature of neural nets, it is a bit slower than other algorithms, but the quality is excellent. You also have an adjustable sampling factor, that lets you trade off speed for quality.

/ Yann

Share this post


Link to post
Share on other sites
Lucky for us, all this is done during the preprocessing stage, so the algorithm that produces the highest quality is the best, since we can get away with slow execution.

Thanks for the link!

Share this post


Link to post
Share on other sites
Well you could always use a program like photoshop to convert it, if you dont have many images. There''s also some programs that do mass conversion of image files.

Share this post


Link to post
Share on other sites
It has to be done in my code, though, because it''s part of an entire tool I''m working on, but otherwise yeah I''d let Photoshop do the work

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!