Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- java.awt.Rectangle area = new java.awt.Rectangle(0, 0, img2.getWidth(), img2.getHeight());
- com.aspose.omr.imageprocessing.GrayscaleAlgorithm gs = new com.aspose.omr.imageprocessing.GrayscaleAlgorithm();
- gs.process(img2, area);
- // Binarization
- com.aspose.omr.imageprocessing.AverageThresholdAlgorithm threshold = new com.aspose.omr.imageprocessing.AverageThresholdAlgorithm();
- threshold.process(img2, area);
- // Skew correction
- com.aspose.omr.imageprocessing.SkewCorrectionAlgorithm skewCorrection = new com.aspose.omr.imageprocessing.SkewCorrectionAlgorithm();
- skewCorrection.process(img2, area);
- // save image
- java.io.File fileObj = new java.io.File("result.jpg");
- try {
- ImageIO.write(img2.asBitmap(), "jpg", fileObj);
- } catch (IOException ex) {
- Logger.getLogger(Scanner.class.getName()).log(Level.SEVERE, null, ex);
- }
- //Get skew degree of the image
- double degree = engine.getSkewDegree(img2);
- // Rotate image to correct skew
- engine.rotateImage(img2, degree);
- // Save image
- File file = new java.io.File("result.jpg");
- try {
- ImageIO.write(img2.asBitmap(), "jpg", file);
- } catch (IOException ex) {
- Logger.getLogger(Scanner.class.getName()).log(Level.SEVERE, null, ex);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement