Jump to content

Photo

Conversion from RGB/HSV to GTIA color codes


5 replies to this topic

#1 AverageSoftware OFFLINE  

AverageSoftware

    Chopper Commander

  • 190 posts
  • Location:Burien, WA

Posted Mon Apr 15, 2019 7:30 PM

I've been looking for this for some time and haven't had any luck.  Is there some kind of formula somewhere that can convert from RGB or HSV color values to NTSC GTIA codes?

 

Alternatively, if someone has already brute-forced this, a table of color mappings would be quite helpful.



#2 phaeron OFFLINE  

phaeron

    River Patroller

  • 2,738 posts
  • Location:Bay Area, CA, USA

Posted Mon Apr 15, 2019 8:21 PM

You're going to have to give some more info about what you're trying to do and what form you need that mapping in. The easiest thing to do is just to export a .pal file from a recent emulator that has a palette with the color settings you want, then run a standard RGB-to-indexed-color mapping algorithm. PAL files are just RGB byte triples for all 256 colors in GTIA order. There is still no one such mapping, though, as it depends on the monitor and the color adjustment on the bottom of the computer.

 

If for some reason you want an algorithm, it's more complicated and there's still ongoing research as to more accurate methods. Forget about HSV for this, it's a weird color encoding that has no use here. The basic method is to map a cylinder in YIQ/YUV space, with its centerline along the grayscale axis and the hue values at equally spaced angles (but not necessarily equally distributed around the whole cylinder), then a color matrix to convert YIQ/YUV to NTSC RGB, followed by an additional color correction from NTSC RGB to sRGB.

 



#3 Wrathchild OFFLINE  

Wrathchild

    River Patroller

  • 2,189 posts
  • Location:Reading, UK.

Posted Tue Apr 16, 2019 2:38 AM

Something like this?

 

[Edit] obviously brought up to date with everything learnt since then :)
Maybe Avery could include a little tool within Altirra to allow an RGB value to be mapped to the active palette?


Edited by Wrathchild, Tue Apr 16, 2019 2:42 AM.


#4 AverageSoftware OFFLINE  

AverageSoftware

    Chopper Commander

  • Topic Starter
  • 190 posts
  • Location:Burien, WA

Posted Tue Apr 16, 2019 6:24 AM

I'm trying to convert some color-indexed RGB images for a game I'm working on.  I have a utility I wrote that generates the data bytes and color tables in a way I can use, but the color conversion has to be done by hand and my eyesight isn't up to the task.

 

I was hoping to have some way to convert, if only approximately, the RGB triples to the GTIA color codes.  I've stumbled across some of those crazy cylinder formulas, but the principles involved are a complete mystery to me.

 

Something like this?

 

 

Wow, I even posted in that thread.  I don't remember that at all.  I'll check this out later.  Unfortunately, I develop on a Linux machine and this isn't running with Wine.  The next time I'm on Windows I'll see if this can help me, thanks.



#5 dmsc OFFLINE  

dmsc

    Dragonstomper

  • 508 posts
  • Location:Viņa del Mar, Chile

Posted Tue Apr 16, 2019 7:58 AM

Hi!
 

I'm trying to convert some color-indexed RGB images for a game I'm working on.  I have a utility I wrote that generates the data bytes and color tables in a way I can use, but the color conversion has to be done by hand and my eyesight isn't up to the task.
 
I was hoping to have some way to convert, if only approximately, the RGB triples to the GTIA color codes.


Then, perhaps it is better to use graph2font? ( http://g2f.atari8.info/That way, all the restrictions on number of color per line are take care.

If not, the correct way is to export the pallete from the emulator and use one of many tools to map an RGB image to a given pallete, I use a command line tool " ppmquant ", but you can use Gimp or other graphic editors.

#6 AverageSoftware OFFLINE  

AverageSoftware

    Chopper Commander

  • Topic Starter
  • 190 posts
  • Location:Burien, WA

Posted Tue Apr 16, 2019 7:12 PM

OK, I tracked down one of these palette files, and now I think I have all the tools I need for what I want to do.  Thanks for the help.






0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users