code: public static void fitCannyBinary( GrayF32 input ) {
  
  		BufferedImage displayImage = new BufferedImage(input.width,input.height,BufferedImage.TYPE_INT_RGB);
  		GrayU8 binary = new GrayU8(input.width,input.height);
  
  		// Finds edges inside the image
  		CannyEdge<GrayF32,GrayF32> canny =
  				FactoryEdgeDetectors.canny(2, false, true, GrayF32.class, GrayF32.class);
  
  		canny.process(input,0.1f,0.3f,binary);
  
  		// Only external contours are relevant
  		List<Contour> contours = BinaryImageOps.contourExternal(binary, ConnectRule.EIGHT);
  
  		Graphics2D g2 = displayImage.createGraphics();
  		g2.setStroke(new BasicStroke(2));
  
  		// used to select colors for each line
  		Random rand = new Random(234);
  
  		for( Contour c : contours ) {
  			List<PointIndex_I32> vertexes = ShapeFittingOps.fitPolygon(c.external,true, minSide,cornerPenalty);
  
  			g2.setColor(new Color(rand.nextInt()));
  			VisualizeShapes.drawPolygon(vertexes,true,g2);
  		}
  
  		gui.addImage(displayImage, "Canny Contour");
  	}
docs: Detects contours inside the binary image generated by canny.  Only the external contour is relevant. Often
  easier to deal with than working with Canny edges directly.