Thursday, March 31, 2011

Red Green Color Blindness Script

I guess it shouldn't be called color "blindness." With those with red-green color blindness, they have a harder time distinguishing between red and green hues. In this script, you need to already have a picture open (most likely a jpg with just a background layer.
var image = app.activeDocument;

var background = app.activeDocument.artLayers.getByName("Background");

background.duplicate();

background.visible = false;

var copy = image.artLayers.getByName("Background copy");

var newLayer = image.artLayers.add();

var newLayer = image.artLayers.add();

var Layer1 = image.artLayers.getByName("Layer 1");

var Layer2 = image.artLayers.getByName("Layer 2");

image.activeLayer = copy;

var redChannel = image.channels.getByName("Red");

var greenChannel = image.channels.getByName("Green");


var arrayRed = new Array (redChannel);

var arrayGreen = new Array (greenChannel);

var arrayChannel = new Array (redChannel, greenChannel);

image.activeChannels = arrayRed;


image.selection.selectAll();

image.selection.copy();

image.activeLayer = Layer1;

image.paste();

image.activeLayer = copy;

image.activeChannels = arrayGreen;

image.selection.selectAll();

image.selection.copy();

image.activeLayer = Layer2;

image.paste();

copy.visible = false;

image.activeLayer.blendMode = BlendMode.SCREEN;

image.mergeVisibleLayers();

image.selection.selectAll();

image.selection.copy();

copy.visible = true;

image.activeLayer = copy;

Layer2.visible = false;

image.activeChannels = arrayRed;

image.paste();

image.activeChannels = arrayGreen;

image.paste();

image.activeLayer = background;

image.flatten();

image.selection.deselect();
And when you run it on a red-green colorblindness test like this one: source It becomes this image after you run it: So, this code simulates the red-green color blindness. The code takes the red and green channels in an rgb image, copies and pastes them into new channels. The screen layer blend mode adds the two layers and averages them out. Then it pastes the resulting image back onto the red and green channels. The resulting image has the red and green channels being the same. In red green color blindness, individuals have a hard time distinguishing between red and green, and this simulates that effect. You can most clearly see this in a traditional test for the color deficiency.

Wednesday, March 23, 2011

Photoshop Script Tutorial and For Loops

http://www.kirupa.com/motiongraphics/ps_scripting.htm

I really liked this tutorial on Kirupa's site. It's good for beginners because it actually goes over all of the basics in scripting again like loops and arrays and variables for Java. It even goes over later in the tutorial how to use the script editor; it's the basic scripting tutorial all in one!

For writing a for loop in JavaScript, here's a simple one. It the same syntax as the code in maya.


for (a=1; a<=3; a++){ alert ("hello world") }


It will create an alert box three times when you launch it in Photoshop.

Automatic HDR image in Photoshop


This was my first try at a High-dynamic range picture using Photoshop. It was fun watching all the images getting lined up, but the image didn't turn out as good as I wanted. I had a few pictures that had details for the light outside, but it got washed out by the other pictures.
I would have uploaded the picture itself, but because it created a 32-bit color picture, it would only save it as a .tiff or a .psd. I took a screenshot of it because blogger can not upload those kinds of pictures.

Monday, March 21, 2011

Elfoid Phone



Source

So, one of the most creepy and fascinating things I've seen recently is this thing called the Elfoid P1, which is basically a phone in the shape of a creepy human doll.

It was developed at Japan's Advanced Telecommunications Research Institute. It is a miniature version of the already working Telenoid, which is a life size human robot that uses motion-capture technology to capture a person's facial expressions and body movements to convey a human presence.

The Elfoid doesn't work like the Telenoid right now, but when it does it will be like having a mini cell phone person talking to you. I think with video chatting the Skype, is there really a need for this kind of phone? I can have a better human experience with someone I can actually see, rather than a little version of them in my hand.

Sunday, March 20, 2011

Movie Review: Battle: LA


Source

I did not have a lot of interest in seeing this movie, but I thought I would see it just because nothing else was out. I saw a movie called "Skyline" last year, and I thought that it could not be worse than that movie.

The plot itself is nothing you really haven't seen before. You follow a group of marines assigned to evacuate a police station after all hell breaks loose. No one really knows what is going on, but the news reports that the invaders are really aliens. Apparently, they are here for our water, and they are exterminating all humans to get it.

I was pretty bored throughout the movie. It was hyper-violent, so after the first few explosions it was old news. The other aspect that bothered me was the "shaky-cam" like Cloverfield. I had a hard time following the action, and I had so little invested in the characters that I did not care who died.

Overall, Battle: Los Angeles is really only for big fans of action movies. I was really disappointed because you hardly even saw the aliens. They were always stuck on rooftops far away from the camera.

Movie Review: Rango


Source

So, I was finally able to catch up on some movies over the break, and my favorite that I saw was Rango.

I had wanted to see this movie ever since my theatre first got the poster last spring. I was really intrigued by Rango's design because it was so unique. Throughout the entire movie, I was impressed by all of the character designs and how good the animation was. I talked to some people who didn't like the story, but they were still impressed by how the movie looked.

What threw some people off was they thought they could bring their kids to this movie. Honestly, it is not for kids. The movie is basically a western, but animated. People automatically assume that when a movie is not live action, they can bring their five year old kids to it. Most of the references and jokes in this movie will go over their heads.

As far as the basic story goes, the main character is a wannabe actor/house pet who accidentally escapes his tank. He gets lost in the desert, and he goes on a journey to find "the spirit of the west." He finds a town called Dirt that is in the middle of a water crisis.

The best part of the movie is watching all of the amazing characters. I really liked this movie, and it's my favorite movie this year. If you really like westerns or just animation, it is definitely worth your time.

Thursday, March 3, 2011

Assignment 3 - Color Space Exploration

Part 1: Color Cube


This is the rendered out picture of the color cube. It is 8*8*8 with white and black at each end. The color cube makes sense because the colors in rgb space directly correspond with their locations in maya. Here's the mel script I used. $ballNumb is used to generalize the code:

select -all;
doDelete;
int $ballNumb = 8;

for ($z = 0; $z&lt;$ballNumb; ++$z)
{
for ($y = 0; $y&lt;$ballNumb; ++$y)
{
for ($x = 0; $x &lt;$ballNumb; ++$x)
{
$name = `shadingNode -asShader blinn`;
$name2 = $name + ".color";
setAttr $name2 -type double3 ($x/7.0) ($y/7.0)($z/7.0);
polySphere -ch on -o on -r .03;
xform -translation ($x/7.0) ($y/7.0) ($z/7.0);
hyperShade -assign $name;

}
}
}
select -cl;
;


Part 2: Two Color Wheel Variations

RGB Color Wheel:



Here's the my code for the RGB color wheel. This wheel is nice because the hues directly correspond with the angles.

select -all;
doDelete;
float $ballsAround = 30.0;
float $steps = 12.0;
float $width = 360.0/$ballsAround;
for ($i= 0;$i<$ballsAround;$i++)//angle
{
for($j=0;$j&lt;$steps;$j++) //radius or saturation
{

$angle = $i * $width; //width for each step //how much to rotate by, absolute rotate
$sat = $j*(1.0/$steps); //how much to translate by, this is the saturation hsv_to_rgb
$hue = $angle/360.0;
$name = `shadingNode -asShader blinn`;
$name2 = $name + ".color";
vector $v = hsv_to_rgb(&lt;&lt;$hue, $sat, 1>>);
setAttr $name2 -type double3 ($v.x) ($v.y) ($v.z);
polySphere -ch on -o on -r .04;
xform -translation $sat 0 0;
rotate -pivot .01 .01 .01 0 $angle 0;
hyperShade -assign $name;
}
}
;

Alternative Color Wheel: Artistic RYB Wheel





For this color wheel, the differences are instead of red and cyan compliments, red and green are compliments. Blue is across from orange instead of yellow, and magenta is across from yellow and not green. For the wheel, I separated out hue and angle from the last color wheel, so that you can set the hue independently from the angle. I manually coded the hues instead of the code doing it for me.


select -all;
doDelete;

float $numHues = 6.0; //This is for the 3 primary and complimentary colors that you know the exact hues for
float $numSats = 8.0;//These are how many different steps of saturation you want
float $numSteps = 6.0;//This is how many different arms are between the main 6 colors that you specify the hues
float $angles[7] = {0.0, 60.0, 120.0, 180.0, 240.0, 300.0, 360.0}; //this is an array that you store all the angels in. The reason 360 is last is because 0 and 360 are the same angle or the red color
float $hues[7] = {0.0, .1, .2, .35, .65, .9, 1};//this is for the hues. They're pretty much on the money for the complementary and secondary colors


for ($k = 0; $k&lt;$numHues; $k++)//this outer for loop goes through each "slice of pie" with the different colors
{
float $da = $angles[$k+1]-$angles[$k];//this is the distance between each angle. You go from the angle you will go to to the one you started at
float $dH = $hues[$k + 1]-$hues[$k];//this is the same thing, except with hue
float $sa = $da/$numSteps; //steps for each angle
float $sH = $dH/$numSteps; //hue steps
float $a1 = $angles[$k]; //this is the angle you start at
float $h1 = $hues[$k]; //this is the hue you start at at each particular hue

for ($i = 0; $i &lt;$numSteps; ++$i) //this is the for loop for the arms in between. It's like the example from the rgb color wheel
{
for ($j = 0; $j&lt;$numSats; $j++)//this is the for loop for saturation like the rgb color wheel
{
$ca = $a1 + $i *$sa; //this is your current angle. The number of arms times the width of the angle plus where you start from
$cH = $h1 + $i *$sH; //same thing for hue
$hue = $cH; //so hue is the current hue
$angle = $ca; //angle is the current angle, just so you don't have to change later coding
$sat = $j * (1.0/$numSats); //saturation is the saturation loop, and then the 1.0 is how far you wanna go / how many steps you want
//sat is the same
//all the color stuff is the same
$name = `shadingNode -asShader blinn`;
$name2 = $name + ".color";
vector $v = hsv_to_rgb(&lt;&lt;$hue, $sat, 1>>);
setAttr $name2 -type double3 ($v.x) ($v.y) ($v.z);
polySphere -ch on -o on -r .04;
xform -translation $sat 0 0;
rotate -pivot .01 .01 .01 0 $angle 0;
hyperShade -assign $name;
}

}
}

;



Part 3: Three linear transitions between complimentary colors

For the linear transitions, I took the color wheel code, and set it to only make the complimentary colors. Then, I selected the line I wanted, inverse selected everything else, deleted them, and straightened out the spheres.


Blue to Yellow:




//Blue to Yellow
select -all;
doDelete;
float $ballsAround = 12.0;
float $steps = 1.0/12.0;
float $width = 360.0/$ballsAround;
string $name;
//float $radius = 1.0;
for ($i= 0;$i<12.0;$i++)//angle
{
for($j=0;$j&lt;12.0;$j++) //radius or saturation
{

$angle = $i * $width; //width for each step //how much to rotate by, absolute rotate
$sat = $j*$steps; //how much to translate by, this is the saturation hsv_to_rgb
$hue = $angle/360.0;
$name = `shadingNode -asShader blinn`;
$name2 = $name + ".color";
vector $v = hsv_to_rgb(&lt;&lt;$hue, $sat, 1>>);
setAttr $name2 -type double3 ($v.x) ($v.y) ($v.z);
polySphere -ch on -o on -r .06;
xform -translation $sat 0 0;
rotate -pivot .01 .01 .01 0 $angle 0;
hyperShade -assign $name;
}
}
select -r pSphere1 pSphere26 pSphere27 pSphere28 pSphere29 pSphere30 pSphere31 pSphere32 pSphere33 pSphere34 pSphere35 pSphere36 pSphere98 pSphere99 pSphere100 pSphere101 pSphere102 pSphere103 pSphere104 pSphere105 pSphere106 pSphere107 pSphere108 ;
invertSelection;
doDelete;
select -r pSphere1 pSphere26 pSphere27 pSphere28 pSphere29 pSphere30 pSphere31 pSphere32 pSphere33 pSphere34 pSphere35 pSphere36 ;
rotate -pivot 0 0 0 30;
select -r pSphere98 pSphere99 pSphere100 pSphere101 pSphere102 pSphere103 pSphere104 pSphere105 pSphere106 pSphere107 pSphere108 ;
rotate -pivot 0 0 0 0 180 0;
select -cl;
;


Red to Cyan:















//Cyan To Red Code Going through White
select -all;
doDelete;
float $ballsAround = 12.0;
float $steps = 1.0/12.0;
float $width = 360.0/$ballsAround;
string $name;
//float $radius = 1.0;
for ($i= 0;$i<12.0;$i++)//angle
{
for($j=0;$j&lt;12.0;$j++) //radius or saturation
{

$angle = $i * $width; //width for each step //how much to rotate by, absolute rotate
$sat = $j*$steps; //how much to translate by, this is the saturation hsv_to_rgb
$hue = $angle/360.0;
$name = `shadingNode -asShader blinn`;
$name2 = $name + ".color";
vector $v = hsv_to_rgb(&lt;&lt;$hue, $sat, 1>>);
setAttr $name2 -type double3 ($v.x) ($v.y) ($v.z);
polySphere -ch on -o on -r .06;
xform -translation $sat 0 0;
rotate -pivot .01 .01 .01 0 $angle 0;
hyperShade -assign $name;
}
}
select -r pSphere1 pSphere2 pSphere3 pSphere4 pSphere5 pSphere6 pSphere7 pSphere8 pSphere9 pSphere10 pSphere11 pSphere12 pSphere74 pSphere75 pSphere76 pSphere77 pSphere78 pSphere79 pSphere80 pSphere81 pSphere82 pSphere83 pSphere84 ;
invertSelection;
doDelete;
select -cl;
;


Magenta to Green:













//Green to Magenta through white
select -all;
doDelete;
float $ballsAround = 6.0;
float $steps = 1.0/12.0;
float $width = 360.0/$ballsAround;
string $name;
//float $radius = 1.0;
for ($i= 0;$i<6.0;$i++)//angle
{
for($j=0;$j&lt;12.0;$j++) //radius or saturation
{

$angle = $i * $width; //width for each step //how much to rotate by, absolute rotate
$sat = $j*$steps; //how much to translate by, this is the saturation hsv_to_rgb
$hue = $angle/360.0;
$name = `shadingNode -asShader blinn`;
$name2 = $name + ".color";
vector $v = hsv_to_rgb(&lt;&lt;$hue, $sat, 1>>);
setAttr $name2 -type double3 ($v.x) ($v.y) ($v.z);
polySphere -ch on -o on -r .06;
xform -translation $sat 0 0;
rotate -pivot .01 .01 .01 0 $angle 0;
hyperShade -assign $name;
}
}

select -r pSphere1 pSphere26 pSphere27 pSphere28 pSphere29 pSphere30 pSphere31 pSphere32 pSphere33 pSphere34 pSphere35 pSphere36 pSphere62 pSphere63 pSphere64 pSphere65 pSphere66 pSphere67 pSphere68 pSphere69 pSphere70 pSphere71 pSphere72 ;
invertSelection;
doDelete;
select -r pSphere1 pSphere26 pSphere27 pSphere28 pSphere29 pSphere30 pSphere31 pSphere32 pSphere33 pSphere34 pSphere35 pSphere36 ;
rotate -pivot 0 0 0 0 180 0 ;
select -r pSphere62 pSphere63 pSphere64 pSphere65 pSphere66 pSphere67 pSphere68 pSphere69 pSphere70 pSphere71 pSphere72 ;
rotate -pivot 0 0 0 30;
select -cl;
;

Part 4: Two "non-linear" transitions between complementary colors

For the two "non-linear" transitions, I did it a different way than the linear ones. Instead of using my color wheel code, I used the color cube code from earlier. I made the color wheel, and selected colors around the edges, so that there was no way the colors could go through grey. Then I inverse selected the others, deleted them, and straightened out the spheres.

Red to Cyan:






//teal to red with no white
select -all;
doDelete;
int $ballNumb = 8;

for ($z = 0; $z&lt;$ballNumb; ++$z)
{
for ($y = 0; $y&lt;$ballNumb; ++$y)
{
for ($x = 0; $x &lt;$ballNumb; ++$x)
{
$name = `shadingNode -asShader blinn`;
$name2 = $name + ".color";
setAttr $name2 -type double3 ($x/7.0) ($y/7.0)($z/7.0);
polySphere -ch on -o on -r .06;
xform -translation ($x/7.0) ($y/7.0) ($z/7.0);
hyperShade -assign $name;

}
}
}
select -r pSphere8 pSphere16 pSphere24 pSphere32 pSphere40 pSphere48 pSphere56 pSphere57 pSphere58 pSphere59 pSphere60 pSphere61 pSphere62 pSphere63 pSphere64 pSphere121 pSphere185 pSphere249 pSphere313 pSphere377 pSphere441 pSphere505 ;
invertSelection;
doDelete;
select -r pSphere57 pSphere121 pSphere185 pSphere249 pSphere313 pSphere377 pSphere441 pSphere505 ;
rotate -pivot 0 1 0 0 -90 0;
select -r pSphere8 pSphere16 pSphere24 pSphere32 pSphere40 pSphere48 pSphere56 pSphere64 ;
rotate -pivot 1 1 0 0 0 90;
select -cl;
;

Green to Magenta:

//green to magenta with no white
select -all;
doDelete;
int $ballNumb = 8;

for ($z = 0; $z&lt;$ballNumb; ++$z)
{
for ($y = 0; $y&lt;$ballNumb; ++$y)
{
for ($x = 0; $x &lt;$ballNumb; ++$x)
{
$name = `shadingNode -asShader blinn`;
$name2 = $name + ".color";
setAttr $name2 -type double3 ($x/7.0) ($y/7.0)($z/7.0);
polySphere -ch on -o on -r .06;
xform -translation ($x/7.0) ($y/7.0) ($z/7.0);
hyperShade -assign $name;

}
}
}
select -r pSphere57 pSphere121 pSphere185 pSphere249 pSphere313 pSphere377 pSphere441 pSphere449 pSphere450 pSphere451 pSphere452 pSphere453 pSphere454 pSphere455 pSphere456 pSphere457 pSphere465 pSphere473 pSphere481 pSphere489 pSphere497 pSphere505 ;
invertSelection;
doDelete;
select -r pSphere57 pSphere121 pSphere185 pSphere249 pSphere313 pSphere377 pSphere441 pSphere449 pSphere457 pSphere465 pSphere473 pSphere481 pSphere489 pSphere497 pSphere505 ;
rotate -pivot 0 0 0 0 0 90;
select -r pSphere57 pSphere121 pSphere185 pSphere249 pSphere313 pSphere377 pSphere441 pSphere505 ;
rotate -pivot -1 0 1 0 90 0 ;
select -cl;
;

Part 5: Novel use of color
So, for this part I wanted to think about camera's saw color, and how that could be affected through the white balance. First, I found a picture that I thought expressed a good use of color harmony in nature.


http://www.flickr.com/photos/txross/3921853686

Here's the link to the original picture
This picture and flower makes a really cool transition between the natural complementary colors of yellow in the middle and blue on the outside. Wanted to experiment with the white balance on my camera and see if I could in a way effect the transition between the two, and maybe help show a forbidden color.

So, this was the first picture with the automatic white balance.

Then I changed the white balance to think that red was white, and it turned this cyan color. There wasn't any difference that I saw in the picture.
Next I set the balance to cyan, and everything looked sort of pink. I didn't expect there to be a difference, but I wanted to try it anyway.


Here, I set the balance to think yellow was white. Nothing really changed except everything looked bluer.



Then I set the balance to blue. All it did was make the flower and everything else more orange.




Here I changed it to magenta. It made everything green, so I thought that if you could stare at it long enough you could see the imaginary color, but I didn't see anything.

The last one I could try of the primary colors and their compliments was green, so everything turned into magenta.

The picture itself has amazing color harmony going from yellow to blue, though looking at it with the camera, the transition mostly goes through black and not a color where I could try to show the impossible bluish-yellow. The flower is gorgeous and demonstrates color harmony in nature. Though I coudn't show the color, it was interesting to demonstrate how the camera sees color through the different white balances.