question: private static Shape bottomEdge ( BufferedImage image ) { GeneralPath path = new GeneralPath ( ) ; Point2D p1 = null ; Point2D p2 = null ; Line2D line = new Line2D . Float ( ) ; Point2D p = new Point2D . Float ( ) ; int foundPointX = - 1 ; for ( int i = 0 ; i < image . getWidth ( ) ; i ++ ) { for ( int j = image . getHeight ( ) - 1 ; j >= 0 ; j -- ) { if ( ( image . getRGB ( i , j ) & 0xff000000 ) != 0 ) { p . setLocation ( i , j ) ; foundPointX = i ; break ; } } if ( foundPointX >= 0 ) { if ( p2 == null ) { p1 = new Point2D . Float ( foundPointX , 0 ) ; path . moveTo ( p1 . getX ( ) , p1 . getY ( ) ) ; p2 = new Point2D . Float ( ) ; p2 . setLocation ( p ) ; } else { p2 = detectLine ( p1 , p2 , p , line , path ) ; } } } path . lineTo ( p . getX ( ) , p . getY ( ) ) ; if ( foundPointX >= 0 ) { path . lineTo ( foundPointX , 0 ) ; } path . closePath ( ) ; return path ; }
target:  trace the bottom of the image