private static Shape leftEdge(BufferedImage image){
  GeneralPath path=new GeneralPath();
  Point2D p1=null;
  Point2D p2=null;
  Line2D line=new Line2D.Float();
  Point2D p=new Point2D.Float();
  int foundPointY=-1;
  for (int i=0; i < image.getHeight(); i++) {
    for (int j=0; j < image.getWidth(); j++) {
      if ((image.getRGB(j,i) & 0xff000000) != 0) {
        p=new Point2D.Float(j,i);
        foundPointY=i;
        break;
      }
    }
    if (foundPointY >= 0) {
      if (p2 == null) {
        p1=new Point2D.Float(image.getWidth() - 1,foundPointY);
        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 (foundPointY >= 0) {
    path.lineTo(image.getWidth() - 1,foundPointY);
  }
  path.closePath();
  return path;
}

private static Shape leftEdge ( BufferedImage image ) { GeneralPath path = new GeneralPath ( ) ; Point2D p1 = null ; Point2D p2 = null ; Line2D line = new Line2D . Float ( ) ; Point2D p = new Point2D . Float ( ) ; int foundPointY = - 1 ; for ( int i = 0 ; i < image . getHeight ( ) ; i ++ ) { for ( int j = 0 ; j < image . getWidth ( ) ; j ++ ) { if ( ( image . getRGB ( j , i ) & 0xff000000 ) != 0 ) { p = new Point2D . Float ( j , i ) ; foundPointY = i ; break ; } } if ( foundPointY >= 0 ) { if ( p2 == null ) { p1 = new Point2D . Float ( image . getWidth ( ) - 1 , foundPointY ) ; 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 ( foundPointY >= 0 ) { path . lineTo ( image . getWidth ( ) - 1 , foundPointY ) ; } path . closePath ( ) ; return path ; }
trace the left side of the image
