Friday, May 13, 2011

Test project and Final Project

Since I didn't understand how to get the for loop to work, I tried the while loop, which I did understand, but it doesn't work either. Below is my code. I took a video and tried to dump the frames out while writing the frame numbers on it. I then tried to compile it back into a mov file, but I always get this error: could not get frame filename from pattern. Something was wrong with the formats. Perhaps one of the previous videos I put in a blog post could serve as my final. I worked hard on them and accomplished the effect I put on them using ffmpeg.

Here is my code:

66 cd Final\ Project/
67 ffmpeg -i BPnm.mp4 -ss 00:06:00 -t 00:06:30 finalprojectvideo.mov
68 ffmpeg -i BPnm.mp4 -vcodec copy -acodec copy -ss 00:06:00 -t 00:06:30 finalprojectvideo.mov
69 ffplay finalprojectvideo.mov
70 cd frames
71 ffmpeg -i BPnm.mp4 -vcodec copy -an -ss 00:03:00 -t 00:00:30 finalprojectvideo.mov
72 ffmpeg -i finalprojectvideo.mov -f image2 fp-%05d.png;
73 ffplay finalprojectvideo.mov
74 for ((img in images)); do mogrify edge 2 fp-%05d.png
75* for ((img in images)); do mogrify edge 2 fp-%05d.png; done2
76 for ((i = 1; i<900; ++i)); do echo "hi $i"; done
77 frames = 900; for ((i = 1; i<frames; ++i)); do echo "hi $i"; done
78 frames = 900; for ((i = 1; i<$frames; ++i)); do echo "hi $i"; done
79 frames = 900; for ((i = frame; i<$frames; ++i)); do echo "hi $i"; done
80 for ((i = 1; i<900; i++)); do
81 for ((i = 1; i<900; i++)); do frames= `printf "fp-%05d.png" $ i`; edge = `printf "%05d-edge.png" $i`; echo "Converting $frames to $edge"; convert -draw `text 100,100 "$i"`; convert $frames -edge 2 $edge; done
82 y=25;for ((x = 1; x>$y; ++x)); do echo $x; done
83 ffmpeg -i finalprojectvideo.mov -f image2 %05d-frames.png; let i=1;while [ i -lt 900 ]; do echo '$i';convert -draw "text 100,100 '$i'"; done
84 ffmpeg -i finalprojectvideo.mov -f image2 %05d-frames.png; let i=1;while [ i -lt 900 ]; do echo '$i';convert -draw "text 100,100 '$i'"; done; ffmpeg -i %05d-frames.png -f image 2 final.mov
85 ffmpeg -i finalprojectvideo.mov -f image2 %05d-frames.png; let i=1;while [ i -lt 900 ]; do echo '$i';convert -draw "text 100,100 '$i'"; done; ffmpeg -i %05d-frames.png -f image2 final.mov
86 history > frames2.txt

87 let x=1; echo $x;
88 i=10; echo `$i`
89 i=10; echo `$i'
90 i=10; echo '$i'
91 i=10; echo "$i"
92 ffmpeg -i finalprojectvideo.mov -f image2 %05d-frames.png; let i=1;while [ i -lt 900 ]; do echo '$i';convert -draw "text 100,100 '$i'"; done; ffmpeg -i %05d-frames.png -f image2 final.mov
93 history >> frames2.txt

94 ffmpeg -i finalprojectvideo.mov -f image2 %05d-frames.png; let i=1;while [ i -lt 900 ]; do echo "$i";convert -draw "text 100,100 '$i'"; done; ffmpeg -i %05d-frames.png -f image2 final.mov
95 history >> frames2.txt

Assignment 4.1 - Photoshop Tutorial and Color Blind Image Scripting-Week 11

Part 1:

Week 9- Best Tutorial Recommendation- For Loops in Photoshop Javascript

This website: http://babbage.cs.qc.edu/courses/cs081/Javascript_Tutorial/index.xhtml#navTarget_2
has the fundamental breakdown on Javascript concepts.

The example in this tutorial discusses that for loops can be employed to use arrays in various ways.
Addition of simple variable numbers in an array is the utilization for this example. First, the selected numbers have to be chosen and put into an array, which is not shown in the example. The variable sum will hold the added amount of all the variables from within the array. Sum has been declared at the top of the for loop to be recognized and used later on. The variable i within the for loop is a generic variable used as a counter also called a loop control variable. The variable i is used three times in the first line of the for loop. The value is always set to zero because that is the number programmers always use to and signifies the beginning of array elements and for loops . An ending has to be specified as well. This for loop can run the number of times stated in the array defined, which is four. The method call anArray.length measures the amount of elements in the for loop, which becomes the amount of times the for loops functions.  Lastly, i++ is the code that specifies that i should add one to every element in the array and add the element values, as demonstrated by the linking of  i to the array in the statement anArray[i].

This is the full code I came up with after I changed the numbers in the example and reviewed the loops and
arrays section also provided on the website. I set up four variables for numbers in the array and the array itself. I made the mistake the first time of not properly declaring the type var for the loop and the array and the new type for the array as well. The types of everything have to be defined in a similar manner to regular Java programming, which I learned from my Java class last semester and made me familiar with for loops and their functions.

//For loop array example with a result of 135.
Every element value in the array is added to the
one before to come out with the result of 135.

var a= 20; //element 0, #1
var b= 35;// element 1, #2
var c= 55; //element 2, #3
var d = 25; //element 3, #4

var anArray = new Array (a, b, c, d);
var sum = 0;
for (var i = 0; i < anArray.length; i++)
{
           sum = sum + anArray[i];
}

Part 2-Photoshop Script:

// Accesses the red channel by selecting it
var channelRef = app.activeDocument.channels.getbyName("red");
channelRef.opacity = 100;
var idslct = charIDToTypeID( "slct" );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRd = charIDToTypeID( "Rd  " );
        ref4.putEnumerated( idChnl, idChnl, idRd );
    desc5.putReference( idnull, ref4 );
executeAction( idslct, desc5, DialogModes.NO );

//Duplicate the red channel
var idDplc = charIDToTypeID( "Dplc" );
    var desc6 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref5 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref5.putEnumerated( idChnl, idOrdn, idTrgt );
    desc6.putReference( idnull, ref5 );
executeAction( idDplc, desc6, DialogModes.NO );

// select the green channel
var channelRef = app.activeDocument.channels.getbyName("green");
channelRef.opacity = 100;
var idslct = charIDToTypeID( "slct" );
    var desc7 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref6 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idGrn = charIDToTypeID( "Grn " );
        ref6.putEnumerated( idChnl, idChnl, idGrn );
    desc7.putReference( idnull, ref6 );
executeAction( idslct, desc7, DialogModes.NO );

//Duplicate the green channel
var idDplc = charIDToTypeID( "Dplc" );
    var desc8 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idChnl, idOrdn, idTrgt );
    desc8.putReference( idnull, ref7 );
executeAction( idDplc, desc8, DialogModes.NO );

// Make the red channel into a layer.

//select the Red copy
var idslct = charIDToTypeID( "slct" );
    var desc9 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref8.putName( idChnl, "Red copy" );
    desc9.putReference( idnull, ref8 );
executeAction( idslct, desc9, DialogModes.NO );

//Go to the select menu and choose All
var idsetd = charIDToTypeID( "setd" );
    var desc10 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref9 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref9.putProperty( idChnl, idfsel );
    desc10.putReference( idnull, ref9 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idAl = charIDToTypeID( "Al  " );
    desc10.putEnumerated( idT, idOrdn, idAl );
executeAction( idsetd, desc10, DialogModes.NO );

//Go to the Edit menu and select copy
var idcopy = charIDToTypeID( "copy" );
executeAction( idcopy, undefined, DialogModes.NO );
//Go to the Select menu and choose Deselect
var idsetd = charIDToTypeID( "setd" );
    var desc11 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref10 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref10.putProperty( idChnl, idfsel );
    desc11.putReference( idnull, ref10 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc11.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc11, DialogModes.NO );

//Go to Select  > Deselect
var idsetd = charIDToTypeID( "setd" );
    var desc27 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref27 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref27.putProperty( idChnl, idfsel );
    desc27.putReference( idnull, ref27 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc27.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc27, DialogModes.NO );

//Select all the Channels for the overall image
var idslct = charIDToTypeID( "slct" );
    var desc22 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref23 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref23.putEnumerated( idChnl, idChnl, idRGB );
    desc22.putReference( idnull, ref23 );
executeAction( idslct, desc22, DialogModes.NO );

//Go to Edit >Paste to Paste the channel into a layer.
var idpast = charIDToTypeID( "past" );
    var desc23 = new ActionDescriptor();
    var idAntA = charIDToTypeID( "AntA" );
    var idAnnt = charIDToTypeID( "Annt" );
    var idAnno = charIDToTypeID( "Anno" );
    desc23.putEnumerated( idAntA, idAnnt, idAnno );
executeAction( idpast, desc23, DialogModes.NO );

// Make the green channel into a layer.

//Select the Green channel layer
var idslct = charIDToTypeID( "slct" );
    var desc25 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref25 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        ref25.putName( idChnl, "Green copy" );
    desc25.putReference( idnull, ref25 );
executeAction( idslct, desc25, DialogModes.NO );

//Go to Select menu and choose All
var idsetd = charIDToTypeID( "setd" );
    var desc26 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref26 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref26.putProperty( idChnl, idfsel );
    desc26.putReference( idnull, ref26 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idAl = charIDToTypeID( "Al  " );
    desc26.putEnumerated( idT, idOrdn, idAl );
executeAction( idsetd, desc26, DialogModes.NO );

//Go to Edit and Select Copy
var idcopy = charIDToTypeID( "copy" );
executeAction( idcopy, undefined, DialogModes.NO );

//Go to Select  > Deselect
var idsetd = charIDToTypeID( "setd" );
    var desc27 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref27 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref27.putProperty( idChnl, idfsel );
    desc27.putReference( idnull, ref27 );
    var idT = charIDToTypeID( "T   " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idNone = charIDToTypeID( "None" );
    desc27.putEnumerated( idT, idOrdn, idNone );
executeAction( idsetd, desc27, DialogModes.NO );

//Select all the color channels
var idslct = charIDToTypeID( "slct" );
    var desc28 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref28 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idChnl = charIDToTypeID( "Chnl" );
        var idRGB = charIDToTypeID( "RGB " );
        ref28.putEnumerated( idChnl, idChnl, idRGB );
    desc28.putReference( idnull, ref28 );
executeAction( idslct, desc28, DialogModes.NO );

//Go to Edit > Paste
var idpast = charIDToTypeID( "past" );
    var desc29 = new ActionDescriptor();
    var idAntA = charIDToTypeID( "AntA" );
    var idAnnt = charIDToTypeID( "Annt" );
    var idAnno = charIDToTypeID( "Anno" );
    desc29.putEnumerated( idAntA, idAnnt, idAnno );
executeAction( idpast, desc29, DialogModes.NO );

// Create the average of the two images in Photoshop.

// Drop opacity on Layer one (red) to 50%.
var idslct = charIDToTypeID( "slct" );
    var desc151 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref144 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        ref144.putName( idLyr, "Layer 2" );
    desc151.putReference( idnull, ref144 );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc151.putBoolean( idMkVs, false );
executeAction( idslct, desc151, DialogModes.NO );

app.activeDocument.activeLayer.fillOpacity = 50;

// Select Screen in the Layers Panel.
LayerSet.properties.blendmode(screen);

// Merge Down both layers into one yellow one.
var idslct = charIDToTypeID( "slct" );
    var desc185 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref170 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        ref170.putName( idLyr, "Layer 3" );
    desc185.putReference( idnull, ref170 );
    var idMkVs = charIDToTypeID( "MkVs" );
    desc185.putBoolean( idMkVs, false );
executeAction( idslct, desc185, DialogModes.NO );

var idMrgtwo = charIDToTypeID( "Mrg2" );
    var desc186 = new ActionDescriptor();
executeAction( idMrgtwo, desc186, DialogModes.NO );

This is the result:


















http://www.ehow.com/how_5894621_average-two-images-photoshop.html
http://www.ehow.com/how_5918950_convert-channel-layer-photoshop.html
I used these two websites and notes from class to solve the problem.

Assignment 3 - Second Attempt

RGB Color Cube



















RGB Color Cube Code:

string $name;
string $tmp;
for ($x=0; $x<8; $x++)
{
    for ($y=0; $y<8; $y++)
    {
        for ($z=0; $z<8; $z++)
        {
            $name = `shadingNode -asShader blinn`;
            $tmp = $name + ".color";//blinnShader1.color
            setAttr $tmp -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;
        }
    }
}

RGB Color Wheel

I have created many forms of this color wheel. Here are a few variations. I want to demonstrate that I put some effort into this color wheel.



















In the following code, I decreased the $numHues variable by 10 points
and increased the $numSat variable by 10 points.

string $name;
string $tmp;
$numHues = 20.0;
$numSat= 40.0;
$w= 360.0/$numHues;//width
$s = 1.0/$numSat;
$value = 1.0; //a constant, value w.r.t. hsv color

for ($i=0; $i<$numHues; $i++)//colors, steps around the circle
{
         for($j=0; $j<$numSat; $j++)//saturation, number of rings
         {
                 $angle = $i * $w; //rotate ball
                 $sat = $j * $s; // translate by number
                 $hue = $angle/360.0;
                 vector $v = <<$hue, $sat, $value>>;
                 $name = `shadingNode -asShader blinn`;
                 $tmp = $name + ".color";//blinnShader1.color
                 vector $c = hsv_to_rgb($v);
                 setAttr $tmp -type double3 ($c.x) ($c.y) ($c.z);
                 polySphere -ch on -o on -r 1;
                 xform -translation ($sat * 10) 0 0;
                 rotate -p 0 0 0 -ws  0 $angle 0 ;
                 hyperShade -assign $name;
         }
}

Expansive Pinwheel


















I used ($numHues = 30.0) to generate the amount of branches of color seen in this image.
I was also trying to generate a wider spectrum of saturation, which is the reason for the
30 steps in saturation ($numSat = 30.0). I multiplied the $sat variable by a larger number,
 perhaps 20 to create more space in between the branches of hue.

// I saved all the code variations to a Mel file which will not load into Maya because it could not read the file name. In all the variations, I only increase or decreased four variables: $numHues, $numSat,
polySphere -ch on -o on -r 1 (the #1 on this line of code), and xform -translation ($sat * 10) 0 0 ($sat * number on this line of code).
Here are some other variations I experimented with:

Original Pinwheel













The Balloon

The Donut

The Donut is one in which I changed the saturation to make it less white throughout the wheel. However, it ended up containing a muted, pastel color palette.

Experimenting with this produced the following code and result.

Lord of the Rings
string $name;
string $tmp;
$numHues = 30.0;
$numSat= 2.0;
$w= 360.0/$numHues;//width
$s = 1.0/$numSat;
$value = 1.0; //a constant, value w.r.t. hsv color
        
for ($i=0; $i<$numHues; $i++)//colors, steps around the circle
{
         for($j=0; $j<$numSat; $j++)//saturation, number of rings
        {
                   $angle = $i * $w; //rotate ball
                   $sat = $j * $s; // translate by number
                   $hue = $angle/360.0;
                   vector $v = <<$hue, $sat, $value>>;
                   $name = `shadingNode -asShader blinn`;
                   $tmp = $name + ".color";//blinnShader1.color
                   vector $c = hsv_to_rgb($v);
                   setAttr $tmp -type double3 ($c.x) ($c.y) ($c.z);
                   polySphere -ch on -o on -r .5;
                   xform -translation ($sat * 10) 0 0;
                   rotate -p 0 0 0 -ws  0 $angle 0 ;
                   hyperShade -assign $name;
           }
}

I think based on the setting of 2.0 for $numSat and that $s divides 1 by 2, Maya only recognized the white hue and the various hues around the color wheel and none of the saturation in between. However, nine white spheres were produced in the center.

Artistic Color Wheel

My first legitimate progress for this color wheel:



Second Attempt:
I have no idea why I was getting a strictly light blue color.

I experimented with the code in the $hues array for the artistic color wheel. Adding seven elements to the array as floats from 0 to 1 and divided by 360.0 kept giving me a completely red color wheel, even though I made sure to delete all prior creations. My next step was to change the values in the array.

float $hues[7] = {0.0, 0.02, 0.04, 0.06, 0.08, 0.093, .01};//two decimal places

This was the result (red to orange to red):

float $hues[7] = {0.0, 0.2, 0.4, 0.6, 0.8, 0.93, .1};//one decimal place

float $hues[7] = {0.0, 0.02, 0.4, 0.06, 0.8, 0.093, .1};//one and two decimal places.

I have accomplish getting significant red and orange sections of the wheel.
Artistic Color Wheel




select -all;//select everything previously created within the Maya interface.
doDelete;//deletes everything selected from the interface.

//below is the hardcoded color values which are vectors, however they aren't being used.
//$red = <<1,0,0>>;//equal to 0 and 1
//$orange = <<1, .5, 0>>;//.05
//$yellow = <<1, 1, 0>>;//.2
//$green = <<0, 1, 0>>;//.4
//$blue = <<0, 0, 1>>; //.8
//$magenta = <<1, 0, 1>>;//.95

string $name;//the string type variable that will be used in the saturation for loop.
string $tmp;//the string type variable that will also be used in the saturation for loop.

float $numHues = 3.0;//this is the number btw primary and secondary.
float $numSat = 10.0;//num of divisions of saturation from the outside to the inside of the color wheel.
//set angle number that corresponds to each of the 6 angles in the color wheel.
float $angle[7] = {0.0, 60.0, 120.0, 180.0, 240.0, 300.0, 360.0};
//set number for hues that correesponds to each color in the artistic color wheel.

float $hues[7] = {0.0, .05, .2, .4, .8, .95, 1.0 };

float $s = 1.0/$numSat;//steps in saturuations decrceasing from brightest color to white.
float $value = 1.0;//value of color has no depth, it equals one.

//the variable k is the position of within the array of angle and hue for the primary and secondary colors.
for ($k=0; $k<6; ++$k)
{
         $dHue = $hues[$k + 1] - $hues[$k];//distance of hue defined by the increments of the &hues array.
         $dAngle = $angle[$k +1] - $angle[$k];//distance of angle defined by the increments of the &angle array.
         $sh = $dHue/$numHues;
         $sa = $dAngle /$numHues;
         $a1 = $angle[$k];//starting angle
         $h1 = $hues[$k];//starting hue
        
         for ($i=0; $i<$numHues; ++$i)//hue for loop
         {
                  for($j=0; $j<$numSat; ++$j)//saturation for loop
                  {  
                          $ca = $a1 + $i * $sa;
                          //adds the starting angle to increments in i, then multiplies it by the steps
                          //in angle.
                          $ch = $h1 + $i * $sh;
                          //the current hue plus the increment to the next primary or secondary color.  
                     
                          $angles = $ca; //rotate ball; set angles to current angle
                          $sat = $j * $s; // translate by number-saturation
                          $hue = $ch;//hue equals current hue.
                     
                          //holds three values of previously calculated hue, saturation, and value.
                          vector $v = <<$hue, $sat, $value>>;
                          $name = `shadingNode -asShader blinn`;//holds the shading node
                          $tmp = $name + ".color";
                          //blinnShader1.color ; combines blinn shading node and color together.
                          vector $c = hsv_to_rgb($v);
                          //sets the hue, sat, value vector equal to rgb color and stores it in c. 

                         //sets $tmp to have attributes of three dimensional color with c(x, y, z);
                         setAttr $tmp -type double3 ($c.x) ($c.y) ($c.z);
                         //double3 is the type that holds 3 dimensions.

                         polySphere -ch on -o on -r .5;//creates sphere and size of sphere
                    
                        //translates in three directions(x, y, z); saturation is increase by 10 in the x direction.
                        xform -translation ($sat * 10) 0 0;   
    
                         //this pivots the spheres around the origin and rotate them in the world space
                         //through x, y, z- y is the current angle. 
                         rotate -p 0 0 0 -ws 0 $angles 0;   
                         hyperShade -assign $name;//sets the hypershade to the variable $name.

                 }
         }
}


Looking at my classmate Tess' blog helped a lot in understanding the code. 

I was totally lost with the following code:

$dHue = $hues[$k + 1] - $hues[$k];//distance of hue defined by the increments of the &hues array.
$dAngle = $angle[$k +1] - $angle[$k];//distance of angle defined by the increments of the &angle array.
 $sh = $dHue/$numHues;
 $sa = $dAngle /$numHues;
 $a1 = $angle[$k];//starting angle
 $h1 = $hues[$k];//starting hue

for($j=0; $j<$numSat; ++$j)//saturation for loop
{            $ca = $a1 + $i * $sa;
             //adds the starting angle to increments in i, then multiplies it by the steps in angle.
             $ch = $h1 + $i * $sh;//the current hue plus the increment to the next primary or secondary color.
             $angles = $ca; //rotate ball; set angles to current angle
              $hue = $ch;//hue equals current hue.
}

This little chunk of code was very confusing to me. I thought I was logically solving the problem, but I realized I was nowhere near the ball park of figuring it out. Professor Kniss and Tess's code helped me realize the problem.
The problem was that I didn't know how the variables I created functioned with respect to the rest of the code.  
I couldn't connect the functions together to make the code run smoothly. Knowing how all the pieces of code work and fit together will make the process much easier. I also think I over think some steps of the process and it distracts from what really need to be done.  

Three linear transitions-Complementary Colors:
My first succesful attempt at the transition from red to cyan linear color space.




















string $name;//the string type variable that will be used in the saturation for loop.
string $tmp;//the string type variable that will also be used in the saturation for loop.

$numHues = 3.0;//this is the number btw primary and secondary.
$numSat = 10.0;//num of divisions of saturation from the outside to the inside of the color wheel.

$w = 180.0;
$s = 1.0/$numSat;//steps in saturuations decrceasing from brightest color to white.
$value = 1.0;//value of color has no depth, it equals one.

for ($i=0; $i<$numHues; ++$i)//hue for loop
{
         for($j=0; $j<$numSat; ++$j)//saturation for loop
        {  
                float $angle = $i * $w;
                float $sat = $j * $s; // translate by number-saturation
                float $hue = $angle/360.0;//hue is rotated by angle / rotatation value.
                vector $v = <<$hue, $sat, $value>>;
                //holds three values of previously calculated hue, saturation, and value.
                $name = `shadingNode -asShader blinn`;//holds the shading node
                $tmp = $name + ".color";//blinnShader1.color ; combines blinn shading node and color together.
                vector $c = hsv_to_rgb($v);//sets the hue, sat, value vector equal to rgb color and stores it in c. 
                setAttr $tmp -type double3 ($c.x) ($c.y) ($c.z);
                //sets $tmp to have attributes of three dimensional color with c(x, y, z);
                //double3 is the data type that holds 3 dimensions.
                polySphere -ch on -o on -r .5;//creates sphere and size of sphere
                xform -translation ($sat * 10) 0 0;
                //translates in three directions(x, y, z); saturation is increase by 10 in the x direction.
                 rotate -p 0 0 0 -ws 0 $angle 0 ;
                 hyperShade -assign $name;//sets the hypershade to the variable $name.

           }
}























































//Jennifer Granger
//Linear Transition from yellow to white to blue.
{
      float $numSteps = 5.0;
      float $startSat = 1.0;
      float $endSat = 0.0;
      float $distSat= $endSat - $startSat;
      float $startPos = 0.0;
      float $endPos = 5.0;
      float $distPos= $endPos - $startPos;
      for ($i=0; $i<$numSteps; ++$i)
     {
              float $curSat = $startSat + $i * $distSat/$numSteps;
              float $curPos = $startPos + $i * $distPos/$numSteps;
              vector $hsv = <<.15, $curSat, 1>>;
              vector $rgb = hsv_to_rgb($hsv);
             $shader = `shadingNode -asShader blinn`; //the variable stores the shading node
             $attr = $shader + ".color";
             //blinnShader1.color-combines blinn shading node with the color for the objects.
             setAttr $attr -type double3 ($rgb.x) ($rgb.y) ($rgb.z);
             //sets $attr to have attributes of three dimensional color with c(x, y, z);
             polySphere -ch on -o on -r .5; //creates the sphere and size of sphere.
             xform -translation $curPos 0 0;//translates in three dimensions(x, y, z).
             hyperShade -assign $shader;
            //sets the hypershade to the variable $shader and sets it on the polysphere. 
      }

       float $numSteps = 5.0;
       float $startSat = 0.0;
       float $endSat = 1.0;
       float $distSat= $endSat - $startSat;
       float $startPos = 5.0;
       float $endPos = 10.0;
       float $distPos= $endPos - $startPos;
       for ($i=0; $i<$numSteps; ++$i)
      {
             float $curSat = $startSat + $i * $distSat/$numSteps;
             float $curPos = $startPos + $i * $distPos/$numSteps;
             vector $hsv = <<.65, $curSat, 1>>;
             vector $rgb = hsv_to_rgb($hsv);
             $shader = `shadingNode -asShader blinn`; //the variable stores the shading node
             $attr = $shader + ".color";
             //blinnShader1.color-combines blinn shading node with the color for the objects.
             setAttr $attr -type double3 ($rgb.x) ($rgb.y) ($rgb.z);
             //sets $attr to have attributes of three dimensional color with c(x, y, z);
             polySphere -ch on -o on -r .5; //creates the sphere and size of sphere.
             xform -translation $curPos 0 0;//translates in three dimensions(x, y, z).
             hyperShade -assign $shader;
              //sets the hypershade to the variable $shader and sets it on the polysphere. 
       }
}

Non-linear Transitions:

http://msdn.microsoft.com/en-us/library/ms536848(v=vs.85).aspx

Complimentary colors in HSV space form a straight line, such as yellow and violet, green and red, and blue and orange.

//Jennifer Granger
//Non-linear transitions



















         float $numSteps = 10.0;
         float $startHue = 0.1;// orange
         float $endHue= 0.6; //blue
         float $distHue= $endHue - $startHue;
         float $startPos =10.0;
         float $endPos = 0.0;
         float $distPos= $endPos - $startPos;
         for ($i=0; $i<$numSteps; ++$i)
        {
                  float $curHue = $startHue + $i * $distHue/$numSteps;
                  float $curPos = $startPos + $i * $distPos/$numSteps;
                  vector $hsv = <<$curHue, 1, 1>>;
                  vector $rgb = hsv_to_rgb($hsv);
                  $shader = `shadingNode -asShader blinn`;
                  //the variable stores the shading node
                  $attr = $shader + ".color";
                  //blinnShader1.color-combines blinn shading node
                  // with the color for the objects.
                 setAttr $attr -type double3 ($rgb.x) ($rgb.y) ($rgb.z);
                 //sets $attr to have attributes of three dimensional color with c(x, y, z);
                 polySphere -ch on -o on -r .5; //creates the sphere and size of sphere.
                 xform -translation $curPos 0 0;//translates in three dimensions(x, y, z).
                 hyperShade -assign $shader;
                 //sets the hypershade to the variable $shader and sets it on the polysphere.
       }
      




       float $numSteps = 10.0;
       float $startHue = 0.2;// yellow
       float $endHue= 0.9; // violet
       float $distHue= $endHue - $startHue;
       float $startPos =10.0;
       float $endPos = 0.0;
       float $distPos= $endPos - $startPos;
       for ($i=0; $i<$numSteps; ++$i)
       {
                float $curHue = $startHue + $i * $distHue/$numSteps;
                float $curPos = $startPos + $i * $distPos/$numSteps;
                vector $hsv = <<$curHue, 1, 1>>;
                vector $rgb = hsv_to_rgb($hsv);
                $shader = `shadingNode -asShader blinn`;
                //the variable stores the shading node
                $attr = $shader + ".color";
                //blinnShader1.color-combines blinn shading node
                // with the color for the objects.
                setAttr $attr -type double3 ($rgb.x) ($rgb.y) ($rgb.z);
               //sets $attr to have attributes of three dimensional color with c(x, y, z);
               polySphere -ch on -o on -r .5; //creates the sphere and size of sphere.
               xform -translation $curPos 0 0;//translates in three dimensions(x, y, z).
               hyperShade -assign $shader;
               //sets the hypershade to the variable $shader and sets it on the polysphere.
         }






















            float $numSteps = 10.0;
           float $startHue = 0.0; // red
           float $endHue= 0.4; // green
           float $distHue= $endHue - $startHue;
           float $startPos =10.0;
           float $endPos = 0.0;
           float $distPos= $endPos - $startPos;
           for ($i=0; $i<$numSteps; ++$i)
           {
                      float $curHue = $startHue + $i * $distHue/$numSteps;
                      float $curPos = $startPos + $i * $distPos/$numSteps;
                      vector $hsv = <<$curHue, 1, 1>>;
                      vector $rgb = hsv_to_rgb($hsv);
                      $shader = `shadingNode -asShader blinn`;
                      //the variable stores the shading node
                      $attr = $shader + ".color";
                      //blinnShader1.color-combines blinn shading node
                      // with the color for the objects.
                     setAttr $attr -type double3 ($rgb.x) ($rgb.y) ($rgb.z);
                     //sets $attr to have attributes of three dimensional color with c(x, y, z);
                     polySphere -ch on -o on -r .5; //creates the sphere and size of sphere.
                      xform -translation $curPos 0 0;//translates in three dimensions(x, y, z).
                      hyperShade -assign $shader;
                      //sets the hypershade to the variable $shader and sets it on the polysphere.
           }
 
 



















Novel Use of Color: This image came from experiementing with the artistic color wheel. Here there are almost two full color wheel in one, making it almost 720 degree space in 360 degrees of space. I tweaked the artsitic color wheel code to do this.

Best Bash Scripting Tutorial

http://www.youtube.com/watch?v=zaULBbY4SVs&feature=related

My Best Bash scripting tutorial involved two tutorials that depend on one another for the script to work.
First, a program called lynx runs in Bash and can take whole html files from websites and display them in the shell.  

 67 cd test
68 ls  

69 lynx --dump http://ccmixter.org/view/media/remix
# Get the url of the website and call lynx to dump the 
#results from the specified website   

70 lynx --source http://ccmixter.org/view/media/remix
# lynx displays the source code of the webpage  

71 lynx --source http://ccmixter.org/view/media/remix|grep "mp3"
# After the source code is shown, the grep command shows 
all the words or characters that are contained within the 
specified string. The symbol | was referred to by the narrator as piing through.
 Maybe this means that several commands can be written in one statement as long as there
 is a pipeline present.  

 72* lynx --source http://ccmixter.org/view/media/remix|grep "mp3"|cut -d\' -f4
#another command is added : cut. The commands (-d\' and -f4 for field 4) select just the urls of the actual song themselves.

73 ffplay http://ccmixter.org/content/AlexBeroza/AlexBeroza_-_Start_Again.mp3
# ffplay play this song which I cut and paste onto the command line.

74 history > whileloop.txt   
75 history >> whileloop.txt 
 76 history >> whileloop2.txt
# I saved my history multiple times.

http://www.youtube.com/watch?v=R-ZTyn1iETE

The next tutorial deals with while loops in bash, and the while loop that is created will play, one by one, the songs I grabbed offline with lynx, grep, and cut. But first, a simpler example was shown to relay the concept.

66 name=Jennifer
# I set the variable (name) to Jennifer.  
 67 echo $name    
 #this produces my name on a single line with nothing else.

68 name=Jenn
# I reset the variable to store Jenn. 

 69 echo $name
# this prints out the single line of Jenn.  

70 echo "my name is $name"
 # This prints: my name is Jenn.

   71  let x=1
# sets the variable x to 1.

   72  echo 4x
# was supposed to echo $x

   73  echo $x
# actually echoes $x on a single line.

   74  let x=$x+1
# x is now equal to itself plus one.

   75  echo $x
# X = 2 now because 1 was added to 1 in the above line. The previous value of $x was 1.

   76  let x=$x+1;echo $x
# x = 3

   77  let x=$x+1;echo $x
# x = 4

   78  let x=$x+1;echo $x
#  x = 5

   79  let x=$x+1;echo $x
# x = 6

   80  while [ 1 ]; do echo "Hello World."; done
# This while loop is a preliminary example for the better, more advanced while loop later using sound. The loop states that while the result occurs one time, do this echo "Hello World."), and then it is done.

   81  while [ 1 ]; do echo "Hello World.";sleep 1;done
# This produces the same result as the line above, but before the loop is finished, it states that after every time the loop prints the statement, the "program" will wait one second, then continue. 

   82  let x=1;while [ $x -lt 10 ]; do echo "x is: $x";let x=$x+1;sleep 1;done
# This while loops states that x will equal one. Then the while loops starts with the statement that while the $x is -lt (less then) the integer 10, echo the statement
x is : a number less than 10. It then increases the value of $x until it get to number 9 after waiting one second before moving on to the next print statement.

   83  history > whileloop.txt

   77  ls
  
78  ls|while read file;do echo "file found: $file"; done
#This for loop displays all the files in whatever directory I am in at the time. It reads all the files in that directory and prints: file found and then the current file stored in the variable file.

   79  lynx --source http://ccmixter.org/view/media/remix|grep "mp3"|cut -d\' -f4
#another command is added : cut. The commands (-d\' and
-f4 for field 4) select just the urls of the actual song themselves. I redid the command here to show the urls again.


   80  lynx --source http://ccmixter.org/view/media/remix|grep "mp3"|cut -d\' -f4|while read mp3;do ffplay "$mp3";done
#the command takes the above line and makes a while loop out of it. It states that while bash it reading all the mp3 files, it should be them all until there are no more songs in the list. 
  
81  history >> whileloop2.txt
  
82  ls
83  history >> whileloop2.txt
#saving history to the file.

Monday, May 9, 2011

More Fun with FFFMPEG-Week 16

Cropping a video:

66 cd Test2
67 ls
68 ffplay new.VOB
69 ffplay newcolor.VOB
70 ffplay newcolor2.VOB
71 ls

72 ffmpeg -i letter1.VOB -vf crop=500:200:0:0 crop.VOB
# I took the input file and crop it with a width of 500 and height of 200 starting at the coordinate (0,0).

73 ffplay crop.VOB




74 ffmpeg -i letter1.VOB -vf crop=700:400:100:100 crop2.VOB
# I took the input file and crop it with a width of 700 and height of 400 starting at the coordinate (100,100).

75 ffplay crop2.VOB




76 ffmpeg -i letter1.VOB -vf crop=600:300:200:200 crop3.VOB
# I took the input file and crop it with a width of 600 and height of 300 starting at the coordinate (200,200).

77 ffplay crop3.VOB



78 history > funffmpeg.txt

Flip Video horizontally:

79 ffmpeg -i letter1.VOB -vf "hflip" flip.VOB
#give ffmpeg a video and horizontally flip it and name the ouput file.

80 ffplay flip.VOB


Scale a Video:

81 ffmpeg -i letter1.VOB -vf "scale=200:100" scale.VOB
# scale selected video using the width of 200 and height of 100, which is the output into a new video.

82 ffplay scale.VOB




83 ffmpeg -i letter1.VOB -vf "scale=1000:100" scale.VOB
# scale selected video using the width of 1000 and height of 100, which is the output into a new video. The above video belongs to this line.

84 ffmpeg -i letter1.VOB -vf "scale=1000:100" scale2.VOB
# scale selected video using the width of 1000 and height of 100, which is the output into a new video.

85 ffplay scale2.VOB







86 ffmpeg -i letter1.VOB -vf "scale=600:100" scale3.VOB
# scale selected video using the width of 600 and height of 100, which is the output into a new video.

87 ffmplay scale3.VOB
88 ffplay scale3.VOB






89 ffmpeg -i letter1.VOB -vf "scale=600:10" scale4.VOB
# scale selected video using the width of 600 and height of 10, which is the output into a new video.

90 ffplay scale4.VOB
#This last one wouldn't load into blogger.

91 history >> funffmpeg.txt

UnSharp a video:

92 ffplay flip.VOB
93 ls

94 ffmpeg -i twosides2.VOB -vf "unsharp" unsharp.VOB
#unnsharp a video using the default settings with ffmpeg. No specified time-all 3minutes of the film.

95 ffmpeg -i unsharp2.VOB -t 00:00:15 -vf "unsharp" unsharp2.VOB
96 ffplay unsharp2.VOB


97 ffmpeg -i twosides2.VOB -t 00:00:20 -vf "unsharp=13:13:5:13:13:5" unsharp3.VOB
# 20 seconds of the input video which the maximum amount of luma and chroma on it. It is saved to a new
# video file.

98 ffplay unsharp3.VOB



More Unsharp Video:

104 ffmpeg -i twosides2.VOB -t 00:00:20 -vf "unsharp=3:3:-2:3:3:-2" unsharp4.VOB
# Put the input video at the lowest unsharp setting and save to a new filename.

105 ffplay unsharp4.VOB


 Vertically Flip a video:

99 ffmpeg -i unsharp3.VOB -vf "vflip" vflip.VOB
#I vertically flip the last video I created along the y-axis, and then create a new video filename.

100 ffpplay vflip.VOB
101 ffplay vflip.VOB


102 history >> funffmpeg.txt


All of these tricks are located in the FFMPEG Documentation. http://ffmpeg.org/ffmpeg-doc.html

106 history >> funffmpeg.txt

Fun with FFMPEG documentation-Week 15

After many trials and tribulations where drawbox was concerned, I finally figured it out. All I had to do was put -vf in front of the command I wanted and it worked perfectly.

Here is my code:

66 cd Test2
67 ffmpeg -i letter1.VOB -vf "drawbox=50:50:100:50:red" newcolor.VOB
68 ffplay newcolor.VOB
69 ffmpeg -i letter1.VOB -vf "drawbox=10:10:500:200:red" newcolor2.VOB
70 ffmpeg newcolor2.VOB
71 ffmpeg -i letter1.VOB -vf "drawbox=10:10:500:200:red" new.VOB
72 ffplay new.VOB
73 ffmpeg -i letter1.VOB -vf "drawbox=0:0:1000:700:red" new2.VOB
74 ffplay new2.VOB
75 ffmpeg -i letter1.VOB -vf "drawbox=0:0:700:500:red" new3.VOB
76 ffplay new3.VOB
77 ffmpeg -i letter1.VOB -vf "drawbox=0:0:500:520:red" new4.VOB
78 ffplay new4.VOB
79 ffmpeg -i letter1.VOB -vf "drawbox=0:0:720:480:red" new5.VOB
# After a lot of experimenting, I realized that the file size was 720 x 480 so I set the size of the box to match that. Here is the result.




80 ffplay new5.VOB
81 history > drawbox.txt