question: 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 ++ ; } }
target:  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