On Octave 3.0.0 commands to:
(1) make a matrix of 256 by 1 ones: ones(256,1)
(2) make a matrix of the integers 0 through 255 in a single row: [0:1:255]
(3) make a column of the integers 0 through 255: [0:1:255]'
(4) make a 256 by 256 matrix with the rows, all the same,
equal to the numbers 0 to 255: C=ones(256,1)*[0:1:255]
(5) make a 256 by 256 matrix with the columns, all the same,
equal to the numbers 0 to 255: C'
(6) make a 256 by 256 matrix of all zeros: zeros(256)
(7) make a 256 by 256 matrix of all ones: ones(256)
(8) make a 256 by 256 matrix of the value 128: 128*ones(256)
(9) make a 256 by 256 matrix of all zeros: zeros(256)
(10) display a fading greyscale image
imshow((1/255)*ones(256,1)*[0:1:255])
For questions 11-16: Define
l=(1/255)*ones(256,1)*[255:-1:0]
r=(1/255)*ones(256,1)*[0:1:255]
u=l'
d=r'
z=zeros(256)
f=ones(256)
(11) display the RB face of the color cube
RB(:,:,1) = r;
RB(:,:,2) = z;
RB(:,:,3) = u;
imshow(RB)
(12) display the RG face of the color cube
RG(:,:,1) = u;
RG(:,:,2) = r;
RG(:,:,3) = z;
imshow(RG)
(13) display the GB face of the color cube
GB(:,:,1) = z;
GB(:,:,2) = r;
GB(:,:,3) = d;
imshow(GB)
(14) display the MY face of the color cube
MY(:,:,1) = f;
MY(:,:,2) = r;
MY(:,:,3) = u;
imshow(MY)
(15) display the CM face of the color cube
CM(:,:,1) = d;
CM(:,:,2) = r;
CM(:,:,3) = f;
imshow(CM)
(16) display the GM face of the color cube
YC(:,:,1) = l;
YC(:,:,2) = f;
YC(:,:,3) = u;
imshow(YC)
(17) display the whole color cube in a cross with white regions where there doesn't need
to be anything
r1=[f,d,f]
r2=[r,f,l]
r3=[f,u,f]
r4=[f,z,f]
R = [r1;r2;r3;r4]
g1=[f,r,f]
g2=[z,r,f]
g3=[f,r,f]
g4=[f,r,f]
G = [g1;g2;g3;g4]
b1=[f,f,f]
b2=[u,u,u]
b3=[f,z,f]
b4=[f,d,f]
B = [b1;b2;b3;b4]
C(:,:,1)=R;
C(:,:,2)=G;
C(:,:,3)=B;
imshow(RGB)
(18) display something similar to the rainbow image that appears on the Math 5300
facebook page
f=ones(100,50);
d=(1/50)*ones(100,1)*[50:-1:1];
u=(1/50)*ones(100,1)*[1:1:50];
dh =(1/100)*ones(100,1)*[100:-1:51];
uh=(1/100)*ones(100,1)*[1:1:50];
qd=(1/100)*ones(100,1)*[50,-1,1]
qu=(1/100)*ones(100,1)*[51,1,100]
z=zeros(100,50);
R=[f,f,d,z,z,u,dh];
G=[z,u,f,dh,qd,z,z];
B=[z,z,z,uh,uh,qu,f];
M(:,:,1)=R;
M(:,:,2)=G;
M(:,:,3)=B;
imshow(M);
(19) shift the entries of a matrix A one place left (wrapping around left ! right)
A= circshift(A,[0,-1]);
(20) shift the entries of a matrix A one place down (wrapping around bottom)
A = circshift(A,1);
(21) shift the entries of a matrix A one place left (dropping values on the left edge)
A= circshift(A,[0,-1]);
for i=1:rows(A);
A(i,1)=0;
endfor;
(22) shift the entries of a matrix A one place down (dropping values on the bottom edge)
A = circshift(A,1);
for i=1:columns(A);
A(rows(A),i)=0;
endfor;
Saturday, May 24, 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment