|
|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
function s=subim(f,4,4,2,2)
; @. c E3 h# _+ b- t2 {. a%SUBIM Extracts a subimage,s,from a given image,f.
6 ?! T8 U. f9 |3 E- Q( `%The subimage is of size m-by-n,and the coordinates
' R* h8 b0 D4 b9 g%of its top,left corner are(rx,cy).$ k8 t$ k6 l+ v. l: ~9 V' X& @
s=zeros(m,n);
' [5 y U6 B+ g) l- zrowhigh=rx+m-1;! y* K; H5 N4 c: A- o, r
colhigh=cy+n-1;
! ] }% S& F" s9 R% C/ F7 pxcount=0;
0 c! h6 w( E+ e. T$ K' @! t, B" mfor r=rx:rowhigh7 C9 s+ d* N! T
xcount=xcount+1;
) m0 j4 `& q1 \0 N: `# L# Uycount=0;* _; v+ @" }' v6 t0 `( ? H3 J
for c=cy:colhigh) h9 K7 [' \0 y, J% d* Y2 r9 B- ?
ycount=ycount+1;
! B z6 F4 Y! K8 Q4 P$ S# _s(xcount,ycount)=f(r,c);; P5 l- x% V7 _6 S6 E4 w
end
/ {2 v2 o5 i4 U4 r8 H" a, aend
L8 o" o3 E* Y6 M! q |
|