Sunday, April 17, 2011

Journal Post 11

I made a simple script that takes a sequence of photos and combines them into a movie using ffmpeg. Donovan actually showed me the script, then I made a version specific to my computer. It's really basic, but it's been a big help so far working on the Haley film. I often have to render out my current progress on composites and post it to the Haley blog. Before I would render out my composite as a png sequence and then import to After Effects. Using ffmpeg quickens that process by a lot, plus the file size is super small. It will create a 1080p clip that's only around 1mb, without loosing any quality that I can tell.

Script:

#!/bin/bash

cd ~

cd /Users/Colin/Haley/2-16/png2

ffmpeg -i Scene2_shot_16_1%03d.png -r 24 -b 2000000 -vcodec libx264 -vpre hq -vpre normal test.Scene_2_1.mp4

Monday, April 11, 2011

Assignment 4.1 (complete)

Part 2

Here's the code for the color blind script I finally finished. I believe this is what you call a Deuteranopia color blindness, affecting someone's ability to distinguish red and green. What I did was create 2 copies of the background layer then use a channel mixer to make a red and green channel from the copies of the original image. I then merged them together and set them as the new red and green channels.

//Color blindness

var curDoc = activeDocument

//create the layer for the red channel
var layerRed = curDoc.artLayers.add()
layerRed.name = "Red Channel"

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

//channel mixer
var idChnM = charIDToTypeID( "ChnM" );
var desc30 = new ActionDescriptor();
var idpresetKind = stringIDToTypeID( "presetKind" );
var idpresetKindType = stringIDToTypeID( "presetKindType" );
var idpresetKindFactory = stringIDToTypeID( "presetKindFactory" );
desc30.putEnumerated( idpresetKind, idpresetKindType, idpresetKindFactory );
var idUsng = charIDToTypeID( "Usng" );
desc30.putPath( idUsng, new File( "/Applications/Adobe Photoshop CS5/Presets/Channel Mixer/Black & White with Red Filter (RGB).cha" ) );
executeAction( idChnM, desc30, DialogModes.NO );


//create the layer for the green channel

var layerGreen = curDoc.artLayers.add()
layerGreen.name = "Green Channel"

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

//channel mixer
var idChnM = charIDToTypeID( "ChnM" );
var desc4049 = new ActionDescriptor();
var idpresetKind = stringIDToTypeID( "presetKind" );
var idpresetKindType = stringIDToTypeID( "presetKindType" );
var idpresetKindFactory = stringIDToTypeID( "presetKindFactory" );
desc4049.putEnumerated( idpresetKind, idpresetKindType, idpresetKindFactory );
var idUsng = charIDToTypeID( "Usng" );
desc4049.putPath( idUsng, new File( "/Applications/Adobe Photoshop CS5/Presets/Channel Mixer/Black & White with Green Filter (RGB).cha" ) );
executeAction( idChnM, desc4049, DialogModes.NO );

var globalOpacity = 50.0;
layerGreen.opacity = globalOpacity;

//Merge layers
var idMrgtwo = charIDToTypeID( "Mrg2" );
var desc243 = new ActionDescriptor();
executeAction( idMrgtwo, desc243, DialogModes.NO );

curDoc.selection.selectAll()
curDoc.selection.copy()
curDoc.activeLayer.remove()

//paste the combined red/green channel into the red channel.
redChannel = new Array(curDoc.channels[0])
curDoc.activeChannels = redChannel

activeDocument.paste();

//paste the combined red/green channel into the green channel.
greenChannel = new Array(curDoc.channels[1])
curDoc.activeChannels = greenChannel

activeDocument.paste();

//make all three channels visible again
activeDocument.activeChannels = activeDocument.componentChannels

//save file
curDoc.flatten();
saveFile = new File("//color_blind_image.jpg");
saveOptions = new JPEGSaveOptions();
saveOptions.embedColorProfile = true;
saveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
saveOptions.matte = MatteType.NONE;
saveOptions.quality = 9;
curDoc.saveAs(saveFile, saveOptions, true,Extension.LOWERCASE);


I had to use code from the script listener a couple times because I couldn't find or figure out how to do it otherwise. I used it for the channel mixer command and for merging layers.

Thursday, April 7, 2011

Assignment 4.2 (continued)

Part 2

There were a couple tutorials that I really liked. I'll choose this one as the best because it shows you a basic program, which is a little guessing game.



This video goes over if statements and how to use the less-than, equal, greater-than, etc. Here's the code for the guessing game:


clear
ANSWER = $RANDOM

while [1]; do
{
echo "Enter your guess (number): "
read USER_GUESS
if [ $USER_GUESS -eq $ANSWER ]; then
{
echo "Correct guess."
exit 0
}
elif [ $USER_GUESS -gt $ANSWER ]; then
{
echo "Too high. Try again."
}
else
{
echo "Too low. Try again."
}
fi
}
done


I wanted to mention this video as well:

http://www.youtube.com/watch?v=QGvvJO5UIs4

This one was nice because it showed you how to easily create and modify text files. This was something that other tutorials didn't cover, or they had you open up a text editor, which you don't really need to do. You just type:

nano file_name.sh

and then it takes you into the file to edit it. To quit and save the file you press control X and it takes you back to the normal terminal. To run the script, you type:

./file_name.sh

Pretty simple. It also teaches you how to write a simple script that asks for user input then stores what you typed into a separate text file. Here's the code:


#!/bin/bash

clear
echo "Welcome"
sleep 2
echo "how is your day going?"
read ans

clear
echo "you typed $ans"
echo "$ans" >> ans.txt

cat ans.txt

Wednesday, April 6, 2011

Assignment 4.2

Part 1.

The best Bash shell tutorial I found was this one here:

http://www.youtube.com/watch?v=N4wKqsMJqnw

It actually doesn't go over that many commands that you can use in the Terminal, but we learned a lot of that in class. This video shows you how to be more productive when working in Bash. You can move the cursor left and right a whole word using alt F and B, respectively. You have to make sure "use option as meta key" is turned on under the preferences though. You can also search your history for any commands you had typed before using command R.

Sunday, April 3, 2011

Journal Post 10

I thought the idea of a home-made infrared camera was really cool, so I looked up some videos. This video uses a method that Joe described in class using negative strips.



This video here shows a way of seeing in the dark using red and blue sulafane cutouts placed in front of a flashlight's lens and then shining the flashlight while looking through the lens of a camera. I guess the sulafane layers are too thick for normal light to pass through, but not infrared. The video says you need an older camera to make this work though (from the 90s).

Assignment 4.1 (continued)

Part 1.

I honestly haven't been able to find any very helpful video tutorials online for Photoshop javascript, but there have been some web pages that have helped a ton. The most useful one for me was this site here:

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

This tutorial is actually several pages long. It goes through basic operations such as creating new layers/documents, making loops, merging layers, and making selections. After reading this and the Scripting Guide I was able to get a pretty good start on the color blind image. Neither of them were able to help me with some of the more specific problems I had though, such as coping a channel into a layer or using the channel mixer command.

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()