public static BufferedImage renderContours ( List < Contour > contours , int colorExternal , int colorInternal , int width , int height , BufferedImage out ) { if ( out == null ) { out = new BufferedImage ( width , height , BufferedImage . TYPE_INT_RGB ) ; } else { Graphics2D g2 = out . createGraphics ( ) ; g2 . setColor ( Color . BLACK ) ; g2 . fillRect ( 0 , 0 , width , height ) ; } for ( Contour c : contours ) { for ( Point2D_I32 p : c . external ) { out . setRGB ( p . x , p . y , colorExternal ) ; } for ( List < Point2D_I32 > l : c . internal ) { for ( Point2D_I32 p : l ) { out . setRGB ( p . x , p . y , colorInternal ) ; } } } return out ; }
Draws contours . Internal and external contours are different user specified colors .