Web Student - Building a Colorblindness Simulator

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
cyber_saliva
Posts: 2
Joined: 2011-01-29T11:21:58-07:00
Authentication code: 8675308

Web Student - Building a Colorblindness Simulator

Post by cyber_saliva »

Hey there.

My name is Wally, and I'm a Web Design student in Philadelphia. For my senior project, I want to build a site where the user uploads a photo and can see that photo as a person with colorblindness would see it. It HAS to be online, and everything must work for the user without ever leaving the web. While doing research on the matter and finding resources, I came across VisCheck, a website which (supposedly) does this, but doesn't seem to be working anymore.

On this site, they listed Image Magick as the main tool they used for pre- and post-processing of the imagery. I am not a programmer, and I've never used this software before. Does anyone know if I can accomplish this with Image Magick? And do you know how I would go about doing it? Links to walkthroughs or other sites would be greatly appreciated.

Thank you!
viarun
Posts: 10
Joined: 2010-12-20T11:57:07-07:00
Authentication code: 8675308

Re: Web Student - Building a Colorblindness Simulator

Post by viarun »

I'd start here first: http://homepage.mac.com/lpetrich/ColorB ... ssSim.html

Appears he's done a bit of research on how colorblind people see, has references to real data and studies, and even includes some downloadable data ( channel filters ) that work in GIMP and Photoshop.

I suspect someone with more IM depth than me could tell you how to use that same data within IM.

A quick and dirty example:

convert rose: -resize 200x -colorspace RGB -channel R -evaluate set 0 rose-nored.jpg

Creates the "rose" picture within IM without any red in it. I suspect colorblindness is a little more complex than that though :)
cyber_saliva
Posts: 2
Joined: 2011-01-29T11:21:58-07:00
Authentication code: 8675308

Re: Web Student - Building a Colorblindness Simulator

Post by cyber_saliva »

viarun wrote:I'd start here first: http://homepage.mac.com/lpetrich/ColorB ... ssSim.html

Appears he's done a bit of research on how colorblind people see, has references to real data and studies, and even includes some downloadable data ( channel filters ) that work in GIMP and Photoshop.

I suspect someone with more IM depth than me could tell you how to use that same data within IM.

A quick and dirty example:

convert rose: -resize 200x -colorspace RGB -channel R -evaluate set 0 rose-nored.jpg

Creates the "rose" picture within IM without any red in it. I suspect colorblindness is a little more complex than that though :)
Thank you so much! This will definitely help me out.
SineSwiper
Posts: 23
Joined: 2011-07-19T04:20:20-07:00
Authentication code: 8675308

Re: Web Student - Building a Colorblindness Simulator

Post by SineSwiper »

For others interested, this works:

Code: Select all

# Protanope = reds are greatly reduced (1% men)
convert -monitor Lenna.png -strip -depth 32 -colorspace sRGB -color-matrix '0.0 2.02344 -2.52581 0.0 1.0 0.0 0.0 0.0 1.0' +set profile Lenna-CBP.png
# Deuteranope = greens are greatly reduced (1% men)
convert -monitor Lenna.png -strip -depth 32 -colorspace sRGB -color-matrix '1.0 0.0 0.0 0.494207 0.0 1.24827 0.0 0.0 1.0' +set profile Lenna-CBD.png
# Tritanope = blues are greatly reduced (0.003% population)
convert -monitor Lenna.png -strip -depth 32 -colorspace sRGB -color-matrix '1.0 0.0 0.0 0.0 1.0 0.0 -0.395913 0.801109 0.0' +set profile Lenna-CBT.png
Grabbed that from Daltonize.org in one of their scripts. Didn't use LMS because I was having issues with the LMS to XYZ conversion back.
SineSwiper
Posts: 23
Joined: 2011-07-19T04:20:20-07:00
Authentication code: 8675308

Re: Web Student - Building a Colorblindness Simulator

Post by SineSwiper »

Update: Version that mostly works with LMS, using a XYZ to LMS conversion. For some reason, this doesn't appear to work with the Deuteranope version. I suspect there's some clipping going on that I don't know how to disable.

Code: Select all

# Normal
convert -monitor Lenna.png -background Orange label:Normal -gravity Center -append Lenna-N.png

# Protanope = reds are greatly reduced (1% men)
convert -monitor \( Lenna.png -strip -depth 32 -colorspace XYZ \
-color-matrix '0.7328 0.4296 -0.1624 -0.7036 1.6975 0.0061 0.0030 0.0136 0.9834' \
-color-matrix '0.0 2.02344 -2.52581 0.0 1.0 0.0 0.0 0.0 1.0' \
-color-matrix '1.0961 -0.2789 0.1827 0.4544 0.4735 0.0721 -0.0096 -0.0057 1.0153' \
-colorspace sRGB +set profile \) -background Orange label:Protanope -gravity Center -append Lenna-CBP.png

# Deuteranope = greens are greatly reduced (1% men)
# (still using older "straight RGB" code)
convert -monitor \( Lenna.png -strip -depth 32 -colorspace sRGB \
-color-matrix '1.0 0.0 0.0 0.494207 0.0 1.24827 0.0 0.0 1.0' \
+set profile \) -background Orange label:Deuteranope -gravity Center -append Lenna-CBD.png

# Tritanope = blues are greatly reduced (0.003% population)
convert -monitor \( Lenna.png -strip -depth 32 -colorspace XYZ \
-color-matrix '0.7328 0.4296 -0.1624 -0.7036 1.6975 0.0061 0.0030 0.0136 0.9834' \
-color-matrix '1.0 0.0 0.0 0.0 1.0 0.0 -0.395913 0.801109 0.0' \
-color-matrix '1.0961 -0.2789 0.1827 0.4544 0.4735 0.0721 -0.0096 -0.0057 1.0153' \
-colorspace sRGB +set profile \) -background Orange label:Tritanope -gravity Center -append Lenna-CBT.png

# Comparison
montage -monitor \( Lenna-CB[NP].png Lenna-CB[DT].png \) -geometry '1x1<' Lenna-CB.png
Post Reply