15 Feb 2005
v=[1:64];
image(v);
//generate a default gradient image
map=colormap
//to see colormap numerically
size(map)
//ans = 1 3
//to verify the size of the map
//Notice that it has 64 rows and three columns. Each row is one entry
in the colormap. The three
columns give the amounts of red, green, and blue respectively in the
colormap.
//These amounts range
from 0 (none of the color present) to 1.0 (the maximum amount of the
color possible).
map=gray(256);
colormap(map);
//generate a plain gray
image([1:256]);
//generate a gray gradient
map=white(256);
axis image
//force matlab not to stretch
cd U:
cd lab02
//change to directory
imfinfo('helen.jpg')
//get image information
helen=imread('helen.jpg');
//image read
image(helen);
//display image in a stretched version
axis image
//display image in the original dimension
whos
//display info of everything in the workspace
pixel = helen(1,1,:)
//upper left pixel of the image (3 basic colors)
//looks like bright color is high number, dark color is small number
whos helen
//display the array information
rgb=squeeze(pixel)
//squeeze the info for array of length one
help size
//to get help for the function size
array =[1 2 3 4 5]
//array = 1x5, row vector
array = [1:5]
//array = 1x5, row vector
array = 1:5
//array = 1x5, row vector
array = [1:1:5]
//array = 1x5, row vector
array = [1:1:5]
//array = 1x7, row vector
array = [start:step:stop]
array = [1 2; 3 4]
//array = 2x2, matrix
array = [1; 2; 3; 4]
//array = 4x1, column vector
size(array)
//size of array as [M, N]
array = zeros(3)
//an 3by3 matrix of zeros.
array = zeros(N)
//an NbyN matrix of zeros.
//ZEROS(M,N) or ZEROS([M,N]) is an MbyN matrix of zeros.
array = ones(3)
//an 3by3 matrix of 1s.
array = ones(N)
//an NbyN matrix of 1s.
//ONES(M,N) or ONES([M,N]) is an MbyN matrix of ones.
array = eye(3)
//an 3by3 matrix of diagonal matrix.
array = eye(N)
//an NbyN matrix of diagonal matrix.
//EYE(M,N) or EYE([M,N])
array= 1:1:4
//array = 1 2 3 4
>> start =1;
>> stop=5;
>> step=1;
>> array=start:step:stop;
>> length(array)
//ans = 5
array = [1 2 3; 4 5 6]
eye2 = eye(2)
>> round (array)
>> sin(pi/4)
>> sin([0 pi/4 pi/2 3*pi/4 pi])
>> [1 2 3 4].*[1 2 3 4]
>> sin([0 pi/4 pi/2 3*pi/4 pi]) .* sin([0 pi/4 pi/2 3*pi/4 pi])
//notice it's ".*", not "*"
>> plot (array)
//continuous plot
>> stem (array)
//discrete plot
