%
% Tom McGrath
% September 2004
% CIS 601 - Temple University
% Assignment #1
%
% This m-file creates a movie to demonstrate basic
% 2 dimensional transformation operations
% in matlab.
%


% --- Perform initialization of variables ---

    delete 'tomsvideo.avi'; %deletes old .avi
    clear all; %clears memory
    clc; % clears console
    outputName = 'tomsvideo.avi';
    outputFile = avifile(outputName,'fps',16, 'compression', 'Indeo5'); 
    frame = 1;
    
    cubemat = [ 0 0 0;
                1 0 0;
                0 1 0;
                0 0 1;]
            
    
    
% --- End variable initialization ---



%  --- Create and store frames ---

    myImage = imread('tompic.jpg');
    imshow(myImage);

    for i = 1:32  %show intro
    
        imshow(myImage);
        text(300,150,'Tom McGrath Presents...','FontSize',32,'FontWeight','bold','Color','r','HorizontalAlignment','center');
        outputFile = addframe(outputFile,getframe);
        frame = frame + 1;
        clf;
        
    end
    
    

    for i = 1:48  %scroll text
        
        imshow(myImage);
        text(300-(i*10),150,'Tom McGrath Presents...','FontSize',32,'FontWeight','bold','Color','r','HorizontalAlignment','center');
        outputFile = addframe(outputFile,getframe);
        frame = frame + 1;
        clf;
    
    end
    
    for i = 1:16  % fade picture of me
        myImage2 = imresize(myImage,1-(i*.062));
        myImage2 = imresize(myImage2,[480,640]);
        imshow(myImage2);
        outputFile = addframe(outputFile,getframe);
        frame = frame + 1; 
        clf;
    end
    
    for i = 1:16  %show 2d transformation text
        axis off;
        text(.2,.5,'2D Transformations','FontSize',32,'FontWeight','bold','Color','r');
        outputFile = addframe(outputFile,getframe);
        frame = frame + 1;
        clf;
           
    end
    
    a2dimage = imread('its_not_the_same_style.jpg');

    for i = 1:16  %show a 2d image
        
        image(a2dimage);
        outputFile = addframe(outputFile,getframe);
        frame = frame + 1;
        clf;
        
    end
    
    for i = 1:36  %spin image and crop as we go
        a2dimage = imrotate(a2dimage,10,'bilinear','crop');
        image(a2dimage);
        outputFile = addframe(outputFile,getframe);
        frame = frame + 1;
        clf;
        
    end
    
    for i = 1:16  %show circular image
        
        image(a2dimage);
        outputFile = addframe(outputFile,getframe);
        frame = frame + 1;
        clf;
        
    end
    
    for i = 1:20  %erode image
        se = strel('ball',5,5);
        imerode(a2dimage,se);
        image(a2dimage);
        outputFile = addframe(outputFile,getframe);
        frame = frame + 1;
        clf;
        
    end
    
    
    for i = 1:16  %show 'fin'
        
        axis off;
        text(.45,.5,'Fin','FontSize',32,'FontWeight','bold','Color','b');
        outputFile = addframe(outputFile,getframe);
        frame = frame + 1;
        clf;
        
    end
    
    %close necessary handles...
    outputFile = close(outputFile);

% --- End Program ---