Download as pdf or txt
Download as pdf or txt
You are on page 1of 38

Matlab

MATLAB

% MATLAB $ ! " #" Matrix Laboratory MATLAB


5 56 #54 & ' () ! *+ ,-. / (. % / 0 , 1 2 3 )#4
$% 6 #; < # , MATLAB ,6 7 ! " 89 0 : %#, 2
5 < #5 5 5 = 5>,7 . 56 5 ?5> @ ! " 0 A# TOOLBOX : !97 % '. MATLAB
5 % C Neural Network !;A : D!( C Statistics = (. % / C Signal Processing ) + B. % / : !97
Filter 5 > - 4 C Control Systems 3 6 , C Image Processing #; B. % / C Image Acquisition #;
5 5: 5!97 *5 . 589 $% 56 ' ( $$$ Genetic Algorithms G : #+3 C Fuzzy Logic . EF C Design
$ www.Mathworks.com ?> @ : I 6 % <# + % 89 #( H MATLAB ' ,:
NO5 % 56 5 5 P53 F 5H 5 M 5: $ 5 <= : !97 MATLAB 2 J 6 K L C (# * M :
$ ) 6 , ) + B. % / J J- % MATLAB
$ 2 % / : #2 <= . '% R )#S MATLAB : 2 P>F * Q@ %
$% % T ; 2 , 3 + >S :% 6 . D < # A #; B. % / % MATLAB % 6 % Q@
, 1 : . '% R '#" $% 6 : #2 3 6 , - 4 J >" % MATLAB :% 6 # Q@ %
$ ( : #2 K L Q@ * % SIMULINK SISOTOOL CLTIVIEW

MATLAB

MATLAB
56 *5 $ 5 MATLAB 5 ' ,: : !97 , P; . $ '% L U#3 % J ( MATLAB J 6
CCustom Installation IY@ CMATLAB P; + : % * $%#( ,( # X 6 W - 8 * : VA
< #5 A 5" ) ' ,( * ( % 3 CMATLAB P; + : % D $ 6Y@ %#2 . % # : !97
6 7 ' ( H <= ' ,: 6 crack C original >S @ ,( MATLAB Z [$ PLP
$ 6 MATLAB P; + : % %#( 3# <= \ # 6 PLP
] #( % MATLAB \ " Start # E 4 . CMATLAB P; . /
Matlab

]%#( ,( # % % '% = ' < / <= \ " ^I , W MATLAB % . /

% <= < # A _ # % 7 \" * %$ Command ^X \ " CMATLAB 6 >S \ "


$ #( b 2 MATLAB . Enter >6 L exit quit # % ` ) a < # A $ :% L Enter >6 '% 6 `
$ 6 8- c % 0 >!1 # % # >6 L
56 #5S < ,: : d # % e - M - D[#6 I ! MATLAB 6 ( ( % %
$ 6 ' (? 9
Matlab

L MATLAB \ " % J ` C .m # / J % # % A#,0 ' 2f CMATLAB . '% R +%B


2 5( . % 5 g#5 J5 $ 5 6 7 3 # #S # %. % .% 9 # B * ,6 $ Enter >6
$ F:\Program Files\MATLAB704\work cha ( ( % 1 ' ( P; <= % MATLAB 6 % work
Y 5@ 5 #5( 5 + '%#, 7 6 # % * 2= C% % Command History 6 MATLAB \ " . L@ %
c % 50 <= 5 # 5 # 5 % : <% 6 >6 $ ! Q@ * # desktop # . Command History I
$ 6 7

MATLAB !"
5-$ 5 :5 i#5 . MATLAB 5: d , $ ' ( - 4 6 6 . MATLAB
MATLAB _5 # , * l%#( ? 9 jkj #S 6 + %#2 < % % A 6 d
$ #( 7
7 d # . Fm : % ? 9 . <= : d 6 * MATLAB !a : ! 7 . D
5 C 5+ % < 5 5 $%#5( p#A )#4 % # : d '. 9o 6 <= MATLAB + % P3 7 In $ 6 ? 9
5 . < 5 \52 5I ) 5a < # A $ d J 1 9 :'% R % %#( q@L <= 9o d . '% R * 3
] 6
a = [1 2]
5 5 5 a d 9o C%#( '% R a = 5 # %. % % Z [ $ '% 6 ? 9 a jkr d
$% 6 : #2 d jkj
] 6 + 0= % = >9 m 9o ' ( ? 9 : d 6 Workspace L@ % MATLAB

who < 5 5,6 5 $ 6Y@ Workspace I Desktop # . C , MATLAB \ " % Q@ * Z [


$ ! ' ( ? 9 MATLAB >9 8 % 6 : d , #
Matlab

5 d <= 5 C
\m : #2 6s/ d
Z [ $ 6 '% R clear < . : d , <% 6 s /
$ 6 s / c d C >!1 JD( % clear c # % cha & 6 6f clear # % J m
. J5!1 C 5 , 1 5 MATLAB 9 7 : d % J , Z [ $ #( s / : d , MATLAB . b 2
5 MATLAB 5 % 50 % 5 ' ( ' 2f matlab.mat > % : 9 C 6 * $ 6 '% R save # % . b 2
$ #( . # load # % ,6

% # $
?5 9 5 i#5 . 5 <= : d , #"
RI L / 6 #+ ,: MATLAB C (
$ #(
5 I W % d <= jkj C :% ! d 6 6 % A cha Ah4 >1 u t Z [
$ 6 ? 9 'a' 6 6 0.56 #>9 3 % m C X 9 : d C = 'a' X = 0.56 # % cha $%#(
wv 5 hA % * 5 #5( 57 : . 6 3 2 >S 6 < W % # 3 %m C F = ? 9
] ! . # % cha $ :% ! d '% % 1
A = [1 2 3 4 5]
$ :% ! <= S A 1, 2, 3, 4, 5 %m '% 6 ? 9 a jkx F = jkx # %*

50 Cy 5 #5 % 7 cha &%#( '% % Q , MATLAB \ " % <= 7 0 CMATLAB # % 7


]%#( '% % < L . #S 7
A=
1 2 3 4 5
% # 6 6 #; J;R 1 cha %#( '% % Q , # % 7 0 J I
$ 6 '% R *3 6 , ; hA . # %

$ 5 6 '% R ; hA . 6 3 2 >S 7 = S A* C 6? 9 # #S = ( J Z [
# % cha $ % 7 F %0 L hA *
A = [1 ; 2 ; 3 ; 4 ; 5]
]%#( % 0 . #S xkj # = xkj %#( VA
A=
1
2
3
4
5
7 F %0 '% 6 % ) F . i ( wv hA * <= S A C ? 9
# %hc a $ 6 '% R ; hA .
A = [1 2 3 ; 4 5 6 ; 7 8 9]
] 6 %0 . #S zkz
A=
1 2 3
4 5 6
7 8 9

?5 9 . 59 5I cha5 $ 5 :% 51 5 hA % * <= <# F ' ,( C : 2. D %


C %#( . {= . # : F ' ,( MATLAB % : #@ z <# r F % ' ( ' 2f m Cy
] :% Q , ,( ; A <= m . #S MATLAB 6` a(2,3) # % 6
Matlab

ans =
6
C 5( ' L '% % ! d # % 7 2 ' I : 6 % % answer ?R@ ans p Q/ d MATLAB
$ :% 1 d * % # % <= 7 2 m p Q / #S

?5 9 5 5 5 = <= # : +>,A ,6 C ( ' ( J DL #>9 JS # S A . ,( = Z [


] ! . JD( $ S A , ? 9 . +% 6

5. # 5 %. ( |}x = S A >S : #@ I $ 6 ? 9 j| j % m ; A j| = k = 1:10 # %


] 6 '% R
k = 1 : 0.5 : 10
] . JD( : = ? 9 % : +>,A >6 % 6
= ~ = ;A*3 m ] = S A >S ] = ; A * 2= m

x 5 r S A k(2:5) # % y JD( % $% 6 '% R : +>,A . < # C 6 6 = . L@ : #@ Z [


$% = % Q , MATLAB \ " % k = • S A k(4:end) # % k =

] . JD( % . Q , % : +>,A :% 6 . #, [
Matlab

$ :% Q , z <# % %#7# S A , a(:,3) # % j F % %#7# S A , a(1,:) # %

] 6 %0 Transpose '% +>,A * ) ' &'(


Matlab

] : 7 9 C' ( ? 9 ch!1 6 # # %* ,6 )reshape *"+

5: 6 # ,( 6 * $ 6 J ! jk€ 9o r1 = zkz 6 M C) reshape # %


$ 6%0 = # * ( ^I
r2 = ( ^I : 6 :M : F _1 % 6 M '% # C % reshape # %
$%. jk€ 9o

'+ , *"+
#5 %* 5, . %$ # % * '% ! " ‚ _# # CMATLAB #1 • m . D
$ . % / MATLAB ,

] :% Q , I #S = %m # # %* ,6 ) stem *"+
Matlab

$ 6 ' 2f v d % '% 6 % 0 % ; % m jkx| v = rand(1,50) # %


$% % 0 , : <= % < # 6 6 % 0 3 2 JD( figure # %
$ :% Q , I #S v % % m stem(v) # %
Matlab

50 $ 5 6 5 ' 5 2f x 5 = % 5 : % A …z 6 <= % m '% 6 % 0 |}j JS # „ ƒ . % ) # %


$ 6 ' : L y JD( % stem(sin(x)) # % 7

JD5( 5 I % m * <# plot # % ,6 $ : I +,: MATLAB : d )plot *"+


] :% Q , #/ #S xP - y % % m plot(x,y) # % $% % Q , #/

$% % < L ' ( JD( % L 7 < # '% # % 7


$ :% Q , JD( y ' = # % % 6 title(' JD( ') # %
$ :% Q , 4# : #" 6 % ' ( 6f #"
ylabel(' y ') xlabel(' x #" ') # %
. 5 y #5" <%. 5 $ 6 q@L #( '%. x #" % 4 m set(gca,'XTick', JS # % ) # %
6
$ 6 '% R YTick P [
T 5; 2 56 5W % #5 5 C' ( q@L J!1 # % ,6 6 D set(gca,'XTickLabel', : ) # %
$ 6 '% R YTickLabel P [ . y #" D ^+ $ :%
$ :% Q , JD( (x,y) ; @ % ' ( q@L * text(x,y,' * ') # %
$ :% d 6 ' #@3% : #" 6%#2 e m axis([x-min x_max y_min y_max]) # %
] . JD( % # %* 7 N
Matlab

5 I 5 5/ 9 \2 % # % % C\2 % Fm ` C%#L 7 \2 % 6 ( † 1 <= # % I


:. , ; L # % 6* $% % 1 \2 % # % [ < # ' hA $ ! y JD( % text # %
$ 6 7

$% % Q , JD( : 6 % %#, [ <# plot # % ,6


Matlab

'% R 5 JD5( 5 5 „ 5L . plot(x,y,'+') # % cha &% % d JD( Q , '#" < # , :' I ,6


5 56 %#5, 5 [ <% 6 , <# D * .$ 6 1‡ JD( plot(x,y,'r') # % $ 6
‡5 5 'w' 5 = ‡5 5 'b' C ! ‡ 'g' C 1 ‡ 'r' ]. !A + :' I % 6 '% R ' ( JD(
$ R

5 hA =‡ x P - y2 %#, „ hA 1‡ x P - y1 %#, plot(x,y1,'+r',x,y2,'ob') # %


$ :% Q , o

m-file -
5 L 6 ' #@3% # J % = # C ( % . 6 7 : #2 6 6 # %% 9 1
#2 $ 6 ' 2f ' ( P; <= % MATLAB 6 work 2 ( % .m # / ( ! MATLAB %#2 _ #
] :% L Enter >6 6 ` MATLAB \ " % <= 6 # %*
Matlab

$% I W % # % <# A \2 <= MATLAB C ( ( % 1 % hA F2 % I


] . JD( MATLAB \ " % y m-file 7 '#"
Matlab

. /, %
5 a = zeros(m,n) # % cha $% 6 % 0 - T2 <# = ,6 6 % % %#7 9 # MATLAB %
'% R 5 ones # 5 % . zeros # 5 % 57 I $% ^I a <= 6 % 0 RS S A <# n F m
R5S 5 m j >5S 5F1 5S A 5- 9 eye(n) # % $%# : #2 j # S A , C 6
$ 6 % 0 n '. :

*1 2 3 MATLAB 0
5 5 5 D Image Processing 5 !97 $ MATLAB : > 1* , . D #; ) + B. % /
$ 2% / : #2 R ' ; B. % / /_# % % $% ^I 2 % + R ' ; B. % /

*1 4 +
‡5 •# RS KF 6 % % rxx RS * ( KF Pixel #; J D / Fm : C R ' #; %
$% % Q , ˆ% A #; J D / : ( KF < # * $ R ‡ •# rxx KF '

2 : m 6 <# n F m > D/. _1 % C …•|k•ˆ| cha mkn '. R ' #;


#; <# image read imread # % ,6 $ ( #; J D / <= ( KF ' :%< L
] :% Q , #; #S * imshow _ $% 6 MATLAB % #S
Matlab

RS * m m- % A double i# . ( rxx RS * # 6 uint8 i# . # #; S A


$ (
]% % 0 JD( [ <# subplot _ ,6
Matlab

) +5 5 5 #5; reshape _ 5 5,6 5 * $% % L #>9 . 9 % : 3 + B. % /


$ %I >S '. #; ' % _ * ,: ,6 B. % / . / 6 J ! 9
Matlab

conv *"+
<% 56 #3 # 56 5 9 5 56 *5 $% 56 ) 5,A #5; 5 hc a5 ) + 5 5 5> 5 <# # % * ,6
5 ' 5,: 56 cameraman.tif 5 5 rx…krx… #5; . 6 9F1 $ > ‰ / #; ) + convolution
1 1 1
Q 5, 50 '% 56 ) ,A <= h =[ , , ] ‰ / I\ # > ' #2 %#( H MATLAB
3 3 3
] 6 7# <% 6 reshape '#" $ :%
Im = imread ( ' cameraman.tif ' );
I = im2double ( Im );

% size of this image is 256*256


Vector = reshape ( I , 1 , 256*256 ); %Image as a vector

h1 = [1/3 1/3 1/3]; % or "h1 = ones(1,3)/3"

Filt = conv ( Vector , h1 );

F = Filt ( 2 : end-1 );

Out = reshape ( F , 256 , 256 ); vector as image

imshow ( Out );
i#5 *5 5 ' ( ' #2 #; im2double _ ,6 C 6 J,A double i# . :'% % #
\m conv # % <#[
$ 6 J ! '% %
'. 5 5D 5 * 5 $%#5( *(#3# 6 0 - n-1 %#( VA Cn )#4 ‰ / > <% 6 #3 # 6
%5 5 . J5 D / 5 5 .J D/ F = Filt ( 2 : end-1 ) # % ,6 C ( D >S #; 7 2 #;
$ 6 6 7 2
9 % 6 B. % / 0 J ! % reshape 9 % 9 % #; J ! ) reshape _
$ #( B. % / ' ( ' [ : ) ! % #; # Cy 6 9F1 . '% R $% 6 #; 9 %
* $ 6 B. % / % reshape , 1 % ch!1 Z = ,6 Z : ) !% #; : F C 6 * 7 #
$ 6 m : ‚ ! 6 h = [−1,2,−1] ‰ / ^Iy > #; *(#3# 6 % D %

56 7 *8 *1 2 3
5 # J 5! <= . fft _ 5 5,6 5 6 J ! 9 ) + <= C
6 '.#- % #; B. % /
5 % % 5m < #5 angle abs _ # ,6 6 \> @ % fft _ 0 $
I Fast Fourier Transform
$% = % <= .
] :% <L 6 8 % 9 #S #; ) + B. % / )#S . 6 9F1
Im = imread('eight.tif');
I = im2double(Im);

[row col] = size(I);


% size of this image is row*col
x = reshape(I,1,row*col); %Image as a vector

% Fourier Transform
X = fft(x);
X = fftshift(X);
Matlab

% Amplitude of Fourier Transform


absX = abs(X);

% Phase of Fourier Transform


angX = angle(X);
% High-pass filter
H = zeros(1,row*col);
H(1 : row*col/3) = 1;
H(end - row*col/3 : end) = 1;

absY = H .* absX;

Y = absY .* exp(j*angX);
Y = fftshift(Y);

y = ifft(Y);
y = real(y);

Out = reshape(y,row,col);

imshow(Out),title('High-pass Filter');

y 5 56 59F1 % 56 #I< ,: $ ( '% <= J >" 6 Jm ? 4 6 # 6 6 : R3# fftshift _


5 # J ! Y$ ' (Y #; # J ! '. % 6 )=' ^Iy > 6 ‰ / '. H C
j .angX
fftshift _ 5 % 50 ) 5,A 5 $ (Y = absY .e
) 5= 5 5 % 5 >S # J ! . 7 '. P 6 . 6
< 5 . '.#5- 5 5 7 5 # J 5! Inverse FFT ifft _ 5 5,6 %I < L >S < D 6 : R3O
$ 6 J ! #; reshape _ ,6 7 2 #; < ,: 6 <= m m- , 1 ' % I

MATLAB *1 2 3 < 9$: ; *


Image Display
colorbar Display color bar (MATLAB function)
image Create and display image object (MATLAB function)
imagesc Scale data and display as image (MATLAB function)
immovie Make movie from multiframe indexed image
imshow Display image in a MATLAB figure window
imtool Display image in the Image Viewer
montage Display multiple image frames as rectangular montage
subimage Display multiple images in single figure
warp Display image as texture-mapped surface

Image File I/O


dicomanon Anonymize a DICOM file
dicomdict Specify which DICOM data dictionary to use
dicominfo Read metadata from a DICOM message
dicomread Read a DICOM image
dicomuid Generate DICOM unique identifier
dicomwrite Write a DICOM image
dicom-dict.txt Text file containing DICOM data dictionary
imfinfo Return information about image file (MATLAB function)
imread Read image file (MATLAB function)
imwrite Write image file (MATLAB function)
Matlab

Image Types and Type Conversions


dither Convert image using dithering
double Convert data to double precision (MATLAB function)
gray2ind Convert intensity image to indexed image
grayslice Create indexed image from intensity image by thresholding
graythresh Compute global image threshold using Otsu's method
im2bw Convert image to binary image by thresholding
im2double Convert image array to double precision
im2int16 Convert image array to 16-bit signed integer
im2java Convert image to instance of Java image object (MATLAB function)
im2java2d Convert image to instance of Java buffered image object
im2single Convert image array to single precision
im2uint16 Convert image array to 16-bit unsigned integers
im2uint8 Convert image array to 8-bit unsigned integers
ind2gray Convert indexed image to intensity image
ind2rgb Convert indexed image to RGB image
int16 Convert data to signed 16-bit integers (MATLAB function)
label2rgb Convert a label matrix to an RGB image
mat2gray Convert matrix to intensity image
rgb2gray Convert RGB image or colormap to grayscale
rgb2ind Convert RGB image to indexed image
uint16 Convert data to unsigned 16-bit integers (MATLAB function)
uint8 Convert data to unsigned 8-bit integers (MATLAB function)

Modular Tool Creation Functions


imageinfo Image Information tool
imcontrast Adjust Contrast tool
imdisplayrange Display range tool
impixelinfo Pixel Information tool
impixelinfoval Pixel Information tool, without text label
impixelregion Pixel Region tool
impixelregionpanel Pixel Region scroll panel

Navigational tools
immagbox Image Information tool
imoverview Adjust Contrast tool
imoverviewpanel Display range tool
imscrollpanel Pixel Information tool

Utility Functions
axes2pix Convert axes coordinate to pixel coordinate
getimage Get image data from axes
getimagemodel Retrieve imagemodel objects from image handles
imattributes Return information about image attributes
imgca Get handle to current image axes
imgcf Get handle to current image figure
imgetfile Image Open File dialog box
imhandles Get all image handles
impositionrect Create position rectangle
iptaddcallback Add function handle to callback list
iptcheckhandle Check validity of handle
iptgetapi Get Application Programmer Interface from a handle
ipticondir Directories containing IPT and MATLAB icons
iptremovecallback Delete function handle from callback list
iptwindowalign Align figure windows
truesize Adjust display size of image

Spatial Transformations
checkerboard Create checkerboard image
findbounds Find output bounds for spatial transformation
fliptform Flip the input and output roles of a TFORM structure
imcrop Crop image
Matlab

imresize Resize image


imrotate Rotate image
imtransform Apply 2-D spatial transformation to image
makeresampler Create resampling structure
maketform Create geometric transformation structure
tformarray Geometric transformation of a multidimensional array
tformfwd Apply forward geometric transformation
tforminv Apply inverse geometric transformation

Image Registration
cp2tform Infer geometric transformation from control point pairs
cpcorr Tune control point locations using cross-correlation
cpselect Control point selection tool
cpstruct2pairs Convert CPSTRUCT to valid pairs of control points
normxcorr2 Normalized two-dimensional cross-correlation

Image Analysis
bwboundaries Trace region boundaries in binary image
bwtraceboundary Trace object in binary image
edge Find edges in intensity image
hough Hough transform
houghlines Extract line segments based on the Hough transform
houghpeaks Identify peaks in the Hough transform
qtdecomp Perform quadtree decomposition
qtgetblk Get block values in quadtree decomposition
qtsetblk Set block values in quadtree decomposition

Texture Analysis
entropy Entropy of an intensity image
entropyfilt Local entropy of an intensity image
graycomatrix Gray-level co-occurrence matrix
graycoprops Properties of a gray-level co-occurrence matrix
rangefilt Local range of an image
stdfilt Local standard deviation of an image

Pixel Values and Statistics


corr2 Compute 2-D correlation coefficient
imcontour Create contour plot of image data
imhist Display histogram of image data
impixel Determine pixel color values
improfile Compute pixel-value cross-sections along line segments
mean2 Compute mean of matrix elements
pixval Display information about image pixels
regionprops Measure properties of image regions
std2 Compute standard deviation of matrix elements

Image Arithmetic
imabsdiff Compute absolute difference of two images
imadd Add two images, or add constant to image
imcomplement Complement image
imdivide Divide two images, or divide image by constant
imlincomb Compute linear combination of images
immultiply Multiply two images, or multiply image by constant
imsubtract Subtract two images, or subtract constant from image

Image Enhancement
adapthisteq Perform adaptive histogram equalization using CLAHE
decorrstretch Apply a decorrelation stretch to a multi-channel image
histeq Enhance contrast using histogram equalization
imadjust Adjust image intensity values or colormap
imnoise Add noise to an image
intlut Compute new array values based on lookup table (LUT)
Matlab

medfilt2 Perform 2-D median filtering


ordfilt2 Perform 2-D order-statistic filtering
stretchlim Return a pair of intensities that can be used to increase the contrast of an image
wiener2 Perform 2-D adaptive noise-removal filtering

Image Restoration (Deblurring)


deconvblind Restore image using blind deconvolution
deconvlucy Restore image using accelerated Richardson-Lucy algorithm
deconvreg Restore image using regularized filter
deconvwnr Restore image using Wiener filter
edgetaper Taper the discontinuities along the image edges
otf2psf Convert optical transfer function to point spread function
psf2otf Convert point spread function to optical transfer function

Linear Filtering
conv2 Perform 2-D convolution (MATLAB function)
convmtx2 Compute 2-D convolution matrix
convn Perform N-D convolution (MATLAB function)
filter2 Perform 2-D filtering (MATLAB function)
fspecial Create predefined filters
imfilter Multidimensional image filtering

Linear 2-D Filter Design


freqspace Determine 2-D frequency response spacing (MATLAB function.)
freqz2 Compute 2-D frequency response
fsamp2 Design 2-D FIR filter using frequency sampling
ftrans2 Design 2-D FIR filter using frequency transformation
fwind1 Design 2-D FIR filter using 1-D window method
fwind2 Design 2-D FIR filter using 2-D window method

Image Transforms
dct2 Compute 2-D discrete cosine transform
dctmtx Compute discrete cosine transform matrix
fan2para Convert fan-beam projection data to parallel-beam
fanbeam Compute fan-beam transform
fft2 Compute 2-D fast Fourier transform (MATLAB function)
fftn Compute N-D fast Fourier transform (MATLAB function)
fftshift Reverse quadrants of output of FFT (MATLAB function)
idct2 Compute 2-D inverse discrete cosine transform
ifft2 Compute 2-D inverse fast Fourier transform (MATLAB function)
ifftn Compute N-D inverse fast Fourier transform (MATLAB function)
ifanbeam Compute inverse fan-beam transform
iradon Compute inverse Radon transform
para2fan Convert parallel-beam projections to fan-beam
phantom Generate a head phantom image
radon Compute Radon transform

Intensity and Binary Images


conndef Default connectivity array
imbothat Perform bottom-hat filtering
imclearborder Suppress light structures connected to image border
imclose Close image
imdilate Dilate image
imerode Erode image
imextendedmax Find extended-maxima transform
imextendedmin Find extended-minima transform
imfill Fill image regions
imhmax Calculate H-maxima transform
imhmin Calculate H-minima transform
imimposemin Impose minima
imopen Open image
imreconstruct Perform morphological reconstruction
Matlab

imregionalmax Find regional maxima of image


imregionalmin Find regional minima of image
imtophat Perform tophat filtering
watershed Find image watershed regions

Binary Images
applylut Perform neighborhood operations using lookup tables
bwarea Area of objects in binary image
bwareaopen
bwdist Distance transform
bweuler Euler number of binary image
bwhitmiss Binary hit-and-miss operation
bwlabel Label connected components in 2-D binary image
bwlabeln Label connected components in N-D binary image
bwmorph Perform morphological operations on binary image
bwpack Pack binary image
bwperim Find perimeter of objects in binary image
bwselect Select objects in binary image
bwulterode Ultimate erosion
bwunpack Unpack a packed binary image
imregionalmin Regional minima of image
imtophat Perform tophat filtering
makelut Construct lookup table for use with applylut

Structuring Element (STREL) Creation and Manipulation


getheight Get the height of a structuring element
getneighbors Get structuring element neighbor locations and heights
getnhood Get structuring element neighborhood
getsequence Extract sequence of decomposed structuring elements
isflat Return true for flat structuring element
reflect Reflect structuring element
strel Create morphological structuring element
translate Translate structuring element

Region-Based Processing
poly2mask Convert region-of-interest polygon to mask
roicolor Select region of interest, based on color
roifill Smoothly interpolate within arbitrary region
roifilt2 Filter a region of interest
roipoly Select polygonal region of interest

Neighborhood and Block Processing


bestblk Choose block size for block processing
blkproc Implement distinct block processing for image
col2im Rearrange matrix columns into blocks
colfilt Perform neighborhood operations using column-wise functions
im2col Rearrange image blocks into columns
nlfilter Perform general sliding-neighborhood operations

Colormap Manipulation
brighten Brighten or darken colormap (MATLAB function)
cmpermute Rearrange colors in colormap
cmunique Find unique colormap colors and corresponding image
colormap Set or get color lookup table (MATLAB function)
imapprox Approximate indexed image by one with fewer colors
rgbplot Plot RGB colormap components (MATLAB function)

Color Space Conversions


applycform Apply device-independent color space transformation
hsv2rgb Convert HSV values to RGB color space (MATLAB function)
iccread Read ICC color profile
iccwrite Write ICC color profile
Matlab

isicc Determine if ICC color profile is valid


lab2double Convert color values to double
lab2uint16 Convert color values to uint16
lab2uint8 Convert color values to uint8
makecform Create device-independent color space transform structure
ntsc2rgb Convert NTSC values to RGB color space
rgb2hsv Convert RGB values to HSV color space (MATLAB function)
rgb2ntsc Convert RGB values to NTSC color space
rgb2ycbcr Convert RGB values to YCbCr color space
whitepoint Returns XYZ values of standard illuminants
xyz2double Convert XYZ color values to double
xyz2uint16 Convert XYZ color values to uint16
ycbcr2rgb Convert YCbCr values to RGB color space

Toolbox Preferences
iptgetpref Get value of Image Processing Toolbox preference
iptsetpref Set value of Image Processing Toolbox preference

Toolbox Utility Functions


getrangefromclass Get dynamic range of image based on its class
iptcheckconn Check validity of connectivity argument
iptcheckinput Check validity of array
iptcheckmap Check validity of colormap
iptchecknargin Check number of input arguments
iptcheckstrs Check validity of strings
iptnum2ordinal Convert positive integer to ordinal string

Interactive Mouse Utility Functions


getline Select polyline with mouse
getpts Select points with mouse
getrect Select rectangle with mouse

Array Operations
circshift Shift array circularly (MATLAB function)
padarray Pad an array

Demos
iptdemos Display index of Image Processing Toolbox demos

Performance
ippl Check for presence of Intel Performance Primitives Library (IPPL)

MATLAB ' = "4 , %'" + > &? 0*+

'#" J >" ?> @ : %#, $ 3 6 , - 4 J >" % <= % 6 CMATLAB > 1. D


< # A < * % MATLAB *D, { c 89 #(% # X 6 ,6 < F2 ) 6 , % D>,A
J >" )#S J f % $ , : - 4 J >" 7) 6* ,6 C
$ #( (= MATLAB ,6 3 6 ,

@A3B *8 > 9 ; # $
] b@ #S % s P - >,7 [ % J ( #I eh/y '.#- % LTI , J ! _ 6 %
Matlab

] (# !F1 : RS Y JS - #S <# : >,7 [*

$ : !F1 Pi : RS Z i C ' k 6

$% 6 ? 9 JD( % : % J ! _ <# MATLAB %

DTransfer FunctionC tf *"+


<= 5 56 J ! _ <# tf ( [ #S >,7 [ P % ],[b @ >,7 [ P % ]) # % ,6
$% 6 ? 9 ( ) JD(

DZero-Pol-GainC zpk *"+


$%#, ? 9 % J ! _ <# zpk ( [ RS % m % ] , [ PF1 %m % ],' ) # % ,6

] :% <L + D =J ! g# _ # <% 6 '#" . JD(


Matlab

@A3B > 9 5E( > 9 ; <-


$%#( '% R residue _ . Ceh/y J ! DA ! " 3# 7 : 6 J ! _ 0
] ( ' ( ? 9 . JD( , 6p

] 6J ! . JD( 7 : 6 J ! _ * : #2

J 5! _ 5 b @ #S P b a$ 6 H k p r : % P3 1 % ! " P [r p k] = residue(a ,b) _


] ! . JD( $ :

$ 6 J ! _ JD( Q , % 3 0 % tf _ . '% R

%'" +F
5 6p 5 $ . 7 '% 6 P 6 : ?> @ , # feedback parallel Cseries _ # ,6
] . . : #2

] :% <L g# * 2 '#" . JD(


Matlab

= "4 , %'" + ' + > &?


J5 f % 56 % ^5I 5 6 2 % 3 6 , \! : %#, @ / R _ # MATLAB
$ ' ( '% % < L = . 89 % 6

impulse ; ' G H+ 3 I+
Matlab

step ; ' &3 H+ 3 I+

bode ; ' *, *'6 I+


Matlab

rlucas ; ' @ *= J > &?

nichols ; <=*E 6 > &?


Matlab

sigma ; KE

nyquist ; L *E 6 > &?


Matlab

ltiview <
]% 6 _# #2 . < \! : %#, ,: < # * ,6
Matlab
Matlab
Matlab
Matlab

sisotool <
$ Single Input Single Output 7 2 % , J >" - 4 sisotool
Matlab

$ 5 6 5 5 5: %#, d * N '% % d %#2 2 - # * ,6


$ 6 p#A hA „}ƒ L >6 2 # , y (#I FS >6 >6 cha
5 %#52 5 CTools #5 5,6 # ' hA $ ! : %#, # Analysis # E 4 .
$ 6 % S simlulink

simulink <
* $ D I I % s#> ,6 MATLAB ?> @ , 7 <% 6 % #1 simulink
5 i#5 6#> J ( 6 * @ 6 simulink # % 7 $%#( '% R A# : !97 • ! % #
]% I 1 6e % %

J5 >" 5 5F " # 5 % *5 7$ 6 '% R ltiblock < . 3 6 , J >" % simulink . '% R


50 . 5/ '% = \ 5" *5 J52 % @ 6 J2 % . simulink 6#> % ^I ,( 2 % 3 6 ,
$ 6 . !( % D>,A C .y y ;
] 3 6 , J >" simulink R 6#> . 89 J f %
Matlab

$ ( R 7 2 >D( J >" % # scope s#>

= "4 , %'" + < 9$: ; *


General
ctrlpref Set Control System Toolbox preferences
ltimodels Detailed help on the various types of LTI models
ltiprops Detailed help on available LTI model properties

Creating Linear Models


filt Specify a digital filter
frd Create a frequency-response data models
lti/set Set/modify properties of LTI models
ss, dss Create state-space models (continuous/discrete)
tf Create transfer function models
zpk Create zero/pole/gain models

Data Extraction
dssdata Descriptor version of ssdata
frdata Extract frequency-response data
lti/get Access values of LTI model properties
ssdata Extract state-space matrices
tfdata Extract numerators and denominators
zpkdata Extract zero/pole/gain data

Conversions
c2d Convert from continuous- to discrete-time models
chunits Convert the units property for FRD models
d2c Convert from discrete- to continuous-time models
d2d Test true for continuous-time models
frd Convert to a frequency-response data model
ss Convert to a state-space model
Matlab

tf Convert to a transfer function model


zpk Convert to a zero/pole/gain model

System Interconnections
append Group LTI systems by appending inputs and outputs
connect Derive state-space models from block diagram descriptions
feedback Feedback connections of two systems
lft Generalized feedback interconnection (Redheffer star product)
parallel Generalized parallel connection (see also overloaded +)
series Generalized series connection (see also overloaded *)

System Gain and Dynamics


bandwidth System bandwidth
dcgain D.C. (low-frequency) gain
bandwidth System bandwidth
damp Natural frequency and damping of system poles
dsort Norms of LTI systems
esort Sort continuous poles by real part
iopzmap Input/output pole/zero map
lti/norm Norms of LTI systems
modsep Region-based modal decomposition
pole, eig System poles
pzmap Pole/zero map
stabsep Stable/unstable decomposition

Time Domain Analysis


covar Covariance of response to white noise
gensig Generate input signal for lsim
impulse Impulse response
initial Response of state-space system with given initial state
lsim Response to arbitrary inputs
ltiview Response analysis GUI (LTI Viewer)
step Step response

Frequency Domain Analysis


allmargin All crossover frequencies and related gain/phase margins
bode Bode diagrams of the frequency response
bodemag Bode magnitude diagram only
evalfr Evaluate frequency response at given frequency
freqresp Frequency response over a frequency grid
frd/interp Interpolate frequency-esponse data
ltiview Response analysis GUI (LTI Viewer)
margin Gain and phase margins
nichols Nichols plot
nyquist Nyquist plot
sigma Plot the pole/zero map of an LTI model

Classical Design
rlocus Evans root locus
sisotool SISO design GUI (root locus and loop-shaping techniques)

Pole Placement
acker SISO pole placement
estim Form estimator given estimator gain
place MIMO pole placement
reg Form regulator given state-feedback and estimator gain

LQR/LQG Design
augstate Augment output by appending states
lqg Single-step LQG design
Matlab

lgr, dlqr Linear-quadratic (LQ) state-feedback regulator


lqrd Discrete LQ regulator for continuous plants
lqrreg Form LQG regulator given LQ gain and Kalman estimator
lqgy LQ regulator with output weighting
kalman Kalman estimator
kalmand Discrete Kalman estimator for continuous plants

State-Space Models
balreal Grammian-based input/output balancing
canon State-space canonical forms
ctrb Controllability matrix
gram Controllability and observability grammians
minreal Minimal realization and pole/zero cancellation
modred Model state reduction
margin Calculate gain and phase margins
ngrid Superimpose grid lines on a Nichols plot
nichols Calculate Nichols plot
nyquist Calculate Nyquist plot
obsv Observability matrix
sminreal Structurally minimal realization
ss2ss State coordinate transformation
ssbal Diagonal balancing of state-space realizations

Time Delays
delay2z Replace delays by poles at z=0 or FRD phase shift
hasdelay True for models with time delays
pade Pade approximation of time delays
totaldelay Total delay between each input/output pair

Model Dimensions and Characteristics


class Model type ('tf', 'zpk', 'ss', or 'frd')
isct True for continuous-time models
isdt True for discrete-time models
isproper True for proper models
issiso True for single-input/single-output models
lti/ndims Number of dimensions
lti/isempty True for empty LTI models
reshape Reshape array of linear models size Model sizes and order

Overloaded and Arithmetic Operators


+ and - Add and subtract systems (parallel connection)
* Multiply systems (series connection)
\ Left divide -- sys1\sys2 means inv(sys1)*sys2
/ Right divide -- sys1/sys2 means sys1*inv(sys2)
^ Powers of a given system
' Pertransposition
.' Transposition of input/output map
[..] Concatenate models along inputs or outputs
stack Stack models/arrays along some array dimension
lti/inv Inverse of an LTI system
conj Complex conjugation of model coefficients

Matrix Equation Solvers


bdschur Block diagonalization of a square matrix
care, dare Solve algebraic Riccati equations
gcare, gdare Solve generalized algebraic Riccati equations
lyap, dlyap Solve Lyapunov equations
lyapchol, dlyapschol Square-root Lyapunov equations

Command-Line Plot Customization


Matlab

bodeplot Bode magnitude and phase plus plot handle


getoptions Get the plot options handle
hsvplot Hankel singular value plus plot handle
impulseplot Impulse response plus plot handle
initialplot Initial condition plus plot handle
iopzplot Pole/zero maps for input/output pairs plus plot handle
lsimplot Time response to arbitrary inputs plus plot handle
nicholsplot Nichols plot plus plot handle
nyquistplot Nyquist plus plot handle
pzplot Pole/zero plus plot handle
rlocusplot Root locus plus plot handle
setoptions Set plot options
sigmaplot Singular values of the frequency response plus plot handle
stepplot Step response plus plot handle

You might also like