clear
a=imread('hw1.jpg');

i=0;
for r=1:255
    i=i+1;
    imshow(mat2gray(a,[0 r]));
    M(r)=getframe;
end

red=a;
red(:,:,2:3)=0;          %Show RED plane
imshow(red);
%r=i;
for i=1:60
    r=r+1;
    M(r)=getframe;
end

green=a;
green(:,:,[1 3])=0;     %Show GREEN plane
imshow(green);
for i=1:60
    r=r+1;
    M(r)=getframe;
end

blue=a;
blue(:,:,1:2)=0;        %Show BLUE plane
imshow(blue);
for i=1:60
    r=r+1;
    M(r)=getframe;
end

imshow(a(:,:,[1,1,1])); %Show GRAY level - not sure what exactly happens here.
for i=1:60
    r=r+1;
    M(r)=getframe;
end

                        %Show GRAY level
imshow(a(:,:,1) * 0.299 + a(:,:,2) * 0.587 + a(:,:,3) * 0.114)
for i=1:60
    r=r+1;
    M(r)=getframe;
end

fprintf('Done');
movie2avi(M,'hw1.avi');
%movie(M,30,30);