|
|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
function s=subim(f,4,4,2,2)
, \* N- ?5 e# l0 ]+ e%SUBIM Extracts a subimage,s,from a given image,f.
1 H8 W% E* V! w: S4 i( y+ s! H% \0 f%The subimage is of size m-by-n,and the coordinates9 F4 R$ [# R# Q. W, O/ {
%of its top,left corner are(rx,cy).
) i7 E. N' r6 E% |s=zeros(m,n);' e! o1 w! m! H' Z9 e; h
rowhigh=rx+m-1;1 N9 T' K/ k4 L4 }& ^3 q9 o6 J
colhigh=cy+n-1;
1 P7 c: A2 a [5 c% P, s" hxcount=0;3 S1 a4 _, d+ j, |
for r=rx:rowhigh. G0 ]2 R i- e* r e
xcount=xcount+1;
! z ?* o$ \' u3 Wycount=0;; t% j5 c# u3 W5 G8 {- \5 l
for c=cy:colhigh% h- X/ G) [; Z
ycount=ycount+1;
& z% X/ M* t0 {6 K- b4 r& G3 Q5 c+ vs(xcount,ycount)=f(r,c);/ \/ B% z$ R8 s1 i; O& q0 w! z W. x
end
1 G3 [8 w% |. x! ~* K( [end
, l& _7 k* }' g4 Y. U9 G# P |
|