Octave commands to create:
1. a matrix of 256 x 1 ones: ones(1,256)
2. a matrix of the integers 0 through 255 in a single row: [0:1:255]
3. A column of intergers 0 through 255: [0:1:255]'
4. a 256 x 256 matrix with the rows, all the same, equal to 0 through 255:
ones(256,1)*[0:1:255]
5. a 256 x 256 matrix with the columns, all the same, equal to 0 through 255:
[0:1:255]'*ones(1,256)
6. a 256 x 256 matrix of all zeros: zeros(256)
7. a 256 x 256 matrix all ones: ones(256)
8. a 256 x 256 matrix of the value 128: 128*ones(1,256)
10. display a greyscale image: A=(ones(256,1)*[0:1:255]; imshow(A/255)
11 - 13 the faces of the RGB colour cube: A=uint8(ones(100,1)*[0:1:99]); B=uint8(ones(100,1)*[0:1:99]'; C=uint8(zeros(100));
(These were needed to use 3.0.1 on a Mac)
11. RB face: RB(:,:,1)=A;RB(:,:,2)=C;RB(:,:,3)=B; imshow (RB)
12. RG face: RG(:,:,1)= A; RG(:,:,2)=B; RG(:,:,3)=C; imshow(RG)
13. BG face: BG(:,:,1)=C;BG(:,:,2)=A;BG(:,:,3)=B; imshow(BG)
A different version, using 3.0.0 on a PC:
11 – 16. To show these faces, I set up four basic statements:
octave-3.0.0:1> A=zeros(256);
octave-3.0.0:2> B=ones(256);
octave-3.0.0:3> C=[ones(256,1)*[0:1:255]/255'];
octave-3.0.0:4> D=[ones(256,1)*[0:1:255]/255];
Then I created each face using these commands for the RGB layers:
19-22
A=[1,2,3;4,5,6;7,8,9];
1 2 3
4 5 6
7 8 9
B=eye(3);
1 0 0
0 1 0
0 0 1
C=circshift(B,1);
0 0 1
1 0 0
0 1 0
19. A*C
2 3 0
5 6 0
8 9 0
20. C*A
7 8 9
1 2 3
4 5 6
21. circshift((A,1);
for i+1:columns(A);
A(i,1)=0;
A
0 2 3
0 5 6
0 8 9
22. circhshift(A,1);
A
for i = 1:columns(A);
A(1,i)=0'
A
0 0 0
1 2 3
4 5 6
Wednesday, May 21, 2008
Subscribe to:
Post Comments (Atom)
1 comment:
for that color cube net, don't you want the colors to line up along the edges?
Post a Comment