% CIS 601 SPRING 2007
% Computer Graphics and Image Processing
% Homework 1
% By: Sravani Chandaka
% Description:Generating a matlab movie using several image transformations.


numframes = 24;
%aviobj = avifile ( 'pandu.avi', 'fps', 1 ); 

  I=imread('pic.jpg');

  %   Image Rotation
  
  for j =  1 : 6
      J= imrotate(I,60,'crop');
      K=im2double(J);
      imshow(K);
      f(j) = getframe;
      I=J;
  end
  
%   h = fspecial(type) creates a two-dimensional filter h of the specified 
%   type. fspecial returns h as a correlation kernel, which is the 
%   appropriate form to use with imfilter. type is a string having one of 
%   these values.

   PSF = fspecial('motion',13,45); 
   for j =  6 : 12
    J= imfilter(I,PSF,'circ','conv');
     
      K=im2double(J);
      imshow(K);
      f(j) = getframe;
      I=J;
   end
  
%    Image Resizing
  
   for j =  9 : 12
      J=imresize(I, 0.95);
      K=im2double(J);
      imshow(K);
      f(j) = getframe;
      I=J;
   end
  
   
%     Image Shearing   
%     maketform(transformtype,...) creates a multidimensional spatial 
%     transformation structure (called a TFORM struct) that can be used 
%     imtransform functions.  

   for j =  12 : 13

       tform = maketform('affine',[1 0 0; .25 1 0; 0 0 1]);
       J = imtransform(I,tform); 
       K=im2double(J);
       imshow(K);
       imshow(K);
       f(j) = getframe;
       I=J;
   end
   
%    Performs multidimensional image filtering using convolution.
   
   for j =  13 : 19
    J= imfilter(I,PSF,'circ','conv');
     
      K=im2double(J);
      imshow(K);
      f(j) = getframe;
      I=J;
   end 
   
%    Image Filtering

for j =  19 : 26  
h = fspecial('unsharp');
J = imfilter(I,h); 
K=im2double(J);
      imshow(K);
      f(j) = getframe;
      I=J;
 end 

 movie(f,20); 
