For this question we are asked to shift a matrix 'a' down, one place, and have values dropping off the bottom edge.
I took this as...'as we shift the entries down, the bottom row values go to zero and then are placed at the top of matrix 'a'.
Here are the octave commands. Again...for illustrative purposes I have used a generic 3x3 matrix to show (used for questions 19 and 20 also).
octave:22> a
a =
1 3 0
2 3 6
4 7 8
octave:23> c=[0,0,0;1,0,0;0,1,0]
c =
0 0 0
1 0 0
0 1 0
octave:24> c*a
ans =
0 0 0
1 3 0
2 3 6
Monday, May 26, 2008
Assignment #4, Q 19
The following is an example of what you will see in octave if you enter the 'octave' commands. These commands show you how to shift entries of a matrix 'a' on place left (wrapping around left -> right).
octave:16> a=[1,3,0;2,3,6;4,7,8]
a =
1 3 0
2 3 6
4 7 8
octave:17> b=[0,0,1;1,0,0;0,1,0]
b =
0 0 1
1 0 0
0 1 0
octave:18> a*b
ans =
3 0 1
3 6 2
7 8 4
octave:16> a=[1,3,0;2,3,6;4,7,8]
a =
1 3 0
2 3 6
4 7 8
octave:17> b=[0,0,1;1,0,0;0,1,0]
b =
0 0 1
1 0 0
0 1 0
octave:18> a*b
ans =
3 0 1
3 6 2
7 8 4
Assignment #4, Q 20
Octave command:
octave:14> a=[1,3,0;2,3,6;4,7,8]
a =
1 3 0
2 3 6
4 7 8
octave:15> shift(a,1)
ans =
4 7 8
1 3 0
2 3 6
Details: create a generic nxn matrix (I chose a 3x3 for illustration purposes) and use the 'shift' function in octave to have the matrix wrap around bottom -> top.
octave:14> a=[1,3,0;2,3,6;4,7,8]
a =
1 3 0
2 3 6
4 7 8
octave:15> shift(a,1)
ans =
4 7 8
1 3 0
2 3 6
Details: create a generic nxn matrix (I chose a 3x3 for illustration purposes) and use the 'shift' function in octave to have the matrix wrap around bottom -> top.
Assignment #4, Q 17
To do this question...imagine that you have a sheet of paper divided into 12 squares...
You want to make a 'net' of a colour cube which looks like a 'cross' on your sheet of paper.
If your paper is facing you so that its height is 3 squares and its width is 4 squares, then you need to have the following colours looking back at you 'going 'left to right' and 'top to bottom': (white, CM, white, white), (RB, YM, CY, GB), (white, RG, white, white).
To make the colour 'white' you need to 'turn on the R, G, and B channels'. I have indicated the 'white' regions as WA, WB, ... , WF.
Starting from scratch...the octave commands are:
RB(:,:,1)=[ones(256,1)*[0:1:255]/255];
RB(:,:,2)=[zeros(256)];
RB(:,:,3)=[ones(256,1)*[0:1:255]/255]';
RB=rotdim(RB, 270);
RG(:,:,1)=[ones(256,1)*[0:1:255]/255]';
RG(:,:,2)=[ones(256,1)*[0:1:255]/255];
RG(:,:,3)=zeros(256);
GB(:,:,1)=zeros(256);
GB(:,:,2)=[ones(256,1)*[0:1:255]/255];
GB(:,:,3)=[ones(256,1)*[255:1:0]/255]';
GB=rotdim(GB, 270);
CY(:,:,1)=[ones(256,1)*[0:1:255]/255];
CY(:,:,2)=ones(256);
CY(:,:,3)=[ones(256,1)*[0:1:255]/255]';
YM(:,:,1)=ones(256);
YM(:,:,2)=[ones(256,1)*[0:1:255]/255]';
YM(:,:,3)=[ones(256,1)*[0:1:255]/255];
CM(:,:,1)=[ones(256,1)*[0:1:255]/255]';
CM(:,:,2)=[ones(256,1)*[0:1:255]/255];
CM(:,:,3)=ones(256);
WA(:,:,1)=ones(256);
WA(:,:,2)=ones(256);
WA(:,:,3)=ones(256);
WB(:,:,1)=ones(256);
WB(:,:,2)=ones(256);
WB(:,:,3)=ones(256);
WC(:,:,1)=ones(256);
WC(:,:,2)=ones(256);
WC(:,:,3)=ones(256);
WD(:,:,1)=ones(256);
WD(:,:,2)=ones(256);
WD(:,:,3)=ones(256);
WE(:,:,1)=ones(256);
WE(:,:,2)=ones(256);
WE(:,:,3)=ones(256);
WF(:,:,1)=ones(256);
WF(:,:,2)=ones(256);
WF(:,:,3)=ones(256);
Net=[WA,CM,WB,WC;RB,YM,CY,GB;WD,RG,WE,WF];
imshow(Net)
You want to make a 'net' of a colour cube which looks like a 'cross' on your sheet of paper.
If your paper is facing you so that its height is 3 squares and its width is 4 squares, then you need to have the following colours looking back at you 'going 'left to right' and 'top to bottom': (white, CM, white, white), (RB, YM, CY, GB), (white, RG, white, white).
To make the colour 'white' you need to 'turn on the R, G, and B channels'. I have indicated the 'white' regions as WA, WB, ... , WF.
Starting from scratch...the octave commands are:
RB(:,:,1)=[ones(256,1)*[0:1:255]/255];
RB(:,:,2)=[zeros(256)];
RB(:,:,3)=[ones(256,1)*[0:1:255]/255]';
RB=rotdim(RB, 270);
RG(:,:,1)=[ones(256,1)*[0:1:255]/255]';
RG(:,:,2)=[ones(256,1)*[0:1:255]/255];
RG(:,:,3)=zeros(256);
GB(:,:,1)=zeros(256);
GB(:,:,2)=[ones(256,1)*[0:1:255]/255];
GB(:,:,3)=[ones(256,1)*[255:1:0]/255]';
GB=rotdim(GB, 270);
CY(:,:,1)=[ones(256,1)*[0:1:255]/255];
CY(:,:,2)=ones(256);
CY(:,:,3)=[ones(256,1)*[0:1:255]/255]';
YM(:,:,1)=ones(256);
YM(:,:,2)=[ones(256,1)*[0:1:255]/255]';
YM(:,:,3)=[ones(256,1)*[0:1:255]/255];
CM(:,:,1)=[ones(256,1)*[0:1:255]/255]';
CM(:,:,2)=[ones(256,1)*[0:1:255]/255];
CM(:,:,3)=ones(256);
WA(:,:,1)=ones(256);
WA(:,:,2)=ones(256);
WA(:,:,3)=ones(256);
WB(:,:,1)=ones(256);
WB(:,:,2)=ones(256);
WB(:,:,3)=ones(256);
WC(:,:,1)=ones(256);
WC(:,:,2)=ones(256);
WC(:,:,3)=ones(256);
WD(:,:,1)=ones(256);
WD(:,:,2)=ones(256);
WD(:,:,3)=ones(256);
WE(:,:,1)=ones(256);
WE(:,:,2)=ones(256);
WE(:,:,3)=ones(256);
WF(:,:,1)=ones(256);
WF(:,:,2)=ones(256);
WF(:,:,3)=ones(256);
Net=[WA,CM,WB,WC;RB,YM,CY,GB;WD,RG,WE,WF];
imshow(Net)
Assignment #4, Q 16
Assignment #4, Q15
Assignment #4, Q 14
Assignment #4, Q13
Assignment #4, Q 12
Sunday, May 25, 2008
Assignment #4, Question 11
To make an exact copy of the RB face of the colour cube on p. 404, you will need to enter the following octave command.
Octave command:
RB(:,:,1)=[ones(256,1)*[0:1:255]/255];
RB(:,:,2)=zeros(256);
RB(:,:,3)=[ones(256,1)*[0:1:255]/255]';
RB =rotdim(RB,270);
imshow(RB)
The rotdim function allows you to rotate the image so that the orientation of the RB face of the colour cube is the same as it appears in the textbook.
Octave command:
RB(:,:,1)=[ones(256,1)*[0:1:255]/255];
RB(:,:,2)=zeros(256);
RB(:,:,3)=[ones(256,1)*[0:1:255]/255]';
RB =rotdim(RB,270);
imshow(RB)
The rotdim function allows you to rotate the image so that the orientation of the RB face of the colour cube is the same as it appears in the textbook.
Assignment #4, Question 3
Assignment #4, Question 2
Subscribe to:
Posts (Atom)