|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
function s=subim(f,4,4,2,2). R0 w# U2 O K& I) R
%SUBIM Extracts a subimage,s,from a given image,f.
& r. i0 F$ V& \%The subimage is of size m-by-n,and the coordinates
+ u8 m6 z* a1 K4 i6 o- T" c%of its top,left corner are(rx,cy).
' X) Q- Y. D, a% Fs=zeros(m,n);
' K% l }& `; X W2 b$ browhigh=rx+m-1;
2 Q @9 \" M# r3 t6 Ycolhigh=cy+n-1;; T8 L4 m9 n9 K! j2 k0 x9 f. M6 Y. w8 V
xcount=0;
; z% R8 ?; }" a- i4 D$ U2 \for r=rx:rowhigh* W5 C) }: k$ X- ~
xcount=xcount+1;
X1 Y3 S4 E% Lycount=0;
( m1 f! R/ m( Cfor c=cy:colhigh0 P8 Z" |1 U* [) J8 X, p9 H3 D0 M
ycount=ycount+1;3 K" i8 o# A( T: G# E7 ]- X
s(xcount,ycount)=f(r,c);
" N. o" J" r: ^/ _* [' x* cend
6 R" ]5 e! P1 {+ Pend# Z- h: P0 E( b3 p
|
|