Laboratory of Computer and Information Science / Neural Networks Research Centre CIS Lab Helsinki University of Technology

T-61.5100 Digitaalinen kuvankäsittely / Digital Image Processing

Harjoitustyö / Course assignment

Useful Matlab commands

format compact
output without empty lines
more on
output one screen at a time
Hint: put these lines in the file startup.m in your working directory, and they will be automatically on in your sessions.
sort(x), sort(A)
sorts elements of vector x, or columns of matrix A
eig(A)
[V,E]=eig(A) gives the matrix V of eigenvectors and the matrix E of respective eigenvalues (in the diagonal) of matrix A.
Notice: eigenvectors are in no particular order.
conv2(F,H)
convolution F*H
Some matrix operations
For matrix A and scalar t,
A>t returns a matrix B with B(i,j)=1, if A(i,j)>t, and B(i,j)=0 otherwise. Similarly for >,>=,<=,==,~= operations.
max(A,t) returns the matrix similar to A, but elements smaller than t are set to t; min(A,t) does the opposite.
Three and more dimensional matrices
An example tells it all:
>> D(:,:,1)=ones(3,3);
>> D(:,:,2)=zeros(3,3);
>> D(:,:,3)=diag(1:3);
>> D
D(:,:,1) =
     1     1     1
     1     1     1
     1     1     1
D(:,:,2) =
     0     0     0
     0     0     0
     0     0     0
D(:,:,3) =
     1     0     0
     0     2     0
     0     0     3
Notice: Limited set of aritmetic operations.
size(x)
size(A)
size(A,n)
Returns size of a vector, matrix or nth level of NDIM matrix.
squeeze(X)
For example: squeeze(D(2,2,:)) is [1 0 2]' in the example above. Otherwise:
>> D(2,2,:) 
ans(:,:,1) =
     1
ans(:,:,2) =
     0
ans(:,:,3) =
     2

image(I)
Shows a matrix as an image;
- if the dimension of the matrix is MxX, image uses colormap
- if MxXx3, image treats it as an RGB image
colormap([1:255; 1:255, 1:255])
colormap('gray')
see help colormap

Image Processing ToolBox

imread(filename)
imread(filename,format)
I=imread('name.tif') reads a tif image to matrix I
I=imread('name.im1',tif) reads a tif image to matrix I
depending on image format, I becomes a conventional 2D matrix or a NDIM matrix with size(I,3)=3.
Supported formats: bmp,hdf,jpg,pcx,xwd
imshow(I,0:255)
imshow(I,[0 255])
Shows a single channel image I in gray scale
imshow(I,MAP)
Shows an indexed-color image I with the colormap MAP
imshow(I,MAP)
Shows a true RGB image I in colors: red=I(:,:,1), green=I(:,:,2), blue=I(:,:,3)

double(I)
Converts a matrix to the double-precision floating-point format

Help

help
help help
help relops
help elmat
help images
help specgraph
help graph2d

You are at: CIST-61.5100 → Useful Matlab commands

Page maintained by t615100 at cis.hut.fi, last updated Monday, 12-Nov-2007 15:44:22 EET