Skip to content

Instantly share code, notes, and snippets.

@sminogue
Created April 13, 2017 13:43
Show Gist options
  • Save sminogue/e5e43d2d13a2f8ab312adbf9fbf3f797 to your computer and use it in GitHub Desktop.
Save sminogue/e5e43d2d13a2f8ab312adbf9fbf3f797 to your computer and use it in GitHub Desktop.
//Load test image from disk
BufferedImage image = UtilImageIO.loadImage("test.jpg");
//Convert to gray scale image
GrayU8 gray = ConvertBufferedImage.convertFromSingle(image, null, GrayU8.class);
//Brighten the image to wash out light colors in the background
GrayU8 brighter = GrayImageOps.brighten(gray, 100, 255, null);
//Reverse the black and white to make the paper page solid black for detection
GrayU8 invert = GrayImageOps.invert(brighter, 0, null);
panel.addImage(VisualizeBinaryData.renderBinary(invert, false, null), "Enhanced");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment