Sunday, May 25, 2008

Assignment 4

1. Make a matrix of 256 x 1 ones.
Answer ones(256)

2. Make a matrix of the integers 0 to 255 in a single row.
Answer [0:1:255]

3. Make a column of the integers o to 255.
Answer [0:1:255]’

4. Make a matrix 256 x 256 with the rows all the same equal to the numbers 0 to 255.
Answer ones(256)*[0:1:255]

5. Make a matrix 256 x 256 with the columns all the same equal to the numbers 0 to 255.
Answer [0:1:255]’*ones(1,6)

6. Make a matrix 256 x 256 of all zeros.
Answer zeros(256)

7. Make a matrix 256 x 256 of all ones


Answer ones(256)

8. Make a matrix 256 x 256 of the value 128.


Answer 128*ones(1,256)
9. same as # 6

10. Display the grey scale image .


Answer imshow(ones(256,1)*[0:1:255]/255)’










Display the different faces of the color cube.
11. Red - Blue
RB face of the colour cube.
RB(:,:,1)=(ones(256)*((255:-1:0)/255)’;
RB(:,:,2)=zeros(256);
RB(:,:,3)=(ones(256,1)*(0:1:255)/255);
imshow(RB)














12. Red – Green
RG face of the colour cube.
RG (:,:,1)= (ones(256,1)*(0:1:255)/255)’;
RG (:,:,2)= (ones(256,1)*((255:-1:0)/255);
RG (:,:,3)= zeros(256);
imshow(RG)

















13. Blue - Green
BG face of the colour cube.
BG (:,:,1)= zeros(256);
BG (:,:,2)= (ones(256,1)*(0:1:255)/255);
BG (:,:,3)= (ones(256,1)*((255:-1:0)/255)’;
imshow(RB)


















14. Cyan – Yellow
CY face of the colour cube.
CY(:,:,1)=[ones(256,1)*[255:-1:0]/255]';
CY(:,:,2)=ones(256);
CY(:,:,3)=[ones(256,1)*[0:1:255]/255]’;
imshow(CY)



















15. Cyan - Magenta
BW face of the colour cube.
BW (:,:,1)= zeros(256);
BW (:,:,2)= (ones(256,1)*(0:1:255)/255);
BW (:,:,3)= (ones(256,1)*((255:-1:0)/255)’;
imshow(BW)













16. Magenta – Yellow
MY(:,:,1)=ones(256);
MY(:,:,2)=(ones(256,1)*(0:1:255)/255);
MY(:,:,3)=(ones(256,1)*(255:-1:0)/255)’;
imshow(MY)


























17. Display the whole color cube in a cross with white regions where there doesen’t need to be anything.

Not exactly sure how to do this just yet.

18. Display the rainbow image that appears on the Math 5330 facebook page.

Not exactly sure how to do this just yet.


19. Shift entries of a matrix A one place left. (Wrapping)

Suppose A = [1,2,3;4,5,6;7,8,9]. To shift A left we perform the following operation.

[1,2,3;4,5,6;7,8,9]*[0,0,1;1,0,0;0,1,0] = [2,3,1;5,6,4;8,9,7]

20. Shift the entries of a matrix A one pixel down.

Suppose A = [1,2,3;4,5,6;7,8,9]. To shift A one pixel down we perform the following operation.

[0,0,0;1,0,0;0,1,0]* [1,2,3;4,5,6;7,8,9] = [0,0,0;1,2,3;4,5,6]

21. Shift entries of a matrix A one place left (drop values off left edge)

Suppose A = [1,2,3;4,5,6;7,8,9]. To shift A one place left (drop values off left edge) we perform the following operation.

[1,2,3;4,5,6;7,8,9]*[0,0,0;1,0,0;0,1,0] = [2,3,0;5,6,0;8,9,0]

22. Suppose A = [1,2,3;4,5,6;7,8,9]. To shift A one place left (drop values off bottom edge) perform the following operation.

[0,0,0;1,0,0;0,1,0]*[1,2,3;4,5,6;7,8,9] = [0,0,0;1,2,3;4,5,6]



No comments: