MATLAB...
Transcript of MATLAB...
MATLAB
dilate BW2=dilate(BW1SE) BW2=dilate(BW1SEn) BW2=dilate(BW1SE)SEBW1BW1doubleunit8BW2unit8BW2=dilate(BW1SEn)n 2erode BW2= erode(BW1SE) BW2= erode(BW1SEn) BW2= erode(BW1SE)SEBW1BW1doubleunit8BW2unit8BW2= erode(BW1SEn)n 3bwmorph BW2=bwmorph(BW1operation) BW2=bwmorph(BW1operationn) bwmorphBW1bwmorphBW1noperation clean(01) close dilate erode 4imclose IM2=imclose(IM,SE) IM2=imclose(IM,NHOOD) 5imopen IM2=imopen(IM,SE) IM2=imopen(IM,NHOOD) 3MATLAB 3.1 [4] tire.tif I1=imread('tire.tif'); %tire.tif I2=imnoise(I1,'salt & pepper'); % figure,imshow(I2) % I3=im2bw(I1); % figure,imshow(I3) % I4=bwmorph(I3,'open'); % figure,imshow(I4) % I5=bwmorph(I4,'close'); % figure,imshow(I5) %
Matlab
1. Matlab 1.1 imhist imhist(I,n) imhist(X,map)imhist(I,n) n 256imhist(X,map) X map stem(x,counts) 1.2 imcontour imcontour(I,n),imcontour(I,v)n v 1.3 imadjust J=imadjust(I,[low high],[bottom top],gamma) newmap=imadjust(map,[low high],[bottom top],gamma)J=imadjust(I,[low high],[bottom top],gamma) gamma r[low high] [bottom top] newmap=imadjust(map,[low high],[bottom top],gamma) map [low high] [bottom top] 23 RGB 31.4 histeq J=histeq(I,hgram) J=histeq(I,n) [J,T]=histeq(I,...) newmap=histeq(X,map,hgram) newmap=histeq(X,map) [new,T]=histeq(X,...)J=histeq(I,hgram) I hgram hgram [0,1] J=histeq(I,n) n 64[J,T]=histeq(I,...) I J T newmap=histeq(X,map) [new,T]=histeq(X,...) 2. Matlab imnoise J=imnoise(I,type) J=imnoise(I,type,parameter)J=imnoise(I,type) I J type parameter 3. Matlab 3.1 conv2 C=conv2(A,B) C=conv2(Hcol,Hrow,A) C=conv2(...,'shape') C=conv2(A,B) conv2 A B [Ma,Na]size(A), [Mb,Nb]=size(B), size(C)=[Ma+Mb-1,Na+Nb-1]; C=conv2(Hcol,Hrow,A) A Hcol Hrow C=conv2(...,'shape') conv2 shape full same A valid 0 size(A)>size(B) size(C)=[Ma-Mb+1,Na-Nb+1]3.2 conv conv2 3.3 filter2 fspecial Y=filter2(B,X) Y=filter2(B,X,'shape') Y=filter2(B,X) filter2 B FIR X Y X Y=filter2(B,X,'shape') filter2 Y shape full size(Y)>size(X) same Y X valid 0 size(Y)size(B) size(C)=[Ma-Mb+1,Na-Nb+1]3.2 conv conv2 3.3 filter2 fspecial Y=filter2(B,X) Y=filter2(B,X,'shape') Y=filter2(B,X) filter2 B FIR X Y X Y=filter2(B,X,'shape') filter2 Y shape full size(Y)>size(X) same Y X valid 0 size(Y)0mask_e=mask(1,[2:2:N-1]);mask_o=mask(1,[1:2:N]);elsemask_e=mask(1,[2:2:N]);mask_o=mask(1,[1:2:N-1]);end % for m=1:M; ee=conv(mask_e,phi); oo=conv(mask_o,phi); phi(1,[2:2:2*length(ee)])=ee; phi(1,[1:2:2*length(oo)-1])=oo;end;% phi=phi(1N-1)*(2^M)+1);X=linspace(0,N-1,(N-1)*2^M+1);%plot(X,phi); axis ([0,N-1,-0.5,1.5])axis square
mov=aviread('avi2.avi'); temp=size(mov); fnum=temp(2);% for t=1:1:fnum X=(mov(t).cdata);% end
MATLAB[]MATLABMATLAB Toolboxes New ZSM (zero sum multinomial)http://mcgillb.user.msu.edu/zsmcode.html
Binaural-modeling software for MATLAB/Windowshttp://www.lifesci.sus***.ac.uk/home/Michael_Akeroyd/download2.html
Statistical Parametric Mapping (SPM)http://www.fil.ion.ucl.ac.uk/spm/ext/
BOOTSTRAP MATLAB TOOLBOXhttp://www.csp.curtin.edu.au/downloads/bootstrap_toolbox.html
The DSS package for MATLABDSS Matlab package contains algorithms for performing linear, deflation and symmetric DSS.http://www.cis.hut.fi/projects/dss/package/ Psychtoolboxhttp://www.psychtoolbox.org/download.html Multisurface Method Tree with MATLABhttp://www.cs.wisc.edu/~olvi/uwmp/msmt.html A Matlab Toolbox for every single topic !http://stommel.tamu.edu/~baum/toolboxes.html eg. BrainStorm - MEG and EEG data visualization and processingCLAWPACK is a software package designed to compute numerical solutions to hyperbolic partial differential equations using a wave propagation approachhttp://www.amath.washington.edu/~claw/ DIPimage - Image Processing ToolboxPRTools - Pattern Recognition Toolbox (+ Neural Networks) NetLab - Neural Network ToolboxFSTB - Fuzzy Systems ToolboxFusetool - Image Fusion Toolboxhttp://www.metapix.de/toolbox.htm W***EKIT - Wavelet ToolboxGat - Genetic Algorithm Toolbox TSTOOL is a MATLAB software package for nonlinear time series analysis.TSTOOL can be used for computing: Time-delay reconstruction, Lyapunov exponents, Fractal dimensions, Mutual information, Surrogate data tests, Nearest neighbor statistics, Return times, Poincare sections, Nonlinear predictionhttp://www.physik3.gwdg.de/tstool/ MATLAB / Data description toolbox A Matlab toolbox for data description, outlier and novelty detection March 26, 2004 - D.M.J. Tax http://www-ict.ewi.tudelft.nl/~davidt/dd_tools/dd_manual.html MBEhttp://www.pmarneffei.hku.hk/mbetoolbox/ Betabolic network toolbox for Matlab http://www.molgen.mpg.de/~lieberme/pages/network_matlab.html Pharmacokinetics toolbox for Matlab http://page.inf.fu-berlin.de/~lieber/seiten/pbpk_toolbox.html
The SpiderThe spider is intended to be a complete object orientated environment for machine learning in Matlab. Aside from easy use of base learning algorithms, algorithms can be plugged together and can be compared with, e.g model selection, statistical tests and visual plots. This gives all the power of objects (reusability, plug together, share code) but also all the power of Matlab for machine learning research.http://www.kyb.tuebingen.mpg.de/bs/people/spider/index.html Schwarz-Christoffel Toolboxhttp://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=1316&objectType=file#
XML Toolbox http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=4278&objectType=file FIR/TDNN Toolbox for MATLAB Beta version of a toolbox for FIR (Finite Impulse Response) and TD (Time Delay) Neural Networks. http://www.cs.utep.edu/interval-comp/dagstuhl.03/oish.pdf Misc. http://www.dcsc.tudelft.nl/Research/Software/index.html Astronomy Saturn and Titan trajectories ... MALTAB astronomyhttp://sprg.ssl.berkeley.edu/~abrecht/Matlab-codes/
Audio MA Toolbox for Matlab Implementing Similarity Measures for Audiohttp://www.oefai.at/~elias/ma/index.html MAD - Matlab Auditory Demonstrationshttp://www.dcs.shef.ac.uk/~martin/MAD/docs/mad.htm
Music Analysis - Toolbox for Matlab : Feature Extraction from Raw Audio Signals for Content-Based Music Retrievalhttp://www.ai.univie.ac.at/~elias/ma/
WarpTB - Matlab Toolbox for Warped DSPBy Aki Hrm and Matti Karjalainenhttp://www.acoustics.hut.fi/software/warp/
MATLAB-related Softwarehttp://www.dpmi.tu-graz.ac.at/~schloegl/matlab/
Biomedical Signal data formats (EEG machine specific file formats with Matlab import routines)http://www.dpmi.tu-graz.ac.at/~schloegl/matlab/eeg/
MPEG Encoding library for MATLAB Movies (Created by David Foti)It enables MATLAB users to read (MPGREAD) or write (MPGWRITE) MPEG movies. That should help Video Quality project.
Filter Design packagehttp://www.ee.ryerson.ca:8080/~mzeytin/dfp/index.html
Octave by Christophe COUVREUR (Generates normalized A-weigthing, C-weighting, octave and one-third-octave digital filters)http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectType=file&objectId=69
Source Coding MATLAB Toolboxhttp://www.ece.umn.edu/users/kieffer/programs.html
Bio Medical Informatics (Top) CGH-Plotter: MATLAB Toolbox for CGH-data AnalysisCode: http://sigwww.cs.tut.fi/TICSP/CGH-Plotter/ Poster: http://sigwww.cs.tut.fi/TICSP/CSB2003/Posteri_CGH_Plotter.pdf
The Brain Imaging Software Toolboxhttp://www.bic.mni.mcgill.ca/software/
MRI Brain Segmentationhttp://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=4879
Chemometrics (providing PCA) (Top) Matlab Molecular Biology & Evolution Toolbox(Toolbox Enables Evolutionary Biologists to Analyze and View DNA and Protein Sequences)James J. Cai http://www.pmarneffei.hku.hk/mbetoolbox/
Toolbox provided by Prof. Massart research grouphttp://minf.vub.ac.be/~fabi/publiek/
Useful collection of routines from Prof age smilde research grouphttp://www-its.chem.uva.nl/research/pac
Multivariate Toolbox written by Rune Mathisenhttp://www.bitjungle.com/~mvartools/index.html
Matlab code and datasetshttp://www.acc.umu.se/~tnkjtg/chemometrics/dataset.html
Chaos (Top) Chaotic Systems Toolbox http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=1597&objectType=file#
HOSA Toolboxhttp://www.mathworks.nl/matlabcentral/fileexchange/loadFile.do?objectId=3013&objectType=file
Chemistry (Top) MetMAP - (Metabolical Modeling, Analysis and oPtimization alias Met. M. A. P.)http://webpages.ull.es/users/sympbst/pag_ing/pag_metmap/index.htm
DoseLab - A set of software programs for quantitative comparison of measured and computed radiation dose distributionshttp://doselab.sourceforge.net
GenBank Overviewhttp://www.ncbi.nlm.nih.gov/Genbank/GenbankOverview.html Matlab: http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=1139
Coding Code for the estimation of Scaling Exponentshttp://www.cubinlab.ee.mu.oz.au/~darryl/secondorder_code.html
Control (Top) Control Tutorial for Matlab http://www.engin.umich.edu/group/ctm/
Another Communications (Top) Channel Learning Architecture toolbox(This Matlab toolbox is a supplement to the article "HiperLearn: A High Performance Learning Architecture")http://www.isy.liu.se/cvl/Projects/hiperlearn/
Source Coding MATLAB Toolboxhttp://www.ece.umn.edu/users/kieffer/programs.html
TCP/UDP/IP Toolbox 2.0.4http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=345&objectType=file
Home Networking Basis: Transmission Environments and Wired/Wireless ProtocolsWalter Y. Chenhttp://www.mathworks.com/support/books/book5295.jsp?category=new&language=-1 MATLAB M-files and Simulink models http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=3834&objectType=file
Engineering (Top) OPNML/MATLAB Facilitieshttp://www.opnml.unc.edu/OPNML_Matlab/
Mesh Generationhttp://www.cs.cornell.edu/home/vavasis/qmg-home.html
OpenFEM : An Open-Source Finite Element Toolbox http://www.openfem.net/
CALFEM is an interactive computer program for teaching the finite element method (FEM)http://www.byggmek.lth.se/Calfem/frinfo.htm
The Engineering Vibration Toolboxhttp://www.cs.wright.edu/people/faculty/jslater/vtoolbox/vtoolbox.html
SaGA - Spatial and Geometric Analysis Toolboxby Kirill K. Pankratovhttp://puddle.mit.edu/~glenn/kirill/saga.html
ASCIIMATLAB
6.1
abs
ASCII
dec2hex
fprintf
hex2dec
hex2num
IEEE
int2str
lower
num2str
setstr
ASCII
sprintf
sscanf
str2mat
str2num
upper
rad=2.5; area=pi*rad^2;
t=[' A circle of radius ' num2str(rad) ' has an area of ' num2str(area) ' . ' ] ;
disp(t)
A circle of radius 2.5 has an area of 19.63.
num2strint2strnum2strint2strsprintfC
fprintfdisp
fprintf(' See what this does ')
See what this does
fprintf(' See what this does\n ')
See what this does
fprintfMATLAB\n MATLAB
fprintfsprintffprintfsprintfnum2str
t=sprintf(' A circle of radius %.4g has an area of %.4g. ', rad, area);
disp(t)
A circle of radius 2.5 has an area of 19.63.
fprintf(' A circle of radius %.4g has an area of %.4g.\n ' , rad, area)
A circle of radius 2.5 has an area of 19.63.
%.4gnum2str%.4g4ge ()f ()6.2pi
6.2
fprintf(' %.0e\n ',pi)
3e+00
fprintf(' %.1e\n ',pi)
3.1e+00
fprintf(' %.3e\n ',pi)
3.142e+00
fprintf(' %.5e\n ',pi)
3.14159e+00
fprintf(' %.10e\n ',pi)
3.1415926536e+00
fprintf(' %.0f\n ',pi)
3
fprintf(' %.1f\n ',pi)
3.1
fprintf(' %.3f\n ',pi)
3.142
fprintf(' %.5f\n ',pi)
3.14159
fprintf(' %.10f\n ',pi)
3.1415926536
fprintf(' %.0g\n ',pi)
3
fprintf(' %.1g\n ',pi)
3
fprintf(' %.3g\n ',pi)
3.14
fprintf(' %.5g\n ',pi)
3.1416
fprintf(' %.10g\n ',pi)
3.141592654
fprintf(' %.8.0g\n ',pi)
3
fprintf(' %.8.1g\n ',pi)
3
fprintf(' %.8.3g\n ',pi)
3.14
fprintf(' %.8.5g\n ',pi)
3.1416
fprintf(' %.8.10g\n ',pi)
3.141592654
e f g 888
dispnum2strint2strfprintfsprintf
str2mat
a=' one ' ; b= ' two ' ; c= ' three ' ;
disp(str2mat(a, b, c, ' four '))
one
two
three
four
s= ' [1 2; pi 4] ' % a string of a MATLAB matrix
s =
[1 2; pi 4]
str2num(s)
ans =
1.0000 2.0000
3.1416 4.0000
s=' 123e+5 ' % a string containing a simple number
s =
123e+5
str2num(s)
ans =
12300000
str2num
MATLAB6.3
6.3
eval(string)
MATLAB
eval(try,catch)
blanks(n)
n
deblank
feval
findstr
isletter
isspace
isstr
lasterr
MATLAB
strcmp
strrep
strtok
evalMATLAB
a=eval(' sqrt(2) ')
a =
1.4142
eval(' a=sqrt(2) ')
a =
1.4142
eval2eval
evalMATLAB
eval(' a=sqrtt(2) ',' a=[ ] ')
a =
[ ]
sqrttMATLABeval(try,catch)
fevalevalfeval(' fun ',x)' fun 'xfeval(' fun ',x)fun(x)
a=feval(' sqrt ' ,2)
a =
1.4142
evalfevalfevalfeval(' fun ', x, y, z) fun(x, y, z)
findstr
b=' Peter Piper picked a peck of pickled peppers ' ;
findstr(b,' ') % find space
ans =
6 12 19 21 26 29 37
findstr(b,' p ') % find the letter p
ans =
9 13 22 30 38 40 41
find(b= = ' p ') % for single character searches the find command works too
ans =
9 13 22 30 38 40 41
findstr(b, ' cow ') % find the word cow
ans =
[ ]
findstr(b,' pick ') % find the string pick
ans =
13 30
findstr
strrep(b, ' p ', ' P ') % capitalize all p ' s
ans =
Peter PiPer Picked a Peck of Pickled PePPers
strrep(b, ' Peter ', ' Pamela ') % change Peter to Pamela
ans =
Pamela Piper picked a peck of pickled peppers
strrepstrrep
strtok
disp(b)
Peter Piper picked a peck of pickled peppers
strtok(b) % find first token in above string separated by whitespace
ans =
Peter
[c, r]=strtok(b) % return the remainder of the string array in r
c =
Peter
r =
Piper picked a peck of pickled peppers
[d,s]=strtok(r) %find the next token by using the previous remainder
d =
Piper
s =
picked a peck of pickled peppers
strtokstrtok
[d, s]=strtok(b, ' pP ') %let delimiter be lower or upper case P
d =
eter
s =
Piper picked a peck of pickled peppers
d = eter
6.1
MATLABASCII
t=' How about this character string? '
t =
How about this character string?
size(t)
ans =
1 32
whos
Name Size Elements Bytes Density Complex
ans 1 by 2 2 16 Full No
t 1 by 32 32 256 Full No
8MATLABASCII7/8MATLABMATLAB
ASCII
u=abs(t)
u =
Columns 1 through 12
72 111 119 32 97 98 111 117 116 32 116 104
Columns 13 through 24
105 115 32 99 104 97 114 97 99 116 101 114
Columns 25 through 32
32 115 116 114 105 110 103 63
u=t+0
u =
Columns 1 through 12
72 111 119 32 97 98 111 117 116 32 116 104
Columns 13 through 24
105 115 32 99 104 97 114 97 99 116 101 114
Columns 25 through 32
32 115 116 114 105 110 103 63
ASCIIsetstr
v=setstr(u)
v =
How about this character string?
MATLAB
u=t(16:24)
u =
character
1624character
u=t(24:-1:16)
u =
retcarahc
character
u=t(16:24)'
u =
c
h
a
r
a
c
t
e
r
character
v=' I can''t find the manual! '
v =
I can't find the manual!
u=' If a woodchuck could chuck wood, ' ;
v=' how much wood would a woodchuck chuck? ' ;
w=[u v]
w =
If a woodchuck could chuck wood, how much wood would a woodchuck chuck?
disp
disp(u)
If a woodchuck could chuck wood,
u =
v=[' Character strings having more than '
' one row must have the same number '
' of column just like matrices! ']
v =
Character strings having more than
one row must have the same number
of column just like matrices!
findsetstr
disp(u)
If a woodchuck could chuck wood,
i=find(u>=' a ' & u=' a ' & v 5
tape =
5
input
x=input(' Enter anything > ',' s ')
Enter anything > anything can be entered
x =
anything can be entered
inputsMATLAB
1.applylut
:
lookup.
:
A = applylut(BW,lut)
lut = makelut('sum(x() == 4',2);
BW1 = imread('text.tif');
BW2 = applylut(BW1,lut);
imshow(BW1)
figure, imshow(BW2)
:
makelut
2.bestblk
:
.
:
siz = bestblk([m n],k)
[mb,nb] = bestblk([m n],k)
siz = bestblk([640 800],72)
siz =
64 50
:
blkproc
3.blkproc
:
MATLAB 320
.
:
B = blkproc(A,[m n],fun)
B = blkproc(A,[m n],fun,P1,P2,...)
B = blkproc(A,[m n],[mborder nborder],fun,...)
B = blkproc(A,'indexed',...)
I = imread('alumgrns.tif');
I2 = blkproc(I,[8 8],'std2(x)*ones(size(x))');
imshow(I)
figure, imshow(I2,[]);
:
colfilt, nlfilter,inline
4.brighten
:
.
:
brighten(beta)
newmap = brighten(beta)
newmap = brighten(map,beta)
brighten(fig,beta)
:
imadjust, rgbplot
5.bwarea
:
.
:
total = bwarea(BW)
BW = imread('circles.tif');
imshow(BW);
MATLAB 321
bwarea(BW)
ans =
15799
:
bweuler, bwperim
6.bweuler.
:
.
:
eul = bweuler(BW,n)
BW = imread('circles.tif');
imshow(BW);
bweuler(BW)
ans =
-2
:
bwmorph, bwperim
7.bwfill
:
.
:
BW2 = bwfill(BW1,c,r,n)
BW2 = bwfill(BW1,n)
[BW2,idx] = bwfill(...)
BW2 = bwfill(x,y,BW1,xi,yi,n)
[x,y,BW2,idx,xi,yi] = bwfill(...)
BW2 = bwfill(BW1,'holes',n)
[BW2,idx] = bwfill(BW1,'holes',n)
MATLAB 322
BW1 =[1 0 0 0 0 0 0 0
1 1 1 1 1 0 0 0
1 0 0 0 1 0 1 0
1 0 0 0 1 1 1 0
1 1 1 1 0 1 1 1
1 0 0 1 1 0 1 0
1 0 0 0 1 0 1 0
1 0 0 0 1 1 1 0]
BW2 = bwfill(BW1,3,3,8)
BW2 =
1 0 0 0 0 0 0 0
1 1 1 1 1 0 0 0
1 1 1 1 1 0 1 0
1 1 1 1 1 1 1 0
1 1 1 1 0 1 1 1
1 0 0 1 1 0 1 0
1 0 0 0 1 0 1 0
1 0 0 0 1 1 1 0
I = imread('blood1.tif');
BW3 = ~im2bw(I);
BW4 = bwfill(BW3,'holes');
imshow(BW3)
figure, imshow(BW4)
:
bwselect, roifill
8.bwlabel
:
.
:
MATLAB 323
L = bwlabel(BW,n)
[L,num] = bwlabel(BW,n)
BW = [1 1 1 0 0 0 0 0
1 1 1 0 1 1 0 0
1 1 1 0 1 1 0 0
1 1 1 0 0 0 1 0
1 1 1 0 0 0 1 0
1 1 1 0 0 0 1 0
1 1 1 0 0 1 1 0
1 1 1 0 0 0 0 0]
L = bwlabel(BW,4)
L =
1 1 1 0 0 0 0 0
1 1 1 0 2 2 0 0
1 1 1 0 2 2 0 0
1 1 1 0 0 0 3 0
1 1 1 0 0 0 3 0
1 1 1 0 0 0 3 0
1 1 1 0 0 3 3 0
1 1 1 0 0 0 0 0
[r,c] = find(L==2);
rc = [r c]
rc =
2 5
3 5
2 6
3 6
:
bweuler, bwselect
9.bwmorph
:
.
:
BW2 = bwmorph(BW1,operation)
BW2 = bwmorph(BW1,operation,n)
BW1 = imread('circles.tif');
MATLAB 324
imshow(BW1);
BW2 = bwmorph(BW1,'remove');
BW3 = bwmorph(BW1,'skel',Inf);
imshow(BW2)
figure, imshow(BW3)
:
bweuler, bwperim, dilate, erode
10.bwperim
:
.
:
BW2 = bwperim(BW1,n)
BW1 = imread('circbw.tif');
BW2 = bwperim(BW1,8);
imshow(BW1)
figure, imshow(BW2)
MATLAB 325
:
bwarea, bweuler, bwfill
11.bwselect
:
.
:
BW2 = bwselect(BW1,c,r,n)
BW2 = bwselect(BW1,n)
[BW2,idx] = bwselect(...)
BW1 = imread('text.tif');
c = [16 90 144];
r = [85 197 247];
BW2 = bwselect(BW1,c,r,4);
imshow(BW1)
figure, imshow(BW2)
:
bwfill, bwlabel, impixel, roipoly, roifill
12.cmpermute
MATLAB 326
:
.
:
[Y,newmap] = cmpermute(X,map)
[Y,newmap] = cmpermute(X,map,index)
To order a colormap by luminance, use:
ntsc = rgb2ntsc(map);
[dum,index] = sort(ntsc(:,1));
[Y,newmap] = cmpermute(X,map,index);
:
randperm
13.cmunique
:
.
:
[Y,newmap] = cmunique(X,map)
[Y,newmap] = cmunique(RGB)
[Y,newmap] = cmunique(I)
:
gray2ind, rgb2ind
14.col2im
:
.
:
A = col2im(B,[m n],[mm nn],block_type)
A = col2im(B,[m n],[mm nn])
:
blkproc, colfilt, im2col, nlfilter
15.colfilt
:
.
:
B = colfilt(A,[m n],block_type,fun)
B = colfilt(A,[m n],block_type,fun,P1,P2,...)
B = colfilt(A,[m n],[mblock nblock],block_type,fun,...)
B = colfilt(A,'indexed',...)
MATLAB 327
:
blkproc, col2im, im2col, nlfilter
16.colorbar
:
.
:
colorbar('vert')
colorbar('horiz')
colorbar(h)
colorbar
h = colorbar(...)
I = imread('blood1.tif');
h = fspecial('log');
I2 = filter2(h,I);
imshow(I2,[]), colormap(jet(64)), colorbar
17.conv2
:
.
:
C = conv2(A,B)
C = conv2(hcol,hrow,A)
C = conv2(...,shape)
A = magic(5)
A =
17 24 1 8 15
23 5 7 14 16
4 6 13 20 22
MATLAB 328
10 12 19 21 3
11 18 25 2 9
B = [1 2 1;0 2 0;3 1 3]
B =
1 2 1
0 2 0
3 1 3
C = conv2(A,B)
C =
17 58 66 34 32 38 15
23 85 88 35 67 76 16
55 149 117 163 159 135 67
79 78 160 161 187 129 51
23 82 153 199 205 108 75
30 68 135 168 91 84 9
33 65 126 85 104 15 27
:
filter2
18.convmtx2
:
.
:
T = convmtx2(H,m,n)
T = convmtx2(H,[m n])
:
conv2
19.convn
: n.
:
C = convn(A,B)
C = convn(A,B,shape)
:
conv2
20.corr2
:
.
MATLAB 329
:
r = corr2(A,B)
:
std2
21.dct2
:
.
:
B = dct2(A)
B = dct2(A,m,n)
B = dct2(A,[m n])
RGB = imread('autumn.tif');
I = rgb2gray(RGB);
J = dct2(I);
imshow(log(abs(J)),[]), colormap(jet(64)), colorbar
J(abs(J) < 10) = 0;
K = idct2(J)/255;
imshow(K)
:
fft2, idct2, ifft2
1. Matlab Matlab fftfft2 fftn N DFT ifftifft2 ifftn DFT Afft(X,N,DIM) X N X Matlab X N DIM Afft2(X,MROWS,NCOLS) MROWS NCOLS X X Afftn(X,SIZE)SIZE X ifftifft2 ifftn% Iimread('lena.bmp');imshow(I)% J=fftshift(fft2(I));figure;imshow(log(abs(J)),[8,10])2. Matlab 2.1. dct2 DCT B=dct2(A) B=dct2(A,m,n) B=dct2(A,[m,n]) Bdct2(A) A DCT B A B Bdct2(A,m,n) B=dct2(A,[m,n]) A 0 B mn2.2. dict2 DCT B=idct2(A) B=idct2(A,m,n) B=idct2(A,[m,n]) Bidct2(A) A DCT B A B Bidct2(A,m,n) B=idct2(A,[m,n]) A 0 B mn2.3. dctmtx DCT Ddctmtx(n)Ddctmtx(n) nn DCT D double 3. Matlab 3.1 Matlab (1) dwt [cA,cD]=dwt(X,'wname') [cA,cD]=dwt(X,Lo_D,Hi_D)[cA,cD]=dwt(X,'wname') 'wname' X cAcD [cA,cD]=dwt(X,Lo_D,Hi_D) Lo_DHi_D (2) idwt X=idwt(cA,cD,'wname') X=idwt(cA,cD,Lo_R,Hi_R) X=idwt(cA,cD,'wname',L) X=idwt(cA,cD,Lo_R,Hi_R,L)X=idwt(cA,cD,'wname') cA cD X 'wname' X=idwt(cA,cD,Lo_R,Hi_R) Lo_R Hi_R X X=idwt(cA,cD,'wname',L) X=idwt(cA,cD,Lo_R,Hi_R,L) X L 3.2 Matlab ------------------------------------------------- --------------------------------------------------- dwt2 wavedec2 idwt2 waverec2 wrcoef2 upcoef2 detcoef2 appcoef2 upwlev2 dwtpet2 idwtper2 -------------------------------------------------------------(1) wcodemat Y=wcodemat(X,NB,OPT,ABSOL) Y=wcodemat(X,NB,OPT) Y=wcodemat(X,NB) Y=wcodemat(X)Y=wcodemat(X,NB,OPT,ABSOL) X Y NB 0NB NB16 OPT 'mat' OPT'row' OPT'col' OPT'mat' ABSOL '1' ABSOL0 ABSOL1 ABS(X)(2) dwt2 [cA,cH,cV,cD]=dwt2(X,'wname') [cA,cH,cV,cD]=dwt2(X,Lo_D,Hi_D)[cA,cH,cV,cD]=dwt2(X,'wname') 'wname' X cAcH,cV,cD [cA,cH,cV,cD]=dwt2(X,Lo_D,Hi_D) Lo_D Hi_D X (3) wavedec2 [C,S]=wavedec2(X,N,'wname') [C,S]=wavedec2(X,N,Lo_D,Hi_D)[C,S]=wavedec2(X,N,'wname') 'wname' X N [C,S]=wavedec2(X,N,Lo_D,Hi_D) Lo_D Hi_D X (4) idwt2 X=idwt2(cA,cH,cV,cD,'wname') X=idwt2(cA,cH,cV,cD,Lo_R,Hi_R) X=idwt2(cA,cH,cV,cD,'wname',S) X=idwt2(cA,cH,cV,cD,Lo_R,Hi_R,S)X=idwt2(cA,cH,cV,cD,'wname') cA cHcHcVcD X X=idwt2(cA,cH,cV,cD,Lo_R,Hi_R) Lo_R Hi_R X X=idwt2(cA,cH,cV,cD,'wname',S) X=idwt2(cA,cH,cV,cD,Lo_R,Hi_R,S) S (5) waverec2 X=waverec2(C,S,'wname') X=waverec2(C,S,Lo_R,Hi_R)X=waverec2(C,S,'wname') CS X 'wname' X=waverec2(C,S,Lo_R,Hi_R) Lo_R Hi_R
| | MAXLCL | |
matlab2009-03-14 10:01A a
abs ASCII
acos
acosh
acot
acoth
acsc
acsch
align
all
angle
ans
any
area
argnames M
asec
asech
asin
asinh
assignin
atan
atan2
atanh
autumn
axes
axis
B b
bar
bar3
bar3h
barh
base2dec X
bin2dec
blanks
bone
box
break while for
brighten
C c
capture 3
cart2pol
cart2sph
cat
caxis
cd
cdedit
cdf2rdf
ceil
cell
cell2struct
celldisp
cellplot
char
chi2cdf
chi2inv
chi2pdf
chi2rnd
chol Cholesky
clabel
cla
class
clc
clear
clf
clock
colorcube
colordef
colormap
colspace
close
colperm
comet
comet3
compass
compose
cond
condeig
condest -1
conj
contour
contourf
contour3
contourslice
conv
cool
copper
cos
cosh
cot
coth
cplxpair
csc
csch
cumsum
cumtrapz
cylinder
D d
dblquad
deal
deblank
dec2base X
dec2bin
dec2hex
deconv
delaunay Delaunay
del2 Laplacian
demo Matlab
det
diag
diary Matlab
diff
digits
dir
disp
display
dlinmod
dmperm Dulmage-Mendelsohn
dos DOS
double
drawnow Matlab
dsolve
E e
echo M
edit M
eig
eigs
end FOR
eps
error
errortrap
erf
erfc
erfcx
erfinv
errorbar
etreeplot
eval
evalin
exist
exit Matlab
exp
expand
expint
expm
expm1 Pade
expm2 Taylor
expm3
eye
ezcontour
ezcontourf
ezgraph3
ezmesh
ezmeshc
ezplot
ezplot3
ezpolar
ezsurf
ezsurfc
F f
factor
feather
feedback
feval
fft Fourier
fft2 Fourier
fftn Fourier
fftshift
fieldnames
figure
fill3
find
findobj
findstr
findsym
finverse
fix
flag
fliplr
flipud
flipdim
floor
flops
flow Matlab
fmin
fminbnd
fmins
fminunc
fminsearch
fnder
fnint
fnval
fnplt
fopen
for for
format
fourier Fourier
fplot
fprintf
fread
fsolve
full
funm
funtool
fzero
G g
gamma
gammainc
gammaln
gca
gcbo ""
gcf
gco
geomean
get
getfield
getframe
ginput
global
gplot
gradient
gray
grid
griddata
gtext
guide
H h
harmmean
help
helpwin
helpdesk
hex2dec
hex2num
hidden
hilb Hilbert
hist
histc
histfit
hold
horner
hot
hsv
I i
if-else-elseif
ifft Fourier
ifft2 Fourier
ifftn Fourier
ifftshift
ifourier Fourier
i, j ""
ilaplace Laplace
imag
image
imagesc
imfinfo
imread
imwrite
imwrite
ind2sub
inf
info MathWorks
inline
inmem
input
inputname
int
int2str
interp1
interp2
interp3
interpn N
interpft FFT
intro Matlab
inv
invhilb Hilbert
ipermute
isa
ischar
isequal
isempty
isfinite
isfield
isglobal
ishandle
ishold
isieee IEEE
isinf
isletter
islogical
ismember
isnan
isnumeric
isobject
isprime
isreal
isspace
issparse
isstruct
isstudent Matlab
iztrans Z
J j , K k
jacobian Jacobian
jet
jordan Jordan
keyboard
kron Kronecker
L l
laplace Laplace
lasterr
lastwarn
leastsq
legend
lighting
line
lines plot
linmod
linmod2
linspace
ln
load MAT
log
log10
log2 2
loglog
logm
logspace
lookfor M
lower
lsqnonlin
lu LU
M m
mad
magic
maple &nb, sp; Maple
mat2str
material
max
mbuild EXE
mcc MEXEXE
mean
median
menuedit
mesh
meshz
meshgrid ""
methods
mex MEX
mfunlis mfunMAPLE
mhelp Maple
min
mkdir
mkpp
mod
more
movie
moviein
mtaylor Taylor
N n
ndims
NaN
nargchk
nargin
nargout
ndgrid
newplot
nextpow2 2
nnz
nonzeros
norm
normcdf
normest 2
norminv
normpdf
normrnd
notebook MatlabWord
null
num2str
numden
nzmax
O o
ode1 Stiff
ode15s Stiff
ode23t Stiff
ode23tb Stiff
ode45 Stiff
odefile ODE
odeget ODE
odephas2 ODE
odephas3 ODE
odeplot ODE
odeprint Matlab
odeset ODE
ones 1
optimset
orient
orth
P p
pack Matlab
pagedlg
patch
path Matlab
pathtool
pause
pcode P
pcolor
peaks Matlab
permute
pi
pie
pie3
pink
pinv
plot
plot3
plotmatrix
plotyy
poissinv
poissrnd
pol2cart
polar
poly
poly2str
poly2sym
polyder
polyfit
polyval
polyvalm
pow2 2
ppval
pretty
print SIMULINK
printsys
prism
procread MAPLE
profile
propedit
pwd
Q q
quad
quad8 (QUADL)
quit Matlab
quiver
quiver3
R r
rand
randn
randperm
range
rank
rats
rcond
real
reallog
realpow
realsqrt
realmax
realmin
rectangle ""
rem
repmat
reshape
residue
return
ribbon
rmfield
roots
rose
rot90 90
rotate
rotate3d
round
rref
rsf2csf
rsums Riemann
S s
save
scatter
scatter3
sec
sech
semilogx X
semilogy Y
series
set
setfield
setstr ASCII
sign
signum
sim SIMULINK
simget SIMULINK
simple
simplify
simset SIMULINK
simulink SIMULINK
sin
sinh
size
slice
solve
spalloc
sparse
spconvert
spdiags
spfun
sph2cart
sphere
spinmap
spline
spones 1
sprandsym
sprank
spring
sprintf
spy
sqrt
sqrtm
squeeze 1""
sscanf
stairs
std
stem
step
str2double
str2mat
str2num
strcat
strcmp
strjust
strmatch
strncmp
strrep
strtok
struct
struct2cell
strvcat
sub2ind
subexpr
subplot
subs
subspace
sum
summer
superiorto
surf
surface
surfc
surfl
surfnorm
svd
svds
switch-case-otherwise
sym2poly
symmmd
symrcm Cuthill-McKee
syms
T t
tan
tanh
taylortool Taylor
text
tf
tic
title
toc
trapz
treelayout
treeplot
tril
trim
trimesh
trisurf triu try-catch Try-catch type M
U u
uicontextmenu
uicontrol
uimenu
unmkpp
unwrap
upper
V v
var
varargin
varargout
vectorize
ver
view
voronoi Voronoi
vpa
W w
warning
what
whatsnew Matlab Readme
which
while While
white
whitebg
who
whos
winter
workspace
X x , Y y , Z z
xlabel X
xor
yesinput
ylabel Y
zeros
zlabel Z
zoom
ztrans Z
http://blog.sina.com.cn/s/blog_59ad64b90100aee9.html
Matlab | | (127) | (1) More Effective C++... matlab matlab (1)
Matlab(1) MATLAB(...
matlab2 MATLAB(...
Matlab num2cell MatlabVBDLL
matlabs matlab
>>
jiahao1889 yjnanli lskansx 329988869
1
329988869 2009-03-18 18:54 |
| *50
()
?
|
|
http://blog.pfan.cn/liangdas
GIS
matlab
GIS
RS
matlab(2009-3-15 22:54:00)
.
1. imread
imreada=imread('e:\w01.tif')
Ew01.tif
2. imwrite
imwriteimwrite(a,'e:\w02.tif',tif)
3. imfinfo
imfinfoimfinfo('e:\w01.tif')
.
1. image
imageMATLAB
a=[1,2,3,4;4,5,6,7;8,9,10,11,12];
image(a);
2. imshow
imshow
i=imread('e:\w01.tif');
imshow(i);
3. colorbar
colorbar caxis [cmin,cmax]=caxismesh(peaks) peakscaxis[-6.54668.0752]Z
i=imread('e:\w01.tif');
imshow(i);
colorbar;
4 .figurefigurefigure(1) /figure(2)
5.imagesc(a); caxis([-3 8]) ; colorbar; -38
.
1. fft2
fft2
i=imread('e:\w01.tif');
j=fft2(i);
2. ifft2
ifft2
i=imread('e:\w01.tif');
j=fft2(i);
k=ifft2(j);
3. fft2
fft2,:
a=[8,1,6;3,5,7;4,9,2];
b=[1,1,1;1,1,1;1,1,1];
a(8,8)=0;
b(8,8)=0;
c=ifft2(fft2(a).*fft2(b));
c=c(1:5,1:5);
conv2(),
a=[8,1,6;3,5,7;4,9,2];
b=[1,1,1;1,1,1;1,1,1];
c=conv2(a,b);
.
1. imnoise
imnoise
i=imread('e:\w01.tif');
j=imnoise(i,'gaussian',0,0.02);%
2. fspecial
fspecial
h=fspecial('sobel');%sobel
h=fspecial('gaussian');%
h=fspecial('laplacian');%
h=fspecial('log');%LoG
h=fspecial('average');%
.
1.
imhist
i=imread('e:\w01.tif');
imhist(i);
2.
histeq
i=imread('e:\w01.tif');
j=histeq(i);
3.
imadjust
i=imread('e:\w01.tif');
j=imadjust(i,[0.3,0.7],[]);
4.
log
i=imread('e:\w01.tif');
j=double(i);
k=log(j);
5.
filter2
i=imread('e:\w01.tif');
h=[1,2,1;0,0,0;-1,-2,-1];
j=filter2(h,i);
6.
conv2, :
i=imread('e:\w01.tif');
h=[1,1,1;1,1,1;1,1,1];
h=h/9;
j=conv2(i,h);
7.
medfilt2
i=imread('e:\w01.tif');
j=medfilt2(i);
8.
1Sobel, :
i=imread('e:\w01.tif');
h=[1,2,1;0,0,0;-1,-2,-1];%Sobel
j=filter2(h,i);
2, :
i=imread('e:\w01.tif');
j=double(i);
h=[0,1,0;1,-4,0;0,1,0];%
k=conv2(j,h,'same');
m=j-k;
.
i=imread('e:\w01.tif');
figure(1);
imshow(i);
colorbar;
j=fft2(i);
k=fftshift(j);
figure(2);
l=log(abs(k));
imshow(l,[]);
colorbar
n=ifft2(j)/255;
figure(3);
imshow(n);
colorbar;
1. Matlab Matlab fftfft2 fftn N DFT ifftifft2 ifftn DFT Afft(X,N,DIM) X N X Matlab X N DIM
Afft2(X,MROWS,NCOLS) MROWS NCOLS X X
Afftn(X,SIZE)SIZE X
ifftifft2 ifftn
% Iimread('lena.bmp');imshow(I)% J=fftshift(fft2(I));figure;imshow(log(abs(J)),[8,10])
2. Matlab
2.1. dct2 DCT B=dct2(A) B=dct2(A,m,n) B=dct2(A,[m,n]) Bdct2(A) A DCT B A B Bdct2(A,m,n) B=dct2(A,[m,n]) A 0 B mn
2.2. dict2 DCT B=idct2(A) B=idct2(A,m,n) B=idct2(A,[m,n]) Bidct2(A) A DCT B A B Bidct2(A,m,n) B=idct2(A,[m,n]) A 0 B mn
2.3. dctmtx DCT Ddctmtx(n)Ddctmtx(n) nn DCT D double
3. Matlab
3.1 Matlab (1) dwt [cA,cD]=dwt(X,'wname') [cA,cD]=dwt(X,Lo_D,Hi_D)[cA,cD]=dwt(X,'wname') 'wname' X cAcD [cA,cD]=dwt(X,Lo_D,Hi_D) Lo_DHi_D (2) idwt X=idwt(cA,cD,'wname') X=idwt(cA,cD,Lo_R,Hi_R) X=idwt(cA,cD,'wname',L) X=idwt(cA,cD,Lo_R,Hi_R,L)X=idwt(cA,cD,'wname') cA cD X 'wname' X=idwt(cA,cD,Lo_R,Hi_R) Lo_R Hi_R X X=idwt(cA,cD,'wname',L) X=idwt(cA,cD,Lo_R,Hi_R,L) X L
3.2 Matlab
------------------------------------------------- --------------------------------------------------- dwt2 wavedec2 idwt2 waverec2 wrcoef2 upcoef2 detcoef2 appcoef2 upwlev2 dwtpet2 idwtper2 -------------------------------------------------------------
(1) wcodemat Y=wcodemat(X,NB,OPT,ABSOL) Y=wcodemat(X,NB,OPT) Y=wcodemat(X,NB) Y=wcodemat(X)Y=wcodemat(X,NB,OPT,ABSOL) X Y NB 0NB NB16 OPT 'mat' OPT'row' OPT'col' OPT'mat' ABSOL '1' ABSOL0 ABSOL1 ABS(X)
(2) dwt2 [cA,cH,cV,cD]=dwt2(X,'wname') [cA,cH,cV,cD]=dwt2(X,Lo_D,Hi_D)[cA,cH,cV,cD]=dwt2(X,'wname') 'wname' X cAcH,cV,cD [cA,cH,cV,cD]=dwt2(X,Lo_D,Hi_D) Lo_D Hi_D X
(3) wavedec2 [C,S]=wavedec2(X,N,'wname') [C,S]=wavedec2(X,N,Lo_D,Hi_D)[C,S]=wavedec2(X,N,'wname') 'wname' X N [C,S]=wavedec2(X,N,Lo_D,Hi_D) Lo_D Hi_D X
(4) idwt2 X=idwt2(cA,cH,cV,cD,'wname') X=idwt2(cA,cH,cV,cD,Lo_R,Hi_R) X=idwt2(cA,cH,cV,cD,'wname',S) X=idwt2(cA,cH,cV,cD,Lo_R,Hi_R,S)X=idwt2(cA,cH,cV,cD,'wname') cA cHcHcVcD X X=idwt2(cA,cH,cV,cD,Lo_R,Hi_R) Lo_R Hi_R X X=idwt2(cA,cH,cV,cD,'wname',S) X=idwt2(cA,cH,cV,cD,Lo_R,Hi_R,S) S
(5) waverec2 X=waverec2(C,S,'wname') X=waverec2(C,S,Lo_R,Hi_R)X=waverec2(C,S,'wname') CS X 'wname' X=waverec2(C,S,Lo_R,Hi_R) Lo_R Hi_R 1. MATLAB(double)64MATLAB(uint8)1 MATLABuint8double uint8double --------------------------------------------- MATLAB --------------------------------------------- B=double(A)+1 B=double(A)/255 B=double(A) ---------------------------------------------
doubleuint8 --------------------------------------------- MATLAB --------------------------------------------- B=uint8(round(A-1)) B=uint8(round(A*255)) B=logical(uint8(round(A))) ---------------------------------------------
2.
2.1 RGB(100,50)(100,50,1:3) [0,1][0,255] 2.2 33 MATLAB[0,1]01 RGB -------------------------------------------- R G B R G B -------------------------------------------- 0 0 1 1 0 1 1 1 1 0 1 1 1 0 0 0.67 0 1 0 1 0 1 0.5 0 0 0 1 0.5 0 0 1 1 0 0.5 0.5 0.5 -------------------------------------------- ------------------------------------------------- ------------------------------------------------- Hsv Hot Cool Pink Gray Bone Jet Hsv Copper Prim Flag -------------------------------------------------- 643 doubleuint8 double1122 uint8012
2.3 double[01]uint8[0,255]
2.4 uint8double MATLABuint8
2.5 MATLAB 44 cat() Acat(4,A1,A2,A3,A4,A5)
3. MATLAB --------------------------------------------------------------------------- --------------------------------------------------------------------------- dither gray2ind grayslice im2bw ind2gray ind2rgb mat2gray rgb2gray rgb2ind ----------------------------------------------------------------------------
4.
4.1 imread()
A=imread(filename,fmt) [X,map]=imread(filename,fmt) [...]=imread(filename) [...]=imread(filename,idx) TIF [...]=imread(filename,ref) HDF
8bitMatlabuint8Matlab16bitPNGTIFMatlabuint16
uint8uint16imread
4.2 imwrite
imwrite(A,filename,fmt) imwrite(X,map,filename,fmt) imwrite(...,filename) imwrite(...,parameter,value)
imwriteMatlabuint8
4.3 imfinfo()
5.
5.1
image(X) colormap(map)
imshow(X,map)
5.2 Matlab 7.0 imshow imagesc imagescale
(1) imshow imshow(I) imshow(I,32) Matlab imshow(I,[low,high]) low high
(2) imagesc imagesc imagesc(1,[0,1]); colormap(gray); imagesc 01
imagesc
5.3 RGB (1) image(RGB) RGBdouble uint8 uint16 Matlab image
RGB8 = uint8(round(RGB64255)); double uint8 RGB64 = double(RGB8)/255; uint8 double RGB16 = uint16(round(RGB6465535)); double uint16 RGB64 = double(RGB16)/65535; uint16 double
(2) imshow(RGB) mn3
5.4
(1) imshow(BW) Matlab 7.0 0 1 0 1 NOT(~) 0 1 imshow(~BW)
(2) uint8 0 1 imshow(BW,[1 0 0;0 0 1])
5.5 imshow filename filename
imshow Matlab 7.0 getimage rgb getimage;
Matlab MATLAB
Matlab
1MATLAB2MATLAB3MATLAB MATLAB
MATLABMATLAB
(toolbox)MATLAB
Toolbox
MATLABImage Processing Toolbox1MATLAB MATLABMatrix Laboratory
MATLAB
MATLAB
MN
MATLABMATLABMATLABRGBBMPGIF
HDFJPEGPCXPNGTIFFXWDCURICOMATLAB
Image Processing Toolbox
2MATLAB MATLAB
CC
x=4:6%461x = 4 5 6xA>> A=[x-3;x;x+3] %AA = 1 2 3 4 5 6 7 8 9AC>> C=A(1:2,2:3)C = 2 3 5 6A >> A(2,2)=0A = 1 2 3 4 0 6 7 8 9A1A(:,1)=1A = 1 2 3 1 0 6 1 8 9A=eye(2) %A = 1 0 0 1>> B=[1,2;3,4] %B = 1 2 3 4>> A+B%ABans = 2 2 3 5>> A.*B %ABans = 1 0 0 4>> A*B %ABABans = 1 2 3 4EimpMATLAB
File----Set Path----Tool---Add Path3MATLABA imread imread [XMAP]=imread(filename,fmt)XMAPfmtfilename
[XMAP]=imreadflowers.tif,tif;B imwriteimwriteimwrite(X,map,filename,fmt)fmtXmapfilenameC imfinfoimfinfoimfinfo(filename,fmt)imfinfoinfo
imfinfo('rice.tif')ans = Filename: 'C:\MATLAB6p5\toolbox\images\imdemos\rice.tif' FileModDate: '26-Oct-1996 06:11:58' FileSize: 65966 Format: 'tif' FormatVersion: [] Width: 256 Height: 256 BitDepth: 8 ColorType: 'grayscale' FormatSignature: [73 73 42 0] ByteOrder: 'little-endian' NewSubfileType: 0 BitsPerSample: 8 Compression: 'Uncompressed'PhotometricInterpretation: 'BlackIsZero' StripOffsets: [8x1 double] SamplesPerPixel: 1 RowsPerStrip: 32 StripByteCounts: [8x1 double] XResolution: 72 YResolution: 72 ResolutionUnit: 'Inch' Colormap: [] PlanarConfiguration: 'Chunky' TileWidth: [] TileLength: [] TileOffsets: [] TileByteCounts: [] Orientation: 1 FillOrder: 1GrayResponseUnit: 0.0100 MaxSamplevalue: 255 MinSamplevalue: 0 Thresholding: 1ImageDescription: [1x166 char]4MATLABimshowimshowimshow(X,map)Xmap[]
mapfigureI=imread(rice.tif);Imshow(I);J=imread(flowers.tif);figure,imshow(J);5MATLABMATLABimhistimhistimhist(I,n)imhist(X,map)imhist(I,n)In256imhist(X,map)
XmapI = imread('rice.tif');imshow(I)figure, imhist(I)6 f(x,y)[mM]g(x,y)[nN]
MATLABimadjustImadjust
J = imadjust(I,[low_in high_in],[low_out high_out])J = imadjust(I,[low_in high_in],[low_out high_out])IJ
[low_in high_in][low_out high_out]I = imread('pout.tif');J = imadjust(I,[0.3 0.7],[]);imshow(I), figure, imshow(J)copygirl1.bmpgirl2.bmpMATLABwork1 MATLABworkgirl.bmp.imreadimfinfo
MATLABimshow
map2 MATLABworkgirl2.bmp
imadjust[01]
Matlab
MTLAB MATLAB MATLAB MATLAB,,,,
.B(x,y)=f(A(x,y)).,,.
C(x,y)=A(x,y)+B(x,y)C(x,y)=A(x,y)-B(x,y)C(x,y)=A(x,y)*B(x,y)C(x,y)=A(x,y)/B(x,y) A(x,y)B(x,y)C(x,y)
MATLABA(x,y)B(x,y)
C(x,y)
MM
(x,y)
MATLAB
224
44
MATLABimresize3
ImresizeB = imresize(A,m,method) method'nearest''bilinear'
'bicubic''nearest'B = imresize(A,m,method)Amm1 1 MATLABimnoiseimnoiseJ = imnoise(I,type)J = imnoise(I,type,parameters)J = imnoise(I,type)IJtypeparameterseight.tifI=imread('eight.tif');J1=imnoise(I,'gaussian',0,0.02);J2=imnoise(I,'salt & pepper',0.02);J3=imnoise(I,'speckle',0.02);subplot(2,2,1),imshow(I),title('');subplot(2,2,2),imshow(J1),title('');subplot(2,2,3),imshow(J2),title('');subplot(2,2,4),imshow(J3),title(''); subplot
subplot(m,n,p) mnp MATLAB
MATLABFOR
MATLABFOR ENDfor endfor variable = expressionstatementsend%forfor i=1:10;y(i)=i;end;y %yy = 1 2 3 4 5 6 7 8 910 for
fory1MATLABy
fory=zeros(1,10);for i=1:10;y(i)=i;end;y unit8MATLAB
double
MATLAB im2double I2 = im2double(I1) I1unit8unit16I2double
.
00.02%[I,M]=imread('eight.tif');J=imnoise(I,'gaussian',0,0.02);subplot(1,2,1),imshow(I,M),title('');subplot(1,2,2),imshow(J,M),title('');K=zeros(242,308);for i=1:100J=imnoise(I,'gaussian',0,0.02);J1=im2double(J);K=K+J1;endK=K/100; %figure;imshow(K),title('');2ImresizeB = imresize(A,m,method)method'nearest''bilinear'
'bicubic''nearest'B = imresize(A,m,method)Amm1I=imread('ic.tif');J = imresize(I,1.25);imshow(I),title('')figure,imshow(J),title('') imrotate
Imrotate B = imrotate(A,angle,method imrotatemethod'nearest'
'bilinear''bicubic''nearest'
0I=imread('rice.tif');J=imrotate(I,30,'bilinear');imshow(I);title('')figure,imshow(J),title('') 1 girl.bmp,2 3 for100,4 1.50.845
5
12MATLABFFT3MATLAB1
fx,yu=0,1M-1v=0,1N-1(1) x=0,1M-1y=0,1N-13 Fp,qfm,nfm,n
w1w2Fw1w2fm,n10. fm,nfm,n2MATLAB1fft2fft2B = fft2(I)B = fft2(I)IfftIBload imdemos saturn2imshow(saturn2)B = fftshift(fft2(saturn2));imshow(log(abs(B)),[],'notruesize')2fftshiftMATLABfftshift
B = fftshift(I)IB = fftshift(I)I2ifft2ifft2B = ifft2(I)B = ifft2(A)IIB
fft2fft23
ButterworthELPF
10128*128H=zeros(128);H(32:96,32:96)=1; % IB(fftshift)
LOWPASS=B.*H; %LOWPASSC=ifft2(LOWPASS);Imshow(abs(C))1 girl.bmp
2
2
123MATLAB1 (m,n)02f(m,n)
2
1
2
58090200
110120110110
200110200
MATLABconv2C = conv2(A,B)C = conv2(A,B)ABCAmanaBmbnbC
(ma+mb+1)(na+nb+1)A=magic(5)A =17 241 81523 5 714 164 61320 22 1012 1921 31118 25 2 9>> B=[1 2 1 ;0 2 0;3 1 3]B = 1 2 1 0 2 0 3 1 3>> C=conv2(A,B)C =1758 663432 38152385 883567 761655 149 117 163 159 135677978 160 161 187 129512382 153 199 205 108753068 135 16891 84 93365 12685 104 1527MATLABfilter2filter2Y = filter2(h,X)Y = filter2(h,X)XhYXfilter2conv2MATLABfilter2180conv2
Fspecialh = fspecial(type)h = fspecial(type,parameters)typeparameterstype='average'n[3,3]type= 'gaussian'n[3,3]sigma
0.5type= 'laplacian'alpha[0,1]
0.2type= 'log'n[3,3]sigma
0.5type= 'prewitt'prewitttype= 'sobel'sobeltype= 'unsharp'alpha[0,1]
0.2MATLABmedfilt2Medfilt2B = medfilt2(A) 33AB = medfilt2(A,[m n]) mnA
Matlab
g(i,j),XEBBs
B0 , 0BsB180 MatlabimdilateImdilate(X,SE).XSE:bw = imread('text.tif');se = strel('line',11,90);bw2 = imdilate(bw,se);imshow(bw), title('Original')figure, imshow(bw2), title('Dilated')Matlabimerode:Imerode(X,SE).XSE:I = imread('cameraman.tif');se = strel('ball',5,5);I2 = imerode(I,se);imshow(I), title('Original')figure, imshow(I2), title('Eroded')1 2 3
123MATLAB
xy
;
f
RobertsSobel Sobel
loG
Zero Crossing
0
MATLABedgeBW = edge(I,'sobel')BW = edge(I,'sobel',direction)BW = edge(I,'roberts')BW = edge(I,'log')BW = edge(I,'sobel')SobelBW = edge(I,'sobel',direction)
direction=horizontaldirection=verticaldirection=bothBW = edge(I,'roberts')BW = edge(I,'log')Roberts
I=imread('eight.tif');imshow(I)BW1=edge(I,'roberts');figure ,imshow(BW1),title('Roberts')BW2=edge(I,'sobel');figure,imshow(BW2),title('Sobel ')BW3=edge(I,'log');figure,imshow(BW3),title('')1MATLABrice.tif2 Roberts,Sobel
1 2 Matlab 1 RLERun Length Encoding
aabbbcddddd2a3b1c5d2 Huffman
P(x2)=0.3
3.
Matlab
MATLAB
1 (General Purpose Commands)
1.1 (General information)
1.2 (Managing the workspace)
1.3 (Managing commands and functions)
1.4 (Managing the seach patli)
1.5 (Controlling the command window)
1.6 (Operating system commands)
2 (Operators and special characters)
2.1 (Arithmetic operators)
2.2 (Relational operators)
2.3 (Logical operators)
2.4 (Special characters)
3 (Programming language constructs)
3.1 (Control flow)
3.2 (Evaluation and execution)
3.3 (Scripts,function,and variables)
3.4 (Augument handling)
3.5 (Message display)
3.6 (Interactive input)
4 (Elementary matrices and matrix manipulation)
4.1 (Elementary matrices)
4.2 (Basic array information)
4.3 (Matrix manipulateion)
4.4 (Special variables and constants)
4.5 (Specialized matrices)
5 (Elementary math functions)
5.1 (Trigonometric)
5.2 (Exponential)
5.3 (Complex)
5.4 (Rounding and remainder)
6 (Specialized math functions)
7 (Matrix functionsnumerical linear algebra)
7.1 (Matrix analysis)
7.2 (Linear equations)
7.3 (Eigenvalues and singular values)
7.4 (Matrix functions)
7.5 (Factorization utility)
8 (Date analysis and Fourier transforms)
8.1 (Basic operations)
8.2 (Finite differentces)
8.3 (Correlation)
8.4 (Filtering and convoluteion)
8.5 (Fourier transforms)
9 (Audio support)
9.1 (Audio hardware drivers)
9.2 (Audio file import and export)
9.3 (Utilities)
10 (Interpolation and polynomials)
10.1 (Data Interpolation)
10.2 (Spline Interpolation)
10.3 (Polynomials)
11 ODE (Function functions and ODE solvers)
11.1 (Optimization and root finding)
11.2 (Optimization Option handling)
11.3 (Numerical intergration)
11.4 (Plotting)
11.5 (Inline function object)
11.6 (Differential equation solvers)
12 (Two dimensional graphs)
12.1 (Elementary XY graphs)
12.2 (Axis control)
12.3 (Graph annotation)
12.4 (Hardcopy and printing)
13 (Three dimensional graphs)
13.1 (Elementary 3D plots)
13.2 (Color control)
13.3 (Lighting)
13.4 (Color maps)
13.5 (Axis control)
13.6 (Viewpoint control)
13.7 (Graph annotation)
13.8 (Hardcopy and printing)
14 (Specialized graphs)
14.1 (Specialized 2D graphs)
14.2 (Contour and 21/2D graphs)
14.3 Specialized 3D graphs
14.4 (Volume and vector visualization)
14.5 (Image display and file I/O)
14.6 (Movies and animation)
14.7 (Color related function)
14.8 (Solid modeling)
15 (Handle Graphics)
15.1 (Figure window creation and control)
15.2 (Axis creation and control)
15.3 (Handle Graphics objects)
15.4 (Handle Graphics operations)
15.5 (Utilities)
16 (Graphical user interface tools)
17 (Character string)
17.1 (General)
17.2 (String tests)
17.3 (String operations)
18 /(File input/output)
19 (Time and dates)
20 (Data types and structures)
20.1 (Data types)
20.2 (Multidimensional array functions)
20.3 (Cell array functions)
20.4 (Structure functions)
20.5 (Function handle functions)
20.6 (Object oriented programming functions)
21 (E xamples and demonstrations)
22 (Symbolic Math Toolbox)
22.1 (Calculus)
22.2 (Linear Algebra)
22.3 (Simplification)
22.4 (Solution of Equation)
22.5 (Variable Precision Arithmetic)
22.6 (Integral Transforms)
22.7 (Conversions)
22.8 (Basic Operation)
22.9 (String handling utilities)
22.10 (Pedagogical and Graphical Applications)
22.11 Maple (Access to Maple)
23
1. Matlab Matlab fftfft2 fftn N DFT ifftifft2 ifftn DFT Afft(X,N,DIM) X N X Matlab X N DIM Afft2(X,MROWS,NCOLS) MROWS NCOLS X X Afftn(X,SIZE)SIZE X ifftifft2 ifftn% Iimread('lena.bmp');imshow(I)% J=fftshift(fft2(I));figure;imshow(log(abs(J)),[8,10])2. Matlab 2.1. dct2 DCT B=dct2(A) B=dct2(A,m,n) B=dct2(A,[m,n]) Bdct2(A) A DCT B A B Bdct2(A,m,n) B=dct2(A,[m,n]) A 0 B mn2.2. dict2 DCT B=idct2(A) B=idct2(A,m,n) B=idct2(A,[m,n]) Bidct2(A) A DCT B A B Bidct2(A,m,n) B=idct2(A,[m,n]) A 0 B mn2.3. dctmtx DCT Ddctmtx(n)Ddctmtx(n) nn DCT D double 3. Matlab 3.1 Matlab (1) dwt [cA,cD]=dwt(X,'wname') [cA,cD]=dwt(X,Lo_D,Hi_D)[cA,cD]=dwt(X,'wname') 'wname' X cAcD [cA,cD]=dwt(X,Lo_D,Hi_D) Lo_DHi_D (2) idwt X=idwt(cA,cD,'wname') X=idwt(cA,cD,Lo_R,Hi_R) X=idwt(cA,cD,'wname',L) X=idwt(cA,cD,Lo_R,Hi_R,L)X=idwt(cA,cD,'wname') cA cD X 'wname' X=idwt(cA,cD,Lo_R,Hi_R) Lo_R Hi_R X X=idwt(cA,cD,'wname',L) X=idwt(cA,cD,Lo_R,Hi_R,L) X L 3.2 Matlab ------------------------------------------------- --------------------------------------------------- dwt2 wavedec2 idwt2 waverec2 wrcoef2 upcoef2 detcoef2 appcoef2 upwlev2 dwtpet2 idwtper2 -------------------------------------------------------------(1) wcodemat Y=wcodemat(X,NB,OPT,ABSOL) Y=wcodemat(X,NB,OPT) Y=wcodemat(X,NB) Y=wcodemat(X)Y=wcodemat(X,NB,OPT,ABSOL) X Y NB 0NB NB16 OPT 'mat' OPT'row' OPT'col' OPT'mat' ABSOL '1' ABSOL0 ABSOL1 ABS(X)(2) dwt2 [cA,cH,cV,cD]=dwt2(X,'wname') [cA,cH,cV,cD]=dwt2(X,Lo_D,Hi_D)[cA,cH,cV,cD]=dwt2(X,'wname') 'wname' X cAcH,cV,cD [cA,cH,cV,cD]=dwt2(X,Lo_D,Hi_D) Lo_D Hi_D X (3) wavedec2 [C,S]=wavedec2(X,N,'wname') [C,S]=wavedec2(X,N,Lo_D,Hi_D)[C,S]=wavedec2(X,N,'wname') 'wname' X N [C,S]=wavedec2(X,N,Lo_D,Hi_D) Lo_D Hi_D X (4) idwt2 X=idwt2(cA,cH,cV,cD,'wname') X=idwt2(cA,cH,cV,cD,Lo_R,Hi_R) X=idwt2(cA,cH,cV,cD,'wname',S) X=idwt2(cA,cH,cV,cD,Lo_R,Hi_R,S)X=idwt2(cA,cH,cV,cD,'wname') cA cHcHcVcD X X=idwt2(cA,cH,cV,cD,Lo_R,Hi_R) Lo_R Hi_R X X=idwt2(cA,cH,cV,cD,'wname',S) X=idwt2(cA,cH,cV,cD,Lo_R,Hi_R,S) S (5) waverec2 X=waverec2(C,S,'wname') X=waverec2(C,S,Lo_R,Hi_R)X=waverec2(C,S,'wname') CS X 'wname' X=waverec2(C,S,Lo_R,Hi_R) Lo_R Hi_R
1.
MATLAB(double)64
MATLAB(uint8)
1
MATLABuint8
double
uint8double
---------------------------------------------
MATLAB
---------------------------------------------
B=double(A)+1
B=double(A)/255
B=double(A)
---------------------------------------------
doubleuint8
---------------------------------------------
MATLAB
---------------------------------------------
B=uint8(round(A-1))
B=uint8(round(A*255))
B=logical(uint8(round(A)))
---------------------------------------------
2.
2.1
RGB(100,50)
(100,50,1:3)
[0,1]
[0,255]
2.2
3
3
MATLAB[0,1]01
RGB
--------------------------------------------
R G B R G B
--------------------------------------------
0 0 1 1 0 1
1 1 1 0 1 1
1 0 0 0.67 0 1
0 1 0 1 0.5 0
0 0 1 0.5 0 0
1 1 0 0.5 0.5 0.5
--------------------------------------------
-------------------------------------------------
-------------------------------------------------
Hsv
Hot
Cool
Pink
Gray
Bone
Jet Hsv
Copper
Prim
Flag
--------------------------------------------------
643
doubleuint8
double1122
uint8012
2.3
double[01]uint8[0,255]
2.4
uint8double
MATLABuint8
2.5
MATLAB
44
cat() Acat(4,A1,A2,A3,A4,A5)
3. MATLAB
---------------------------------------------------------------------------
---------------------------------------------------------------------------
dither
gray2ind
grayslice
im2bw
ind2gray
ind2rgb
mat2gray
rgb2gray
rgb2ind
----------------------------------------------------------------------------
4.
4.1
imread()
A=imread(filename,fmt)
[X,map]=imread(filename,fmt)
[...]=imread(filename)
[...]=imread(filename,idx) TIF
[...]=imread(filename,ref) HDF
8bitMatlab
uint8Matlab16bitPNGTIFMatlab
uint16
uint8uint16imread
4.2
imwrite
imwrite(A,filename,fmt)
imwrite(X,map,filename,fmt)
imwrite(...,filename)
imwrite(...,parameter,value)
imwriteMatlabuint8
4.3 imfinfo()
5.
5.1
image(X)
colormap(map)
imshow(X,map)
5.2
Matlab 7.0 imshow imagesc
imagescale
(1) imshow
imshow(I) imshow(I,32)
Matlab
imshow(I,[low,high])
low high
(2) imagesc
imagesc
imagesc(1,[0,1]);
colormap(gray);
imagesc 0
1
imagesc
5.3 RGB
(1) image(RGB)
RGBdouble uint8 uint16 Matlab
image
RGB8 = uint8(round(RGB64255)); double uint8
RGB64 = double(RGB8)/255; uint8 double
RGB16 = uint16(round(RGB6465535)); double uint16
RGB64 = double(RGB16)/65535; uint16 double
(2) imshow(RGB) mn3
5.4
(1) imshow(BW)
Matlab 7.0 0 1 0
1
NOT(~) 0 1
imshow(~BW)
(2) uint8
0 1
imshow(BW,[1 0 0;0 0 1])
5.5
imshow filename
filename
imshow
Matlab 7.0 getimage
rgb getimage;
[1] [2] [3]
2007
matlab7.0(IPT)
Image Display ()(9)
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
image tool
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 ()10
DICOMDigital Image Communication and MedicianmatlabDICOM
dicomanon
Anonymize a DICOM file
DICOM
dicomdict
Specify which DICOM data dictionary to use
DICOM
dicominfo
Read metadata from a DICOM message
DICOM
dicomread
Read a DICOM image
DICOM
dicomuid
Generate DICOM unique identifier
DICOM
dicomwrite
Write a DICOM image
DICOM
dicom-dict.txt
Text file containing DICOM data dictionary
DICOM
imfinfo
Return information about image file (MATLAB function)
imread
Read image file (MATLAB function)
imwrite
Write image file (MATLAB function)
Matlab MATLAB
Matlab
1MATLAB2MATLAB3MATLAB MATLAB
MATLABMATLAB
(toolbox)MATLAB
Toolbox
MATLABImage Processing Toolbox1MATLAB MATLABMatrix Laboratory
MATLAB
MATLAB
MN
MATLABMATLABMATLABRGBBMPGIF
HDFJPEGPCXPNGTIFFXWDCURICOMATLAB
Image Processing Toolbox
2MATLAB MATLAB
CC
x=4:6%461x = 4 5 6xA>> A=[x-3;x;x+3] %AA = 1 2 3 4 5 6 7 8 9AC>> C=A(1:2,2:3)C = 2 3 5 6A >> A(2,2)=0A = 1 2 3 4 0 6 7 8 9A1A(:,1)=1A = 1 2 3 1 0 6 1 8 9A=eye(2) %A = 1 0 0 1>> B=[1,2;3,4] %B = 1 2 3 4>> A+B%ABans = 2 2 3 5>> A.*B %ABans = 1 0 0 4>> A*B %ABABans = 1 2 3 4EimpMATLAB
File----Set Path----Tool---Add Path3MATLABA imread imread [XMAP]=imread(filename,fmt)XMAPfmtfilename
[XMAP]=imreadflowers.tif,tif;B imwriteimwriteimwrite(X,map,filename,fmt)fmtXmapfilenameC imfinfoimfinfoimfinfo(filename,fmt)imfinfoinfo
imfinfo('rice.tif')ans = Filename: 'C:\MATLAB6p5\toolbox\images\imdemos\rice.tif' FileModDate: '26-Oct-1996 06:11:58' FileSize: 65966 Format: 'tif' FormatVersion: [] Width: 256 Height: 256 BitDepth: 8 ColorType: 'grayscale' FormatSignature: [73 73 42 0] ByteOrder: 'little-endian' NewSubfileType: 0 BitsPerSample: 8 Compression: 'Uncompressed'PhotometricInterpretation: 'BlackIsZero' StripOffsets: [8x1 double] SamplesPerPixel: 1 RowsPerStrip: 32 StripByteCounts: [8x1 double] XResolution: 72 YResolution: 72 ResolutionUnit: 'Inch' Colormap: [] PlanarConfiguration: 'Chunky' TileWidth: [] TileLength: [] TileOffsets: [] TileByteCounts: [] Orientation: 1 FillOrder: 1GrayResponseUnit: 0.0100 MaxSamplevalue: 255 MinSamplevalue: 0 Thresholding: 1ImageDescription: [1x166 char]4MATLABimshowimshowimshow(X,map)Xmap[]
mapfigureI=imread(rice.tif);Imshow(I);J=imread(flowers.tif);figure,imshow(J);5MATLABMATLABimhistimhistimhist(I,n)imhist(X,map)imhist(I,n)In256imhist(X,map)
XmapI = imread('rice.tif');imshow(I)figure, imhist(I)6 f(x,y)[mM]g(x,y)[nN]
MATLABimadjustImadjust
J = imadjust(I,[low_in high_in],[low_out high_out])J = imadjust(I,[low_in high_in],[low_out high_out])IJ
[low_in high_in][low_out high_out]I = imread('pout.tif');J = imadjust(I,[0.3 0.7],[]);imshow(I), figure, imshow(J)copygirl1.bmpgirl2.bmpMATLABwork1 MATLABworkgirl.bmp.imreadimfinfo
MATLABimshow
map2 MATLABworkgirl2.bmp
imadjust[01]
Matlab
MTLAB MATLAB MATLAB MATLAB,,,,
.B(x,y)=f(A(x,y)).,,.
C(x,y)=A(x,y)+B(x,y)C(x,y)=A(x,y)-B(x,y)C(x,y)=A(x,y)*B(x,y)C(x,y)=A(x,y)/B(x,y) A(x,y)B(x,y)C(x,y)
MATLABA(x,y)B(x,y)
C(x,y)
MM
(x,y)
MATLAB
224
44
MATLABimresize3
ImresizeB = imresize(A,m,method) method'nearest''bilinear'
'bicubic''nearest'B = imresize(A,m,method)Amm1 1 MATLABimnoiseimnoiseJ = imnoise(I,type)J = imnoise(I,type,parameters)J = imnoise(I,type)IJtypeparameterseight.tifI=imread('eight.tif');J1=imnoise(I,'gaussian',0,0.02);J2=imnoise(I,'salt & pepper',0.02);J3=imnoise(I,'speckle',0.02);subplot(2,2,1),imshow(I),title('');subplot(2,2,2),imshow(J1),title('');subplot(2,2,3),imshow(J2),title('');subplot(2,2,4),imshow(J3),title(''); subplot
subplot(m,n,p) mnp MATLAB
MATLABFOR
MATLABFOR ENDfor endfor variable = expressionstatementsend%forfor i=1:10;y(i)=i;end;y %yy = 1 2 3 4 5 6 7 8 910 for
fory1MATLABy
fory=zeros(1,10);for i=1:10;y(i)=i;end;y unit8MATLAB
double
MATLAB im2double I2 = im2double(I1) I1unit8unit16I2double
.
00.02%[I,M]=imread('eight.tif');J=imnoise(I,'gaussian',0,0.02);subplot(1,2,1),imshow(I,M),title('');subplot(1,2,2),imshow(J,M),title('');K=zeros(242,308);for i=1:100J=imnoise(I,'gaussian',0,0.02);J1=im2double(J);K=K+J1;endK=K/100; %figure;imshow(K),title('');2ImresizeB = imresize(A,m,method)method'nearest''bilinear'
'bicubic''nearest'B = imresize(A,m,method)Amm1I=imread('ic.tif');J = imresize(I,1.25);imshow(I),title('')figure,imshow(J),title('') imrotate
Imrotate B = imrotate(A,angle,method imrotatemethod'nearest'
'bilinear''bicubic''nearest'
0I=imread('rice.tif');J=imrotate(I,30,'bilinear');imshow(I);title('')figure,imshow(J),title('') 1 girl.bmp,2 3 for100,4 1.50.845
5
12MATLABFFT3MATLAB1
fx,yu=0,1M-1v=0,1N-1(1) x=0,1M-1y=0,1N-13 Fp,qfm,nfm,n
w1w2Fw1w2fm,n10. fm,nfm,n2MATLAB1fft2fft2B = fft2(I)B = fft2(I)IfftIBload imdemos saturn2imshow(saturn2)B = fftshift(fft2(saturn2));imshow(log(abs(B)),[],'notruesize')2fftshiftMATLABfftshift
B = fftshift(I)IB = fftshift(I)I2ifft2ifft2B = ifft2(I)B = ifft2(A)IIB
fft2fft23
ButterworthELPF
10128*128H=zeros(128);H(32:96,32:96)=1; % IB(fftshift)
LOWPASS=B.*H; %LOWPASSC=ifft2(LOWPASS);Imshow(abs(C))1 girl.bmp
2
2
123MATLAB1 (m,n)02f(m,n)
2
1
2
58090200
110120110110
200110200
MATLABconv2C = conv2(A,B)C = conv2(A,B)ABCAmanaBmbnbC
(ma+mb+1)(na+nb+1)A=magic(5)A =17 241 81523 5 714 164 61320 22 1012 1921 31118 25 2 9>> B=[1 2 1 ;0 2 0;3 1 3]B = 1 2 1 0 2 0 3 1 3>> C=conv2(A,B)C =1758 663432 38152385 883567 761655 149 117 163 159 135677978 160 161 187 129512382 153 199 205 108753068 135 16891 84 93365 12685 104 1527MATLABfilter2filter2Y = filter2(h,X)Y = filter2(h,X)XhYXfilter2conv2MATLABfilter2180conv2
Fspecialh = fspecial(type)h = fspecial(type,parameters)typeparameterstype='average'n[3,3]type= 'gaussian'n[3,3]sigma
0.5type= 'laplacian'alpha[0,1]
0.2type= 'log'n[3,3]sigma
0.5type= 'prewitt'prewitttype= 'sobel'sobeltype= 'unsharp'alpha[0,1]
0.2MATLABmedfilt2Medfilt2B = medfilt2(A) 33AB = medfilt2(A,[m n]) mnA
Matlab
g(i,j),XEBBs
B0 , 0BsB180 MatlabimdilateImdilate(X,SE).XSE:bw = imread('text.tif');se = strel('line',11,90);bw2 = imdilate(bw,se);imshow(bw), title('Original')figure, imshow(bw2), title('Dilated')Matlabimerode:Imerode(X,SE).XSE:I = imread('cameraman.tif');se = strel('ball',5,5);I2 = imerode(I,se);imshow(I), title('Original')figure, imshow(I2), title('Eroded')1 2 3
123MATLAB
xy
;
f
RobertsSobel Sobel
loG
Zero Crossing
0
MATLABedgeBW = edge(I,'sobel')BW = edge(I,'sobel',direction)BW = edge(I,'roberts')BW = edge(I,'log')BW = edge(I,'sobel')SobelBW = edge(I,'sobel',direction)
direction=horizontaldirection=verticaldirection=bothBW = edge(I,'roberts')BW = edge(I,'log')Roberts
I=imread('eight.tif');imshow(I)BW1=edge(I,'roberts');figure ,imshow(BW1),title('Roberts')BW2=edge(I,'sobel');figure,imshow(BW2),title('Sobel ')BW3=edge(I,'log');figure,imshow(BW3),title('')1MATLABrice.tif2 Roberts,Sobel
1 2 Matlab 1 RLERun Length Encoding
aabbbcddddd2a3b1c5d2 Huffman
P(x2)=0.3
3.
Matlab
.1
-1
betapdf
binopdf
chi2pdf
exppdf
fpdf
f
gampdf
geopdf
hygepdf
normpdf
lognpdf
nbinpdf
ncfpdf
f
nctpdf
t
ncx2pdf
poisspdf
raylpdf
tpdf
t
unidpdf
unifpdf
weibpdf
-2
betacdf
binocdf
chi2cdf
expcdf
fcdf
f
gamcdf
geocdf
hygecdf
logncdf
nbincdf
ncfcdf
f
nctcdf
t
ncx2cdf
normcdf
poisscdf
raylcdf
tcdf
t
unidcdf
unifcdf
weibcdf
-3
betainv
binoinv
chi2inv
expinv
finv
f
gaminv
geoinv
hygeinv
logninv
nbininv
ncfinv
f
nctinv
t
ncx2inv
icdf
norminv
poissinv
raylinv
tinv
t
unidinv
unifinv
weibinv
-4
betarnd
binornd
chi2rnd
exprnd
frnd
f
gamrnd
geornd
hygernd
lognrnd
nbinrnd
ncfrnd
f
nctrnd
t
ncx2rnd
normrnd
poissrnd
raylrnd
trnd
t
unidrnd
unifrnd
weibrnd
-5
betastat
binostat
chi2stat
expstat
fstat
f
gamstat
geostat
hygestat
lognstat
nbinstat
ncfstat
f
nctstat
t
ncx2stat
normstat
poisstat
raylstat
tstat
t
unidstat
unifstat
weibstat
-6
betafit
betalike
binofit
expfit
gamfit
gamlike
mle
normlike
normfit
poissfit
unifit
weibfit
weiblike
-7
bootstrap
corrcoef
cov
crosstab
geomean
grpstats
harmmean
iqr
kurtosis
mad
mean
median
moment
nanmax
Nanmean
nanmedian
nanmin
nanstd
nansum
prctile
range
skewness
std
tabulate
trimmean
var
-8
boxplot
cdfplot
errorbar
fsurfht
gline
gname
gplotmatrix
gscatter
lsline
normplot
pareto
qqplot
Q-Q
rcoplot
refcurve
refline
surfht
weibplot
-9
capable
capaplot
ewmaplot
histfit
normspec
schart
S
xbarplot
x
-10
cluster
linkage
clusterdata
cophenet
Cophenet
dendrogram
inconsistent
linkage
pdist
squareform
zscore
Z
-11
anova1
anova2
anovan
aoctool
dummyvar
friedman
Friedman
glmfit
kruskalwallis
Kruskalwallis
leverage
lscov
manova1
manovacluster
multcompare
polyfit
polyval
polyconf
regress
regstats
Ridge
rstool
robustfit
stepwise
x2fx
-12
nlinfit
nlintool
nlparci
nlpredci
nnls
-13
cordexch
D-
daugment
D-
dcovary
D-
ff2n
fracfact
fullfact
hadamard
Hadamard
rowexch
D-
-14
barttest
Barttest
pcacov
pcares
princomp
-15
classify
mahal
manova1
manovacluster
-16
ranksum
signrank
signtest
ttest
t
ttest2
t
ztest
z
-17
jbtest
Jarque-Bera
kstest
Kolmogorov-Smirnov
kstest2
Kolmogorov-Smirnov
lillietest
Lilliefors
-18
friedman
Friedman
kruskalwallis
Kruskalwallis
ranksum
signrank
signtest
-19
caseread
casewrite
tblread
tblwrite
tdfread
-20
aoctool
disttool
GUI
glmdemo
randtool
polytool
rsmdemo
robustdemo
.2
-21
fgoalattain
fminbnd
fmincon
fminimax
fminsearch, fminunc
fseminf
linprog
quadprog
-22
\
fsolve
fzero
-23
\
lsqlin
lsqcurvefit
lsqnonlin
lsqnonneg
-24
optimset
optimget
-25
circustent
molecule
optdeblur
-26
bandemo
dfildemo
goaldemo
optdemo
tutdemo
.3
-27
csapi
csape
csaps
cscvn
getcurve
-28
pplst
M
ppmak
ppual
-29 B
splst
BM
spmak
B
spcrv
B
spapi
B
spap2
B
spaps
B
spcol
B
-30
rpmak
rsmak
-31
fnval
fmbrk
fncmb
fn2fm
fnder
()
fndir
fnint
fnjmp
fnplt
fnrfn
fntlr
tarylortaylor
-32
augknt
aveknt
brk2knt
knt2brk
knt2mlt
sorted
pointsmeshpoints
aptknt
-33
newknt
optknt
chbpnt
-34
slvblk
bkbrk
-35 GUI
bspligui
B
splinetool
.4
-36
adaptmesh
PDE
assema
assemb
assempde
PDE
hyperbolic
PDE
parabolic
PDE
pdeeig
PDE
pdenonlin
PDE
poisolv
-37
pdecirc
pdeellip
pdemdlcv
PDE1.0MPDE1.0.2
pdepoly
pderect
pdetool
PDEGUI
-38
csgchk
csgdel
decsg
initmesh
jigglemesh
pdearcl
poimesh
refinemesh
wbound
wgeom
-39
pdecont
pdegplot
PDE
pdemesh
PDE
pdeplot
PDE
pdesurf
-40
Dst idst
sin
pdeadgsc
pdeadworst
pdecgrad
PDE
pdeent
pdegrad
PDE
pdeintrp
pdejmps
pdeprtni
pdesde
pdesdp
pdesdt
pdesmech
pdetrg
pdetriq
Poiasma
poicalc
poiindex
sptarn
tri2grid
PDE
-41
pdebound
M
pdegeom
M
-42
pdedemo1
pdedemo2
pdedemo3
pdedemo4
PDE
pdedemo5
pdedemo6
PDE
pdedemo7
pdedemo8
A a
abs ASCII acos acosh acot acoth acsc acsch align all angle ans any area argnames M asec asech asin asinh assignin atan atan2 atanh autumn axes axis
B b
bar bar3 bar3h barh base2dec X bin2dec blanks bone box break while for brighten
C c
capture 3 cart2pol cart2sph cat caxis cd cdedit cdf2rdf ceil cell cell2struct celldisp cellplot char chi2cdf chi2inv chi2pdf chi2rnd chol Cholesky clabel cla class clc clear clf clock colorcube colordef colormap colspace close colperm comet comet3 compass compose cond condeig condest -1 conj contour contourf contour3 contourslice conv cool copper cos cosh cot coth cplxpair csc csch cumsum cumtrapz cylinder
D d
dblquad deal deblank dec2base X dec2bin dec2hex deconv delaunay Delaunay del2 Laplacian demo Matlab det diag diary Matlab diff digits dir disp display dlinmod dmperm Dulmage-Mendelsohn dos DOS double drawnow Matlab dsolve
E e
echo M edit M eig eigs end FOR eps error errortrap erf erfc erfcx erfinv errorbar etreeplot eval evalin exist exit Matlab exp expand expint expm expm1 Pade expm2 Taylor expm3 eye ezcontour ezcontourf ezgraph3 ezmesh ezmeshc ezplot ezplot3 ezpolar ezsurf ezsurfc
F f
factor feather feedback feval fft Fourier fft2 Fourier fftn Fourier fftshift fieldnames figure fill3 find findobj findstr findsym finverse fix flag fliplr flipud flipdim floor flops flow Matlab fmin fminbnd fmins fminunc fminsearch fnder fnint fnval fnplt fopen for for format fourier Fourier fplot fprintf fread fsolve full funm funtool fzero
G g
gamma gammainc gammaln gca gcbo "" gcf gco geomean get getfield getframe ginput global gplot gradient gray grid griddata gtext guide
H h
harmmean help helpwin helpdesk hex2dec hex2num hidden hilb Hilbert hist histc histfit hold horner hot hsv
I i
if-else-elseif ifft Fourier ifft2 Fourier ifftn Fourier ifftshift ifourier Fourier i, j "" ilaplace Laplace imag image imagesc imfinfo imread imwrite imwrite ind2sub inf info MathWorks inline inmem input inputname int int2str interp1 interp2 interp3 interpn N interpft FFT intro Matlab inv invhilb Hilbert ipermute isa ischar isequal isempty isfinite isfield isglobal ishandle ishold isieee IEEE isinf isletter islogical ismember isnan isnumeric isobject isprime isreal isspace issparse isstruct isstudent Matlab iztrans Z
J j , K k
jacobian Jacobian jet jordan Jordan keyboard kron Kronecker
L l
laplace Laplace lasterr lastwarn leastsq legend lighting line lines plot linmod linmod2 linspace ln load MAT log log10 log2 2 loglog logm logspace lookfor M lower lsqnonlin lu LU
M m
mad magic maple &nb, sp; Maple mat2str material max mbuild EXE mcc MEXEXE mean median menuedit mesh meshz meshgrid "" methods mex MEX mfunlis mfunMAPLE mhelp Maple min mkdir mkpp mod more movie moviein mtaylor Taylor
N n
ndims NaN nargchk nargin nargout ndgrid newplot nextpow2 2 nnz nonzeros norm normcdf normest 2 norminv normpdf normrnd notebook MatlabWord null num2str numden nzmax
O o
ode1 Stiff ode15s Stiff ode23t Stiff ode23tb Stiff ode45 Stiff odefile ODE odeget ODE odephas2 ODE odephas3 ODE odeplot ODE odeprint Matlab odeset ODE ones 1 optimset orient orth
P p
pack Matlab pagedlg patch path Matlab pathtool pause pcode P pcolor peaks Matlab permute pi pie pie3 pink pinv plot plot3 plotmatrix plotyy poissinv poissrnd pol2cart polar poly poly2str poly2sym polyder polyfit polyval polyvalm pow2 2 ppval pretty print SIMULINK printsys prism procread MAPLE profile propedit pwd
Q q
quad quad8 (QUADL) quit Matlab quiver quiver3
R r
rand randn randperm range rank rats rcond real reallog realpow realsqrt realmax realmin rectangle "" rem repmat reshape residue return ribbon rmfield roots rose rot90 90 rotate rotate3d round rref rsf2csf rsums Riemann
S s
save scatter scatter3 sec sech semilogx X semilogy Y series set setfield setstr ASCII sign signum sim SIMULINK simget SIMULINK simple simplify simset SIMULINK simulink SIMULINK sin sinh size slice solve spalloc sparse spconvert spdiags spfun sph2cart sphere spinmap spline spones 1 sprandsym sprank spring sprintf spy sqrt sqrtm squeeze 1"" sscanf stairs std stem step str2double str2mat str2num strcat strcmp strjust strmatch strncmp strrep strtok struct struct2cell strvcat sub2ind subexpr subplot subs subspace sum summer superiorto surf surface surfc surfl surfnorm svd svds switch-case-otherwise sym2poly symmmd symrcm Cuthill-McKee syms
T t
tan tanh taylortool Taylor text tf tic title toc trapz treelayout treeplot tril trim trimesh trisurf triu try-catch Try-catch type M
U u
uicontextmenu uicontrol uimenu unmkpp unwrap upper
V v
var varargin varargout vectorize ver view voronoi Voronoi vpa
W w
warning what whatsnew Matlab Readme which while While white whitebg who whos winter workspace
X x , Y y , Z z
xlabel X xor yesinput ylabel Y zeros zlabel Z zoom ztrans Z
MATLAB
help
doc
what
MMATMEX
type
M
lookfor
help
which
Demo
Path
MATLAB
Who
Whos
Load
Save
Clear
Pack
Size
Length
disp
cd
Dir
Delete
Getenv
!
DOS
Unix
UNIX
Diary
MATLAB
Cedit
Clc
Home
Format
Echo
more
MATLAB
Quit
MATLAB
Startup
MATLABM
Matlabrc
M
Info
MATLABMathworks
Subscribe
MATLAB
hostid
MATLAB
Whatsnew
Ver
+
*
.*
^
.^
\
/
./
Kron
Kronecker
:
( )
[ ]
.
..
,
;
%
!
=
= =
< >
&
|
~
xor
Exist
Any
All
Find
Sin
Sinh
Asin
Asinh
Cos
Cosh
Acos
Acosh
Tan
Tanh
Atan
Atan2
Atanh
Sec
Sech
Asech
Csc
Csch
Acsc
Acsch
Cot
Coth
Acot
Acoth
Exp
Log
Log10
Sqrt
Abs
Argle
Conj
Image
Real
Fix
Floor
Ceil
Round
Rem
Sign
Zeros
Ones
1
Eye
Rand
Randn
Logspace
Meshgrid
XY
:
Ans
Eps
Realmax
Realmin
Pi
I,j
Inf
Nan
Flops
Nargin
Nargout
Computer
Isieee
IEEE
Why
Version
MATLAB
Clock
Date
Etime
Tic
Toc
Cputime
CPU
Diag
Fliplr
Flipud
Reshape
Rot90
90
Tril
Triu
:
Compan
Hadamard
Hadamard
Hankel
Hankel
Hilb
Hilbert
Invhilb
Hilbert
Kron
Kronecker
Magic
Toeplitz
Toeplitz
Vander
Vandermonde
Cond
Norm
Rcond Linpack
Rank
Det
Trace
Null
Orth
\/
Chol
Cholesky
Lu
Inv
Qr
QR
Pinv
Eig
Poly
Hess
Hessberg
Qz
Cdf2rdf
Schur
Schur
Balance
Svde
Expm
Expm1
expmM
Expm2
Expm3
Logm
Sqrtm
Funm
Ode23
Ode23p
Ode45
Quad
Quad8
Fmin
Fmins
Fzero
Fplot
Roots
Poly
Polyvalm
Residue
Polyfit
Polyder
Conv
Deconv
Figure
Gcf
Clf
Close
Subplot
Axes
Gca
Cla
Axis
Caxis
Hold
Figure
Axes
Line
Text
Patch
Surface
Image
Uicontrol
Uimen
Set
Get
Reset
Delete
Newplot
nextplotM
Gco
Drawnow
Findobj
Printopt
Orient
Capture
XY
Plot
Loglog
Semilogx
X
Semilogy
Y
Fill
XY
Polar
Bar
Stem
Stairs
Errorbar
Hist
Rose
Compass
Feather
Fplot
Comet
Title
Xlabel
X
Ylabel
Y
Text
Gtext
Grid
MATLAB
Function
Eval
MATLAB
Feval
Global
If
Else
if
Elseif
if
End
For,whileif
For
While
Break
Return
Error
Input
Keyboard
Menu
Pause
Uimenu
Uicontrol
Strings
MATLAB
Abs
Setstr
Isstr
Blanks
Deblank
Str2mat
Eval
MATLAB
Strcmp
Findstr
Upper
Lower
Isletter
Isspace
Num2str
Int2str
Str2num
Sprintf
Sscanf
Hex2num
IEEE
Hex2dec
Dec2hex
Append
Augstate
Blkbuild
Cloop
Connect
Conv
Destim
Dreg
Drmodel
Estim
Feedback
Ord2
ABCD
Pade
Pade
Parallel
Reg
Rmodel
Series
Ssdelete
ssselect
C2d
C2dm
C2dt
D2c
D2cm
Poly
Residue
Ss2tf
Ss2zp
Tf2ss
Tf2zp
Zp2tf
Zp2ss
Balreal
Dbalreal
Dmodred
Minreal
Modred
Canon
Ctrbf
Obsvf
Ss2ss
Covar
Ctrb
Damp
Dcgain
Dcovar
Ddamp
Ddcgain
Dgram
Dsort
Eig
Esort
Gram
Obsv
Printsys
Roots
Tzero
Tzero2
Dimpulse
Dinitial
Dlsim
Dstep
Filter
Z
Impulse
Initial
Lsim
Ltitr
Step
Stepfun
Bode
Bode
Dbode
Bode
Dnichols
Nichols
Dnyquist
Nyquist
Dsigma
Fbode
Bode
Freqs
Freqz
Z
Ltifr
Margin
Nichols
Nichols
Ngrid
Nichols
Nyquist
Nyquist
Sigma
Pzmap
Rlocfind
Rlocus
Sgrid
Zgrid
Acker
Dlqe
Dlqew
Dlqr
Dlqry
Lqe
Lqed
Lqe2
Schur
Lqew
Lqr
Lqrd
Lqry
Lqr2
Schur
Place
Are
Riccati
Dlyap
Lyapunov
Lyap
Lyapunov
Lyap2
Lyapunov
Ctrldemo
Boildemo
LQG
Jetdemo
Diskdemo
Kalmdemo
Kalman
Abcdchk
ABCD
Chop
n
Dexresp
Dfrqint
Bode
Dfrqint2
Nyquist
Dmulresp
Distsl
Dric
Riccati
Dsigma2
DSIGMA
Dtimvec
Exresp
Freqint
Bode
Freqint2
Nyquist
Freqresp
Givens
Housh
Householder
Imargin
Lab2ser
Mulresp
Nargchk
M
Perpxy
Poly2str
Printmat
Ric
Riccati
Schord
Schwr
Sigma2
SIGMA
Tfchk
Timvec
Tzreduce
Vsort
MATLAB
1applylut
lookup
A = applylut(BW,lut)
lut = makelut('sum(x(:)) == 4',2);
BW1 = imread('text.tif');
BW2 = applylut(BW1,lut);
imshow(BW1)
figure, imshow(BW2)
makelut
2bestblk
siz = bestblk([m n],k)
[mb,nb] = bestblk([m n],k)
siz = bestblk([640 800],72)
siz =
64 50
blkproc
3blkproc
320 MATLAB
B = blkproc(A,[m n],fun)
B = blkproc(A,[m n],fun,P1,P2,...)
B = blkproc(A,[m n],[mborder nborder],fun,...)
B = blkproc(A,'indexed',...)
I = imread('alumgrns.tif');
I2 = blkproc(I,[8 8],'std2(x)*ones(size(x))');
imshow(I)
figure, imshow(I2,[]);
colfilt, nlfilter,inline
4brighten
brighten(beta)
newmap = brighten(beta)
newmap = brighten(map,beta)
brighten(fig,beta)
imadjust, rgbplot
5bwarea
total = bwarea(BW)
BW = imread('circles.tif');
imshow(BW);
MATLAB 321
bwarea(BW)
ans =
15799
bweuler, bwperim
6bweuler
eul = bweuler(BW,n)
BW = imread('circles.tif');
imshow(BW);
bweuler(BW)
ans =
2
bwmorph, bwperim
7bwfill
BW2 = bwfill(BW1,c,r,n)
BW2 = bwfill(BW1,n)
[BW2,idx] = bwfill(...)
BW2 = bwfill(x,y,BW1,xi,yi,n)
[x,y,BW2,idx,xi,yi] = bwfill(...)
BW2 = bwfill(BW1,'holes',n)
[BW2,idx] = bwfill(BW1,'holes',n)
322 MATLAB
BW1 =[1 0 0 0 0 0 0 0
1 1 1 1 1 0 0 0
1 0 0 0 1 0 1 0
1 0 0 0 1 1 1 0
1 1 1 1 0 1 1 1
1 0 0 1 1 0 1 0
1 0 0 0 1 0 1 0
1 0 0 0 1 1 1 0]
BW2 = bwfill(BW1,3,3,8)
BW2 =
1 0 0 0 0 0 0 0
1 1 1 1 1 0 0 0
1 1 1 1 1 0 1 0
1 1 1 1 1 1 1 0
1 1 1 1 0 1 1 1
1 0 0 1 1 0 1 0
1 0 0 0 1 0 1 0
1 0 0 0 1 1 1 0
I = imread('blood1.tif');
BW3 = ~im2bw(I);
BW4 = bwfill(BW3,'holes');
imshow(BW3)
figure, imshow(BW4)
bwselect, roifill
8bwlabel
MATLAB 323
L = bwlabel(BW,n)
[L,num] = bwlabel(BW,n)
BW = [1 1 1 0 0 0 0 0
1 1 1 0 1 1 0 0
1 1 1 0 1 1 0 0
1 1 1 0 0 0 1 0
1 1 1 0 0 0 1 0
1 1 1 0 0 0 1 0
1 1 1 0 0 1 1 0
1 1 1 0 0 0 0 0]
L = bwlabel(BW,4)
L =
1 1 1 0 0 0 0 0
1 1 1 0 2 2 0 0
1 1 1 0 2 2 0 0
1 1 1 0 0 0 3 0
1 1 1 0 0 0 3 0
1 1 1 0 0 0 3 0
1 1 1 0 0 3 3 0
1 1 1 0 0 0 0 0
[r,c] = find(L==2);
rc = [r c]
rc =
2 5
3 5
2 6
3 6
bweuler, bwselect
9bwmorph
BW2 = bwmorph(BW1,operation)
BW2 = bwmorph(BW1,operation,n)