public static int identifyRegions(char[][] img,char offChar){
  for (int i=0; i < img.length; i++) {
    for (int j=0; j < img[0].length; j++) {
      if (img[i][j] != offChar) {
        img[i][j]=ON;
      }
    }
  }
  char next=FirstRegion;
  IConvexHull alg=new ConvexHullScan();
  while (true) {
    IPoint p=locate(img);
    if (p == null)     return (next - FirstRegion);
    Collection<IPoint> points=new LinkedList<IPoint>();
    points.add(p);
    spread(img,(int)p.getX(),(int)p.getY(),points,next);
    IPoint[] raw=points.toArray(new TwoDPoint[]{});
    IPoint[] hull=alg.compute(raw);
    for (    IPoint h : hull) {
      img[(int)h.getX()][(int)h.getY()]=HULL;
    }
    next++;
  }
}

public static int identifyRegions ( char [ ] [ ] img , char offChar ) { for ( int i = 0 ; i < img . length ; i ++ ) { for ( int j = 0 ; j < img [ 0 ] . length ; j ++ ) { if ( img [ i ] [ j ] != offChar ) { img [ i ] [ j ] = ON ; } } } char next = FirstRegion ; IConvexHull alg = new ConvexHullScan ( ) ; while ( true ) { IPoint p = locate ( img ) ; if ( p == null ) return ( next - FirstRegion ) ; Collection < IPoint > points = new LinkedList < IPoint > ( ) ; points . add ( p ) ; spread ( img , ( int ) p . getX ( ) , ( int ) p . getY ( ) , points , next ) ; IPoint [ ] raw = points . toArray ( new TwoDPoint [ ] { } ) ; IPoint [ ] hull = alg . compute ( raw ) ; for ( IPoint h : hull ) { img [ ( int ) h . getX ( ) ] [ ( int ) h . getY ( ) ] = HULL ; } next ++ ; } }
assuming ' ' is the empty char , go through and assign contiguous image regions in the character image map that use ' onchar ' as the onbit . a contiguous region is based on the eight - cardinal directions in a 3x3 grid from center point . first convert all ' onchar ' into ( char 31 ) . start with ' ! ' which is character 33 , and work upwards from there ( skipping the
