filtergrid

PURPOSE ^

FILTERGRID removes spur rows and columns existing after the grid arrangement process.

SYNOPSIS ^

function gridout=filtergrid(grid)

DESCRIPTION ^

 FILTERGRID removes spur rows and columns existing after the grid arrangement process.
 
 FITLERGRID processes the input grid and iteratively removes rows and
 columns until a rectangular grid is obtained.
 
 INPUTS:
     grid: MxNx2 matrix output by GETGRID
 
 OUTPUTS:
     gridout: VxWx2 matrix containing the filtered grid

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function gridout=filtergrid(grid)
0002 % FILTERGRID removes spur rows and columns existing after the grid arrangement process.
0003 %
0004 % FITLERGRID processes the input grid and iteratively removes rows and
0005 % columns until a rectangular grid is obtained.
0006 %
0007 % INPUTS:
0008 %     grid: MxNx2 matrix output by GETGRID
0009 %
0010 % OUTPUTS:
0011 %     gridout: VxWx2 matrix containing the filtered grid
0012 
0013 gridout=grid;
0014 while 1
0015     row1count=0;
0016     row2count=0;
0017     col1count=0;
0018     col2count=0;
0019     
0020     rowthresh=size(gridout,1)/2;
0021     colthresh=size(gridout,2)/2;
0022     
0023     for y=1:size(gridout,2)
0024         if gridout(1,y)
0025             row1count=row1count+1;
0026         end
0027         if gridout(end,y)
0028             row2count=row2count+1;
0029         end
0030     end
0031     for x=1:size(gridout,1)
0032         if gridout(x,1)
0033             col1count=col1count+1;
0034         end
0035         if gridout(x,end)
0036             col2count=col2count+1;
0037         end
0038     end
0039     
0040     row1count=row1count-rowthresh;
0041     row2count=row2count-rowthresh;
0042     col1count=col1count-colthresh;
0043     col2count=col2count-colthresh;
0044     
0045     % remove row or column with the least number of points
0046     [mincount,indx]=min([row1count,row2count,col1count,col2count]);
0047     if mincount<0
0048         switch indx
0049             case 1
0050                 gridout(1,:,:)=[];
0051             case 2
0052                 gridout(end,:,:)=[];
0053             case 3                
0054                 gridout(:,1,:)=[];
0055             case 4
0056                 gridout(:,end,:)=[];
0057         end
0058     else
0059         break;
0060     end
0061 end

Generated on Sun 04-Apr-2010 17:13:59 by m2html © 2005