Thursday, March 31, 2011

Assignment 4.1 - Image Manipulation, Intermediate Scripting

Part 2.

I haven't figured out how to script the color blind image yet. I will describe what I have so far though. I read through the scripting guide while working on this assignment, which helped a ton. There were a lot of web pages that were helpful too, but I still couldn't figure out everything.

My first approach was to pretty much do what we did in class by copying one of the RGB channels of the image and pasting it in a new layer. My problem was actually copying what was in the channel. I was trying a select-all, copy, then paste, but that only worked for copying other layers.

My second approach was to create the channels myself by changing the original background layer. Luckily, I found a command called Channel Mixer that does exactly that. I just had to copy the background layer into a new layer then apply the Channel Mixer. Unluckily though, I couldn't figure out how to use that command while scripting. The closest thing I could find was a command called mixChannels. I couldn't get the same results using that command though, and it used CMY instead of RGB for some reason. If I can get that to work correctly, then I would just need to desaturate the image to match one of the channels.

I had problems with desaturating as well. I used the command: layer.HSBColor.saturation(-100), but the script kept complaining about it. Once I get through these issues it should be pretty straight forward, I hope. Here's the code I'm currently using. I'm going for a "Tritanomaly" color blindness, which makes it hard to distinguish between blue and yellow hues. It might be a little trickier than red/green discrimination because there's no yellow channel by default, but I should be able to make one without too much problem.


var curDoc = activeDocument

//blue channel layer
var layerBlue = curDoc.artLayers.add()
layerBlue.name = "Blue Channel"

curDoc.artLayers["Background"].copy()
curDoc.paste()

//yellow channel layer
var layerYellow = curDoc.artLayers.add()
layerYellow.name = "Yellow Channel"

curDoc.artLayers["Background"].copy()
curDoc.paste()

//code I used at some point and put aside for now:
//layerYellow.mixChannels ([[100,100,100,00],[100,100,100,00],[0,0,0,00]], false)
//layerRed.HSBColor.saturation(-100)
//redChannel = new Array (curDoc.channels[1])
//activeChannels = blueChannel
//curDoc.selection.selectAll()

No comments:

Post a Comment