www.gusucode.com > matlab程序语言实现的水准网平差程序,使用于测绘人员 > 一种基于极大值稳定区域的文本定位方法matlab源码程序/毕业设计/代码/recalculator.m

    function [mserboxes]=recalculator(mserboxes,flag,i,j,ax,ay,bx,by,mx,my,nx,ny)
    
    if flag==0
        if abs(ay-my)<10 && abs(by-ny)<10 && (abs(ax-nx)<2 | abs(bx-mx)<2)%左右结构
            leftx=min(ax,mx);
            lefty=min(ay,my);
            rightx=max(bx,nx);
            righty=max(by,ny);
            width=rightx-leftx;
            height=righty-lefty;
            mserboxes(i).BoundingBox=[leftx,lefty,width,height];
            mserboxes(i).Count=1;
            mserboxes(j).BoundingBox=[0,0,0,0];
            mserboxes(j).Count=0;
        elseif abs(ax-mx)<10 && abs(bx-nx)<10 && (abs(by-my)<5 | abs(ny-ay)<5)%上下结构
            leftx=min(ax,mx);
            lefty=min(ay,my);
            rightx=max(bx,nx);
            righty=max(by,ny);
            width=rightx-leftx;
            height=righty-lefty;
            mserboxes(i).BoundingBox=[leftx,lefty,width,height];
            mserboxes(i).Count=1;
            mserboxes(j).BoundingBox=[0,0,0,0];
            mserboxes(j).Count=0;
        end
    elseif flag==1 | flag==2 | flag==4
        x1=max(ax,mx);
        y1=max(ay,my);
        x2=min(bx,nx);
        y2=min(by,ny);
        area=abs(x1-x2)*abs(y1-y2);
        area1=abs(ax-bx)*abs(ay-by);
        area2=abs(mx-nx)*abs(my-ny);
        if abs(ax-mx)<10 && abs(bx-nx)<10 && abs(ay-my)<10 && abs(by-ny)<10
            leftx=min(ax,mx);
            lefty=min(ay,my);
            rightx=max(bx,nx);
            righty=max(by,ny);
            width=rightx-leftx;
            height=righty-lefty;
            mserboxes(i).BoundingBox=[leftx,lefty,width,height];
            mserboxes(i).Count=1;
            mserboxes(j).BoundingBox=[0,0,0,0];
            mserboxes(j).Count=0;
        elseif (area/area1)>0.3 | (area/area2)>0.3
            leftx=min(ax,mx);
            lefty=min(ay,my);
            rightx=max(bx,nx);
            righty=max(by,ny);
            width=rightx-leftx;
            height=righty-lefty;
            mserboxes(i).BoundingBox=[leftx,lefty,width,height];
            mserboxes(i).Count=1;
            mserboxes(j).BoundingBox=[0,0,0,0];
            mserboxes(j).Count=0;
        end
    end  
    
end