www.gusucode.com > 关于海航matlab和lingo的训练题 > 人眼定位MATLAB源程序/plotbox.m
function result=plotbox(Target,Template,M); %**********判断目标的位置并标记************ [r1,c1]=size(Target); [r2,c2]=size(Template); [r,c]=max(M);%r每一列的最大值,c每列最大值所在的行数,都为一维矩阵 [r3,c3]=max(max(M));%r3 矩阵中的最大值,c3最大值所在的列数 %确定最大值点的坐标 i=c(c3);%行数 j=c3;%列数 result=Target; %画上边的横线 for x=i:i+r2-1 for y=j%一个像素点的宽度 result(x,y)=255;%画线设置成白色 end end %画下边的横线 for x=i:i+r2-1 for y=j+c2-1 result(x,y)=255; end end %画左边的竖线 for x=i for y=j:j+c2-1 result(x,y)=255; end end %画右边的竖线 for x=i+r2-1 for y=j:j+c2-1 result(x,y)=255; end end