Sign in to follow this  

Colorblind Shader Algorithm

This topic is 3338 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

Just wondering if anyone here can point me in the right direction. I'm looking for an algorithm(that can be implemented in a shader) that will process an image so that it is easier for a colorblind person to make out differences in their problem colors. A couple of nights worth of Googling hasn't given me much except examples of pictures that have been run through the process. Conversely, I'd also be interested in a process to simulate the various forms of color blindness, which certainly seems more popular. Thanks for any tips! (And yes, to answer the obvious question, I am colorblind. Red/Green Deficient, to be exact)

Share this post


Link to post
Share on other sites
How do you expect it to work?
switch the channels? out.rgb = in.bgr
replace with another color? redish => magentaish

..or it might be easier to skip the colors altogether. Make the game playable in b/w.

Share this post


Link to post
Share on other sites
I read a SIGGRAPH paper a while ago that might be useful for this - it was a technique for converting color photographs to black and white, but it took similar colours into account.
[EDIT]
This, or this might have been the work I was thinking of.

Notice in the regular color->grey algoithm (the GIMP one), it's hard to see the red reflection of the sun on the water, but with the other algorithms the reflection is distinct from the water:

Share this post


Link to post
Share on other sites
There's an Inkscape plugin which simulates several different types of colour blindness. Source code is included so it might be a good starting point:


import coloreffect

class C(coloreffect.ColorEffect):
def __init__(self):
coloreffect.ColorEffect.__init__(self)
self.OptionParser.add_option("-t", "--type",
action="store", type="string",
dest="type", default="normal",
help="type of vision")

def colmod(self,r,g,b):
if self.options.type=='normal':
return '%02x%02x%02x' % (r,g,b)

typedict={
#'normal': [1 , 0 , 0 , 0 , 1 , 0 , 0 , 0 ,1 ],
'protanopia': [0.567, 0.433, 0 , 0.558, 0.442, 0 , 0 , 0.242 ,0.758],
'protanomaly': [0.817, 0.183, 0 , 0.333, 0.667, 0 , 0 , 0.125 ,0.875],
'deuteranopia': [0.625, 0.375, 0 , 0.7 , 0.3 , 0 , 0 , 0.3 ,0.7 ],
'deuteranomaly':[0.8 , 0.2 , 0 , 0.258, 0.742, 0 , 0 , 0.142 ,0.858],
'tritanopia': [0.95 , 0.05 , 0 , 0 , 0.433, 0.567, 0 , 0.475 ,0.525],
'tritanomaly': [0.967, 0.033, 0 , 0 , 0.733, 0.267, 0 , 0.183 ,0.817],
'achromatopsia':[0.299, 0.587, 0.114, 0.299, 0.587, 0.114, 0.299, 0.587 ,0.114],
'achromatomaly':[0.618, 0.320, 0.062, 0.163, 0.775, 0.062, 0.163, 0.320 ,0.516]
}
m=typedict[self.options.type]

r2=r*m[0]+g*m[1]+b*m[2]
g2=r*m[3]+g*m[4]+b*m[5]
b2=r*m[6]+g*m[7]+b*m[8]

r=min(int(round((r2))), 255)
g=min(int(round((g2))), 255)
b=min(int(round((b2))), 255)

return '%02x%02x%02x' % (r,g,b)

c = C()
c.affect()

Share this post


Link to post
Share on other sites

This topic is 3338 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this