% y" n I z) i% _3 y' Xl truesize:调整图像显示的尺寸。0 \& l6 `+ f; @- k6 Z
; |5 g+ E3 v! a! S C. t5 k% K
l warp:显示图像的纹理表面图。前面提到的图像显示手段都只能在二维平面上显示,MATLAB6.5的一个强大功能是能将平面图像显示在空间三维曲面上。这是由warp函数的纹理成图功能来实现的,该功能能通过双线性插值将平面图像投影到三维曲面上。 $ W& {! _. c& o. A + Q$ U. F6 b. b8 E, sl zoom:将图像或二维图形进行放大或缩小显示。zoom本身是是一个开关键,zoom on用于打开缩放模式,zoom off用于关闭该模式,zoom in用于放大局部图像,zoom out用于缩小图像。+ Y$ ?+ q" g0 I% P% ^% g
" ~2 i; |; e! y1 f( V至于多个图像的显示,则可分为两个方面:在不同的图形窗口显示不同的图像,可以用figure指令来实现;在同一个图形窗口显示多图,可以用subplot来实现。5 B4 q7 p: v A0 m
% A+ ^# C! [ r0 w( y1 g+ A第三章 图像运算" M" N6 E G' G% h a4 Y; s
7 X( A8 t, b$ ?# Z/ C& ]
3.1 图像的点运算* U1 I5 m! f( g& Z
6 E; c. H. p( z2 y! V" X- Z
点运算将输入图像映射为输出图像,输出图像每个像素点的灰度值仅由对应的输入像素点的值决定。它常用于改变图像的灰度范围及分布,是图像数字化及图像显示的重要工具。点运算因其作用性质,也被称为对比度增强、对比度拉伸或灰度变换。在真正进行图像处理之前,有时可以用点运算来克服图像数字化设备的局限性。 4 C' `0 A3 l+ g$ V/ t5 M( b; | 7 {+ T2 S3 a( V1 ^0 g1 p& k点运算实际上是灰度到灰度的映射过程。点运算不会改变图像内像素点之间的空间关系。设输入图像为A(x, y),输出图像为B(x, y),则点运算可表示为: 1 p+ j# i2 Y7 @! ? 3 Q1 L+ I2 l- Y8 y2 ^* v0 oB(x, y) = f [A(x, y)] (3-1)" T& \: |6 `- u/ b7 q
: }- _/ F' T/ w9 _" T: x
点运算可完全由灰度变换(gray-scale transformation)函数s=f (r)决定,后者描述了输入灰度级与输出灰度级之间的映射关系。图像的点运算分为线性点运算和非线性点运算两种。. O! r% S2 Z7 K- a
) M, Y. ~$ ?( B: E
3.1.1 线性点运算* r9 {9 g9 t8 }
6 _6 v6 R7 {1 c' u%该图片在安装matlab的目录中找,原图为灰度图象 9 m1 c( k+ X; M. A6 d% p N/ V ) t* W& f, D5 E/ k0 |5 j( l t: i dI=im2double(I);%图像存储类型转换! L' {0 m% }6 s7 s2 x
4 e5 n8 l# J4 r+ d# l& W. ?3 QT=dctmtx(8);%离散余弦变换矩阵 % T" c, P- p3 U# w% N4 `% P- w; k, C3 M. d/ o) R- j7 }
B=blkproc(I,[8 8],'P1*x*P2',T,T'); ' L a$ m; K5 r- \5 t+ O; y9 T0 F7 _
%对原图像进行DCT变换0 C- v4 O- E) B8 H6 Y
. u' V$ [" `/ [1 L1 a* ?1 G
mask=[1 1 1 1 0 0 0 04 s T2 l% `/ A
* }% Y. \8 G( n
1 1 1 0 0 0 0 07 b" U* ?' u% R: K" O
2 w3 n3 I: z. q( }6 |: }Solution Number: 26990 . Q3 `% O0 n% c, S/ t& W3 I/ y k7 a( v& ~4 S
Date Last Modified: 2001-01-30 2 q3 ~8 R; m# i3 ? ]) D3 e3 w) z. r' U# E7 u2 t9 yProduct: MATLAB 6.0 ==> Current Version1 L* {3 [ I, D7 u0 L/ o
D2 a* J# _5 k Q; [Platform: Windows : B Y3 Q# @' }* N* y0 x+ ^: \' F: S `
Problem Description! q* o+ G7 G5 r) y- A% y! W
4 F+ E5 O3 ]6 U: WWhy do I encounter problems when running MATLAB 6.0 (R12) on Hebrew$ M+ R$ n/ z. y+ d
" H' I7 l. E% Y7 k9 r
or2 |" x% [1 z0 Q7 y3 M% F! s* U8 l: e
$ o9 U3 A7 E T% c
Traditional Chinese (Taiwan) Windows? I try to start MATLAB but after! z4 A$ C2 i+ g8 l' \" ^. _6 f7 v
! o! u4 P5 b, A5 _& ?: Othe splash screen disappears, MATLAB exits.: P3 I. A, l9 L; t
! V3 u$ [& y2 ]6 ?& APLEASE NOTE: This solution only applies to MATLAB 6.0. If you have a+ G6 m& `4 H% s& S* l) C
8 S3 `; P b, o8 i
similar problem with MATLAB 5.0 or the Student Edition of MATLAB 5.0,! H2 `7 t5 n& `4 p' H0 N2 e* G& l
- G) G% c. b2 ~) S6 v7 }see solution 7213.8 a4 E# K; ?2 F# j) U
2 F( G; H/ F L j
Solution: , p' h( T4 F& c7 c" w- P" d ! I. G( F7 a3 y! Z" s- V( y- MThis problem is caused by a bug in one of the font properties files we ship ! H+ K' B5 \( f/ ]- w& f6 B; g# O , E6 m1 h4 ]% [& D+ nwith MATLAB. The font.properties file is used by Java to map the standard5 ^/ `4 n" z+ t4 m
1 ?' o; g; F' [* ]# ^
Java font names to system fonts for a particular language operating system.8 O; [0 @6 _: _+ |
6 e; ^3 W/ y; ]- m* C3 MHowever, we made a few assumptions that do not hold for the Hebrew or3 F! q7 p+ B# C& T. a, r9 q4 C
3 q- [( s$ O9 I( c8 u
Traditional Chinese Windows, causing this problem." n4 p5 f8 d( u6 \( D2 B3 ~6 j6 {
5 t F* @' v0 H. Z* j7 N& }6 xWe have created a fixed version of the mwt.jar file that you can use to 8 R& B2 _" s( V: X / ?1 l" \( { r- C+ S2 ecorrect this. To use the fix, first rename your mwt.jar file as mwt.old. ( [8 h/ E! r- E s8 ?* j ! m2 Q$ |& L2 A4 L$ @This file is found in the $MATLAB\java\jar directory, where $MATLAB is your' R/ d* k" g+ v( [! N
$ V3 s. ]$ h+ BMATLAB root directory. Then download the newer mwt.jar file from: $ d& L# y& Q- W# d0 ^6 H. K8 G/ n! v0 r) _! b( k/ N$ j# ], ~0 Z ftp://ftp.mathworks.com/pub/tech-support/solutions/s26990" i. F- K$ D7 o* ^5 C% m/ ~
/ {8 O0 L2 X9 _
and place it in your $MATLAB\java\jar directrory. Then restart MATLAB; + L3 J, [" U9 ^# m" t7 P+ z5 W9 n8 t( a. ?5 p3 ]
this should correct the problem you're seeing. 0 i9 D3 G2 M! [: N/ N 7 S7 C1 h c$ k0 s' t2)我有一组x,y,z值,非规则排列,如何在Matlab中绘图? R- ]* m6 x0 b: l; P $ T$ W8 }1 q% g' h* i:#FangQ(Qianqian.Fang@Dartmouth.Edu),2002/6/12, BigGreen/MathTools # 1 Z! n- y: v" o. @9 \2 X* H) B0 ~' _! X/ Y% H
参见第一节问题7) + O: S8 d( J. N- u- |2 ` 3 J/ ~4 T; P% N/ r3)如何在给定句柄的axis里绘图? & j3 G5 K. c3 F 4 ~1 W0 R. v4 t: N: i- C0 ?:#FangQ(Qianqian.Fang@Dartmouth.Edu),2002/6/12, SMTH/MathTools #4 o; s% m5 z2 o5 D, E; c3 p
: y7 R* N3 C7 g! ?& [
plot(data,'parent',haxis); 6 I- U! i7 ~3 y2 J; H, Q0 j; a+ c. Q2 m2 }4 T4 G
或者 # u, f$ |8 n, {5 @3 U# _* n m1 | g: c' C' E) b5 t
hbar=bar(data);# O; u, @9 i2 Q0 f
0 p- [$ ~* D5 n2 Z8 c' _% V9 |set(hbar,'parent',haxis); - B( M; c% A4 B 2 K4 |2 Q3 k& N; z5 l0 w7 {* C& k$ \" {4)由Matlab符号运算得到的公式怎么才能将数据代进去运算? ( [" C6 N9 Y( ?2 b1 e2 W 9 ]5 x! A* _; U. s M:#ramjet (德芙)2002/3/3, SMTH/MathTools #) M! w! a0 s7 t/ L0 |
+ u8 _3 H' B, @+ w& w. q5 p使用subs(),或先将值赋予一个符号变量,然后用eval() & u/ m7 o9 r; I2 f3 J5 H g$ k2 ]* L, z0 e! R2 \7 T
5)在Matlab中如何求最值点?如何求一维数组的极值?# k$ w* B' g& v6 }7 @4 {
% P( i; y8 ~6 l) y
:#FangQ(Qianqian.Fang@Dartmouth.Edu),2002/6/18, SMTH/MathTools# , Y3 z* V; o0 c( z9 w * g8 }& `; `2 k: ` c最值: & S* i0 I, i' d! v. A; C% l) G & O0 |; {) V; }) S- a9 A一维或多维数组最值用max(data() a1 @- \, i" c * l! d& b+ t% w7 b如果想返回最值所在的位置,用[Y,I]=max(data) 2 m! y1 f. M$ \" x1 r/ I4 S/ d. }# V1 Z
:#FangQ(Qianqian.Fang@Dartmouth.Edu), 2001/4/21,UESTC/Math# 3 [+ }, n o4 o- d9 x0 e1 U5 v+ H4 J1 C; H" B
极值: ; B3 v1 }7 [) w # F; V7 K [5 {/ idata是你的数据,. @7 x. F- [. [# s9 g1 u
/ ~! y$ S, B8 o* u
find(diff(sign(diff(data)))==-2)+1 6 s& Y, t2 Z! f' v$ {4 y 0 l. ]" e$ S" V- e1 @找到极大值的位置 # K' L. Q5 y+ s0 Z/ J8 _3 l* G% g% Z7 I& J' T( m3 t2 q; p: W+ W# O
find(diff(sign(diff(data)))==2)+16 E1 V0 o1 Z7 ]; `7 _- u( y
* D$ p4 V8 H5 @
找到极小值的位置3 R1 `4 g( ]6 v7 v* h4 X$ v4 T$ o
/ E! T- h3 C X( pdata(find(diff(sign(diff(data)))==-2)+1)和2 w' ~( w! w& V/ g' }6 P
/ @. C# z' {$ C1 x8 G
data(find(diff(sign(diff(data)))==2)+1)# S; h# e; W: k. P
: P" }+ X$ D, c3 C5 D6 C
返回的是极大值和极小值 9 K! S3 h% Z! m ! L2 _7 d. @! c( s7 I' C3 s" [% z6)Matlab中如何作线性拟合/线性回归/多元线性回归? * n& r' L3 { k, ~8 j# k . L/ a9 q' x7 B. K% t* Q7 i:#FangQ(Qianqian.Fang@Dartmouth.Edu),2002/6/21, BigGreen/MathTools # : l+ V, Q6 x- J: o" u4 N4 U+ I+ `+ q) @" o% c2 @9 v! c
即用y=a*x+b来拟合一组数据{{x1,y1},{x2,y2}…{xn,yn}}$ _. `& s* C, w
, W8 [& B+ f( ~$ _& L! d
matlab中使用polyfit; E- s* B' F: n4 B4 L# _
2 G* U( a. w$ m# |6 j
x=data(:,1); N* g7 A8 z9 p/ d8 }
4 f0 y( [/ W9 c
y=data(:,2);, g! T- T' T* v9 d4 V2 m; M
. y/ D+ U& z8 s/ K/ o$ m1 F: z7 }
p=polyfit(x,y,1); ; w# y/ y0 |: r) g* L: k$ B; a% D( R& C. p( K* i" v& q
p(1)为斜率a,p(2)为截距b 0 f8 r s6 u- e1 a1 v! C) c 9 ^* E* l7 N2 j多元线性回归即用y=a1*x1+a2*x2+..+am*xm来拟合数据点{x1i,x2i,…xmi,yi}1 ]( q- h5 v( W2 j2 A7 E
: v' i2 _9 @* U! z/ A( \|x1n,x2n,…xmn|1 b5 f M' ]* d) T) U
+ Z, k& c3 G- }4 b# G
Y={y1,y2,y3,…,yn}' 8 n: Q% v* n* u# H3 e- D* Y2 v+ q9 G T2 M9 ?7 d/ g4 _7 D9 Q
则系数{a1,a2,…,am}'=pinv(A)*Y. T" e# u4 f( @" v' H
$ ]5 k! C( y l& T
在matlab中使用 n9 u7 t+ Z8 i. z* d
; S" j: p i; o: W g
coeff=A\Y4 c. \/ N0 n+ @/ K" H% J7 l
4 k6 Y% k' p, m
则可以得到最小二乘意义上的拟合系数 , a' E0 Q' A g2 g 3 J3 {/ l$ H/ U7 O" M7)Matlab中如何作圆回归? ! v8 b# }# n1 n: D; V 3 I9 W* H W9 V:#Peter Boettcher (boettcher@ll.mit.edu),2002/5/16, comp.soft-sys.matlab# * C* {: W* F( u" |5 j( E9 }7 G$ Q" S P
Q5.5: How can I fit a circle to a set of XY data? " V' g3 u! X3 h9 T& Z2 Q& a* N# n' h2 `. |, o
=================================================7 ^; v! ] _4 l* w$ F; e
7 N1 O- B+ T$ W! ]$ \; b
An elegant chunk of code to perform least-squares circle fitting was" y1 v0 e7 B) o3 T# r8 @0 `- A+ @
" C( F+ U4 M. q2 ]
written by Bucher Izhak and has been floating around the newgroup for , Y2 m) [$ c3 p4 z, \6 z' e2 F' x- g3 v: ~7 p
some time. The first reference to it that I can find is in: 2 {# U$ h. `) j) U* W% e4 g+ |+ A+ S
function [xc,yc,R,a] = circfit(x,y)2 h$ d6 o3 C1 X, j
: S1 N- B' g/ o%CIRCFIT Fits a circle in x,y plane H k) D+ }% ?& {6 y0 A4 r" x* p3 O) b7 ]& P
% , t+ u+ F! D8 c) L: V# w ( t$ X6 _: A& N$ K3 H, b% [XC, YC, R, A] = CIRCFIT(X,Y) % c' Q; r" B$ l4 h+ Z" _+ h5 u# {7 v2 w# E/ d1 ]
% Result is center point (yc,xc) and radius R.A is an optional5 n9 W/ t" |0 O- @. p: \
Q2 |7 B. D/ J, s+ d# p参见, y5 H: s% p. d) ]2 j# n# W; n. D8 H
8 } j$ p6 R7 q3 W& _ http://engineering.dartmouth.edu ... oad/source/Implicit% O5 F: c% ^! k& V/ M( z
6 J' ]9 N& X, O. X) K! S
Plot3D.htm 0 j" y& T3 l& p! j) _+ {3 o- Y; M! V9 ^) \
19)Matlab中什么函数可以删除矩阵的某一行或列?) ^: E v) b L
7 v2 u. Q- p2 t2 f, _, f2 H
:#FangQ(Qianqian.Fang@Dartmouth.Edu),2002/6/21,BigGreen/MathTools # - U& N/ q2 s6 c9 b, }& J8 h) `# ^5 Y2 T9 }9 z. Q; h0 u
A(j,=[]; %删除A的第j行 e' L; m. |) r0 {* C* K
0 U( k" U# P* t* {& q' V9 \# u
A(:,i)=[]; %删除A的第i列! F* o7 Y4 D" c% b2 v0 l- u
4 B. F- w5 e5 L6 v u20)Matlab中能开的最大数组是由什么决定的?2 n1 }% k/ E9 @8 |7 o6 ]
1 g( X; ?% ~1 n6 z8 x! Z& _:# chenft (mike),2002/6/1, SMTH/MathTools #5 a% i0 Z3 ^0 u6 z2 b: I
+ D' c* X$ r* q9 o% _! M
I have had similar problems. Below is an explanation I received from Ian 2 f& s' }8 n- T9 F0 d; W9 b% A2 M h( @* m$ `$ b& h) O
Boyd& I4 t* b1 M" y) H# _4 B* p
6 a& x# U" _6 o9 h' _% mfrom Mathworks (just giving credit where credit is due) that explains 4 ~/ Y% U- A) g6 R, j: w& ~: O- Y. |- B2 T Y- b* L
what's happening. You solution is to run matlab with the -nojvm mode. / Y4 b6 O& Q$ q" b: F, U) V1 U . K+ W2 ]4 h, j% F"The heap memory system in J***A consists of data and handle elements., n+ j3 s7 ^, q% k3 v; C
) B2 F6 l, R0 t1 o4 V
When you allocate a variable you get a handle and data. As long as data ; E! b7 H/ m* C" g/ L2 }, a% s- C, z 3 P; l: v+ _# w6 ], U+ s4 D8 Mhas an . b, V" Y: ]+ i( }- V7 {& {, A7 D X: V" u
associated handle, the JVM considers it valid and will not clean it up. ; M1 B1 N9 B+ G/ S" E) ?) b. v: W7 A4 Y* c- F
However, when you call the clear function in MATLAB, all handles are / G% T$ T- k! t( Y. k ! n. u. V; Q9 E+ v2 y6 ldestroyed, and the data associated is now invalid. This means that the9 ]% n7 D" r- n' ?2 W) U
5 a; U3 z, f; x( F+ R9 S" N( _6 WJ***A- e2 u4 W1 X) n
1 i" p# W( z v" h# [
engine can free up that data (garbage collection), but does not mean 6 W& v! ^. \& l6 p1 i8 }. L9 M$ o$ L2 t7 j7 n' w8 z5 s D
that it will clean it up at that moment.9 O8 V) z: J1 E& I7 l3 M
, R' r$ w$ \6 {7 J" {, s/ i
Calling the PACK command encourages J***A to run the garbage collector8 _: V4 c4 R4 U& e' \, m
: ` c- [7 ]# i) |- f- d, i
and de-fragment the memory. But it does not force it to (This is part9 x2 e$ n1 I3 u" a I
2 a' U( F& E" ]# N
of the J***A design). Even though the memory is 'freed' on the heap, # Y7 f# d' w3 ?* p# t/ i4 m9 e( K' ^% V, h2 u' n
it is not actually free to the OS, it is only free to the JVM. Here 4 j+ S$ Z8 o* k4 |" B0 X* i' G/ H/ d5 \: P' F
is one way to think of it: ( s- O# G4 r8 y! ~/ r; q- C; V* V- Q- ~, Y
[MATLAB] 8 R3 S" }5 J1 Q B! g 8 E4 e1 T) M! [6 \1 R9 [[J***A] 5 u4 s) K7 W n& h. \' q 7 }5 f) t* a6 r7 J[OS] 5 ~8 ~7 q. j; X5 X( ?* Y7 O" ], X$ h/ D' A* F
MATLAB runs on J***A (virtual machine), and Java runs on the OS (physical + b7 p5 y0 ^) \/ p5 n! N + Y' I6 Y. T% _machine). So when MATLAB is running in J***A mode memory allocations 0 u$ v9 S; C) c3 g 8 M A) g$ @& j) ]are requested from the JRE, not the OS. 6 _. e" c+ B0 L: x 3 P. {; g3 X* A1 i* K( H$ ?One problem you may be running into is that the default maximum J***A heap 1 y1 u3 D5 E# F7 ?) n+ n7 C6 ]4 Y2 ?3 P c- \
size is relatively low ( <= 64 M, so that is all the memory one session$ k$ A$ o3 e1 d/ o3 t4 ^5 r
0 n5 j: W: P2 U# w
of MATLAB will ever get on your system.) w9 e' |' V3 r z! g% m
4 r9 [$ Y+ r6 EThe good news is that you can increase this value. You will need to create: v( S9 m- j! u
3 k, v. y# G0 ya java.opts file in $MATLAB/bin/$ARCH (or in the current directory when ! x* L4 J5 Y) y3 j1 h6 H" V( w4 y, f: w: ^# z
you $ R) g! a( v) y ?7 t5 m, t9 w7 K0 B. |- Y) f
start MATLA and put the following command: & a2 c( s1 R2 p4 q - ^# P8 u L* ]6 b%%%BEGIN CODE%%% & e; K0 T/ R6 @ \8 k3 n4 C* [" f, R( S6 }. N4 Q
maxHeapSize = 268435456) ~8 r4 J% T4 n6 W Q9 |9 R
6 x0 ~* [( c" O9 ^9 O
%%%END CODE%%%: h u+ Z. X! t# H" W8 h+ E
. G. i6 F2 y" X0 W) K; |
This will give you 256MB of JVM memory and you can adjust the parameter 0 S* s I3 i+ J3 a, |1 _5 M0 A2 b+ E. I( J/ R
as needed.7 C' H1 N0 b4 _. _! X
& `- e: ~9 e" k- @" X6 jNote: $MATLAB is the root directory and $ARCH is your system$ V# S" b, Z/ D# D- w3 A
" h% [! Y" y* U6 d8 B$ a! @ @architecture. This solution works on Windows as well as Solaris, Linux, % A5 U$ \' x2 R: z8 p0 y N& Y" k2 W( M# c
Alpha, and SGI. A similar operation is possible on IBM and HPUX, but with 8 B1 B% w [/ t) D' a ' l; R& e. F$ E6 K' d& L' Ua different syntax. 2 v& \( y7 o' v! q) h4 G0 d2 N/ l6 V0 C3 W4 T' Q9 R
For the 1.1.8 JVM (Windows, Linux, Solaris, Alpha, SGI) our defaults are:6 o1 J3 W4 N% f8 R
* K/ H6 D) L, h* J
minHeapSize = 16000000 0 i% {3 `& t+ t7 l6 P! _6 e9 a( j2 G D0 d2 O' I. b& e
maxHeapSize = 64000000 4 E4 `2 n$ X3 C0 k1 R: z) N) b; H: [
These are the structure field names in that correspond to -ms and * Z- x) a3 [/ H4 h8 _& {( ~% z 4 C6 m, Q# y8 h; G. M-mx, and the settings above are roughly 16MB and 64MB. 2 p; _* U; x& S6 z- F0 W, Y" x [. c . R, m' Z- f& M- u8 mTo investigate the Java heap a bit, ask via the following: / s5 n, Y6 ]- X; C, y# ?+ [, c 5 X5 X9 q9 I, U$ Q1 k>> java.lang.Runtime.getRuntime.totalMemory" J4 h* o* B) I: N/ f( |
, T( t0 v$ T+ A, E# i U/ i
>> java.lang.Runtime.getRuntime.freeMemory$ I; g) u8 H$ S. `, a G
, [( K4 s! g" e- t2 \When the free memory hits zero, Java will double the heap size (up to the: K+ `1 u1 z& B7 [
; d9 D$ J% g8 A) K4 o6 X% ?maximum setting)." G/ Y' @' \; A+ d
" w2 _/ T/ x, G- RIf you choose to run without Java, you will remove the overhead of the . H. ^5 c6 ^; R ^4 X 1 f3 I! @6 s Rmiddle man, but you will also lose some MATLAB functionality (mostly; |- G- g, d4 x4 D2 R
4 c$ l& P2 c e5 O& a j6 `+ i" |
graphics and the Editor). You will still have most of the computational - U; [" X7 e$ T ]7 o* J& p/ J, Y7 a- ]0 w4 ~0 S$ e
power though.. n( F: V2 `! \% g7 s/ Y
; [% u& o$ h3 E# y9 H/ x
Without J***A, memory management will come directly from the OS, and a 5 V( @9 Z+ K) \2 u4 s! } ; U( {* j e; UCLEAR operation will result in memory being freed back to the OS.+ ~6 F" Y2 W- T. |0 ?7 ]" ]