• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

Archived

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

Rock2000

Finding best color match

6 posts in this topic

Since we are looking for the closest "looking" color, I would expect that the RGB description of a color is all but useless. What we really need is a HSB description of the colors (Hue, Saturation, Brightness). THEN, and only then, do we do a weighted (as in assigning three constants, k, l, and m, to multiply the H, S, and B values by respectively) 3D vector length from desired color to each indexed color in turn.

This should produce much more desireable output. Now, I can't help you with RGB -> HSB conversion, but the find someone who does or even some code that does is trivial.

0

Share this post


Link to post
Share on other sites
Here is a code from Crystal Space sources, it works good:

int TxtCmapPrivate::find_rgb (int r, int g, int b)
{
if (r>255) r=255; else if (r<0) r=0;
if (g>255) g=255; else if (g<0) g=0;
if (b>255) b=255; else if (b<0) b=0;

int i, min, mindist;
mindist = 1000L*256*256;
min = -1;
register int red, green, blue, dist;
for (i = 1 ; i < 256 ; i++) // Color 0 is not used, it is reserved for transparency
if (alloc[i])
{
red = r - rgb_values[(i<<2)+0];
green = g - rgb_values[(i<<2)+1];
blue = b - rgb_values[(i<<2)+2];
dist = (299*red*red) + (587*green*green) + (114*blue*blue);
if (dist == 0) return i;
if (dist < mindist) { mindist = dist; min = i; }
}
return min;
}

The trick is to make difference between colors so distance calculations will be more accurate.

------------------
FlyFire/CodeX
http://codexorg.webjump.com

0

Share this post


Link to post
Share on other sites
HSB space does seem more appropriate. I'll have to look for conversion routines, but in that space I don't think you can use simple 3D vectors, because that color space is not a nice cube like RGB is; it is a crazy double ended cone, which seems pretty scary at first glance anyway.

The Crystal Space example looks about the same as Allegro, but does anyone know where the 'magic numbers' come from? CS uses 299, 587, 114, but allegro uses 30*30, 59*59, and 11*11. I guess it makes some sense in that humans discern green more than other colors, so its weighted more, but why are the numbers different? Maybe I'll run across the answer looking at the color space conversion routines.

0

Share this post


Link to post
Share on other sites
This maybe out of topic here...have a look.
This is from a book called 'Programmer's Guide to the EGA and VGA Cards'....
gray scale = (0.30 x red) +
(0.59 x green) +
(0.11 x blue)
In creating the gray scale, 30 percent of the red intensity is added to 59 percent of the green intensity and added to 11 percent of the blue intensity. Because the resultant intensity is equal to 100 percent of the intensity of the three colors, the intensity of a gray scale will result in a gray scale of the same value. For example, assume that the three color values are 40, 40, 40 for red, green, blue. This produces a gray scale of intensity 40. The resultant gray scale would be (.30 x 40) + (.59 x 40) + (.11 x 40)
= 1.0 x 40 = 40..............

What i found out from CS example above is that 299 almost = 30% x 1000L, 587 almost = 59% x 1000L, 114 almost = 11% x 1000L.......

that's all i can help here.

0

Share this post


Link to post
Share on other sites
Now that we've really beaten this to death ...
__I believe, Rock2000, that you may also want to make the images look good. The next logical step would be to implement a dithering routine.
__Preferably it would be error diffusion; unfortunately I know zilch about it. Perhaps there's a thread in the message board. I couldn't find one, though. Maybe someone could start a new thread on dithering ! [hint, hint]
0

Share this post


Link to post
Share on other sites
The day I find a good article, source, tutorial about COLOUR dithering will be the happiest day of my life. Dithering from RGB24 to PALETTE8 is a pain! You have to do the colour palette conversions AND the dithering sort of at the same time, or else you'll remove colours that are essential to the dithering process. If you dither first, you have too many colours and have to do palette matching, which might cause your dithering to sharpen up or soften up, ruining your image.

Do check out:

A Description of Using Error Diffusion for Graphics

and

Sloppy's palette selection

Sloppy's palette selection concept is pretty amazing, and works quite well (given the sample images) as far as I can implement it.. but dithering is still needed - I wish I knew how photoshop does it because Adobe has made a really nice weighted dithering scheme..

0

Share this post


Link to post
Share on other sites
I need a routine to search a palette and find the color that best matches the input RGB value. I would normally have thought that the best color would be the one that has the smallest distance in the color cube (3D cube, 1 unit around, with x,y,z representing red,green,blue, in whatever order).

However, I've looked at the source code for Allegro because it has lookup tables, which I figured I'd use, but it seems to use some sort of weighted squares approach that I don't understand (and there is pretty much no comments). What is the best approach, or where are any good explanations/algorithms on this?

Rock

0

Share this post


Link to post
Share on other sites