Created
April 13, 2017 13:47
-
-
Save sminogue/5435bfb45a11498b7cccf5625bdd1a93 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Turn page into a grayscale image | |
GrayF32 f32 = ConvertBufferedImage.convertFromSingle(flat, null, GrayF32.class); | |
//Apply filter to give us that pure black and white paper look. This should also | |
//Remove any artifacts like shadows or discolorations in the paper. | |
GrayU8 bw = new GrayU8(f32.width, f32.height); | |
GThresholdImageOps.localSauvola(f32, bw, 15, 0.2f, true); | |
//Turn the pure B&W image into a bufferedimage. Also invert the colors as the filter | |
//Turns the page black with white text. | |
BufferedImage finalInversed = VisualizeBinaryData.renderBinary(bw, true, null); | |
panel.addImage(finalInversed, "Final"); | |
ShowImages.showWindow(panel,"Document Scanning", true); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment