Thread: Colour theory... (weird title)

  1. #1
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145

    Colour theory... (weird title)

    First of all, I don't need help with the actual programming. Only the theory.

    I'm working on a program that are converting a 256 colour picture with a certain palette into a new picture (also 256 colours) with another palette. Since there are different palettes, the colours will be screwed up if you just copy the data.

    Therefore, the program must find the colour (in the new palette) that matches the old colour the best.

    To do this, I use the Red, Green and Blue values in the colour as the three axises in a 3D coordinate system. And to find the colour that is the best match, I simply pick the colour that is closest to this point in the coordinate system (using Pythagoras).

    What do you think? Is this the right way to do this?
    Or is the closest colour not neccesarily the colour that looks most alike?
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  2. #2
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    As long as all three colour components are similar, the resulting colour will be similar. If you set up a simple app with a coloured box, then set some other boxes up around it with, say, +/- 10 on each of the colour components, you are unlikely to notice the difference in the resulting colours.

    What will make a difference is if two of the components match closely, but the other is way out. Your method would seem to be okay, if the new palette is broadly similar to the old. If it is very different, the nearest match in 3d may still be a long way out.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  3. #3
    Registered User
    Join Date
    Aug 2001
    Posts
    101
    You can also use dithering techniques like error diffusion. A search on google should turn out many results.
    - lmov

  4. #4
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145

    It's done

    The bitmap converting program is done. If anyone is interested, you can download it below (the attachment). It has a pretty good result when converting .

    See the ReadMe.txt file for more information.
    The zipfile also contains some code that demonstrates the use of these sprite files (the converted bitmaps).
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  5. #5
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145

    Oops

    Forgot the attachment... and it was too big so I split it into 2 files.
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  6. #6
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145

    Oops

    Here's the second one...
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Extract Title from plain text file
    By Todd88 in forum C++ Programming
    Replies: 10
    Last Post: 11-21-2008, 09:47 AM
  2. Replies: 2
    Last Post: 03-24-2006, 08:36 PM
  3. Program Crashing
    By Pressure in forum C Programming
    Replies: 3
    Last Post: 04-18-2005, 10:28 PM
  4. Child window with active (highlighted) title bar: Possible?
    By JasonD in forum Windows Programming
    Replies: 7
    Last Post: 10-16-2003, 06:43 AM
  5. DirectDraw colour matching
    By Hunter2 in forum Game Programming
    Replies: 2
    Last Post: 12-10-2002, 02:17 PM