|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
function s=subim(f,4,4,2,2)* Y1 z; n2 E4 i2 x p
%SUBIM Extracts a subimage,s,from a given image,f.
& W+ S, _4 G0 U0 }%The subimage is of size m-by-n,and the coordinates
! ]$ G4 U# I* G: {; r, d2 n%of its top,left corner are(rx,cy).
# V s. @5 u: G M# xs=zeros(m,n);& p( c# V5 n$ q, q+ K2 G
rowhigh=rx+m-1;6 I( Q9 ]- b. n4 h/ k* Z* Q* Q
colhigh=cy+n-1;: m {; c9 K, _# k- ?+ R
xcount=0;0 i3 R7 d9 P$ d l6 s- d) m
for r=rx:rowhigh
5 Q$ i/ a7 x2 I1 d9 Y/ D. `% kxcount=xcount+1;
! A* y# B) C8 Q* }7 Dycount=0;
0 M" K$ ]. q' a; F- j$ Jfor c=cy:colhigh
3 ]8 Z$ S+ O2 ~ycount=ycount+1;* X6 j# D. R3 `9 `6 k5 P6 @
s(xcount,ycount)=f(r,c);
) t6 D1 D9 v8 o# P2 u0 |6 z3 O6 j7 Bend
; I, h8 Q8 r% v6 A% G$ vend
. {* E# c- }- X% b |
|