Module NewOCR

Class DefaultScannedImage

  • All Implemented Interfaces:
    ScannedImage

    public class DefaultScannedImage
    extends java.lang.Object
    implements ScannedImage
    An object to store line data for ImageLetters on a scanned image.
    Since:
    April 25, 2019
    • Constructor Summary

      Constructors 
      Constructor Description
      DefaultScannedImage​(java.io.File originalFile, java.awt.image.BufferedImage binarizedImage, java.awt.image.BufferedImage originalImage)  
    • Method Summary

      Modifier and Type Method Description
      void addLine​(int y, java.util.List<ImageLetter> databaseCharacterList)
      Adds a line containing ImageLetters.
      java.awt.image.BufferedImage getBinarizedImage()
      Gets the binarized image before any preprocessing
      it.unimi.dsi.fastutil.ints.Int2ObjectMap<java.util.List<ImageLetter>> getGrid()
      Returns the raw, mutable grid of ImageLetters internally used with the key of the mpa being the exact Y position of the line.
      java.util.Optional<java.util.List<ImageLetter>> getGridLineAtIndex​(int index)
      Gets the line at the stored index.
      java.util.List<ImageLetter> getLine​(int y)
      Gets the line at the given index value.
      int getLineCount()
      gets the amount of lines in the image.
      it.unimi.dsi.fastutil.ints.Int2ObjectMap.Entry<java.util.List<ImageLetter>> getLineEntry​(int y)
      Gets both the line Y and values at the given index value.
      java.io.File getOriginalFile()
      Gets the original File scanned by the OCR.
      java.awt.image.BufferedImage getOriginalImage()
      Gets the original image scanned by the OCR.
      java.lang.String getPrettyString()
      Gets the string of a scanned image
      java.util.Optional<ImageLetter> letterAt​(int index)
      Gets the letter at the given index of the actual ScannedImage.getPrettyString() position, meaning newlines are not returned.
      ScannedImage stripLeadingSpaces()
      Removes all common leading spaces, just like how OCRUtils.removeLeadingSpaces(String) removes empty spaces, but with actual ImageLetter objects.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DefaultScannedImage

        public DefaultScannedImage​(java.io.File originalFile,
                                   java.awt.image.BufferedImage binarizedImage,
                                   java.awt.image.BufferedImage originalImage)
    • Method Detail

      • getPrettyString

        public java.lang.String getPrettyString()
        Description copied from interface: ScannedImage
        Gets the string of a scanned image
        Specified by:
        getPrettyString in interface ScannedImage
        Returns:
        The string of a scanned image
      • letterAt

        public java.util.Optional<ImageLetter> letterAt​(int index)
        Description copied from interface: ScannedImage
        Gets the letter at the given index of the actual ScannedImage.getPrettyString() position, meaning newlines are not returned.
        Specified by:
        letterAt in interface ScannedImage
        Parameters:
        index - The character index
        Returns:
        The ImageLetter at the given position, if found
      • getGridLineAtIndex

        public java.util.Optional<java.util.List<ImageLetter>> getGridLineAtIndex​(int index)
                                                                           throws java.lang.IndexOutOfBoundsException
        Description copied from interface: ScannedImage
        Gets the line at the stored index. This is NOT by the y value.
        Specified by:
        getGridLineAtIndex in interface ScannedImage
        Parameters:
        index - The index of the row
        Returns:
        The row
        Throws:
        java.lang.IndexOutOfBoundsException
      • getLineCount

        public int getLineCount()
        Description copied from interface: ScannedImage
        gets the amount of lines in the image.
        Specified by:
        getLineCount in interface ScannedImage
        Returns:
        The amount of lines in the image
      • getGrid

        public it.unimi.dsi.fastutil.ints.Int2ObjectMap<java.util.List<ImageLetter>> getGrid()
        Description copied from interface: ScannedImage
        Returns the raw, mutable grid of ImageLetters internally used with the key of the mpa being the exact Y position of the line.
        Specified by:
        getGrid in interface ScannedImage
        Returns:
        The raw, mutable grid of values
      • addLine

        public void addLine​(int y,
                            java.util.List<ImageLetter> databaseCharacterList)
        Description copied from interface: ScannedImage
        Adds a line containing ImageLetters.
        Specified by:
        addLine in interface ScannedImage
        Parameters:
        y - The exact Y position of the line
        databaseCharacterList - A list of ImageLetters as the line
      • getLine

        public java.util.List<ImageLetter> getLine​(int y)
        Description copied from interface: ScannedImage
        Gets the line at the given index value.
        Specified by:
        getLine in interface ScannedImage
        Parameters:
        y - The index of the line
        Returns:
        The line at the given index value
      • getLineEntry

        public it.unimi.dsi.fastutil.ints.Int2ObjectMap.Entry<java.util.List<ImageLetter>> getLineEntry​(int y)
        Description copied from interface: ScannedImage
        Gets both the line Y and values at the given index value.
        Specified by:
        getLineEntry in interface ScannedImage
        Parameters:
        y - The index of the line
        Returns:
        The line at the given Y index value
      • getBinarizedImage

        public java.awt.image.BufferedImage getBinarizedImage()
        Description copied from interface: ScannedImage
        Gets the binarized image before any preprocessing
        Specified by:
        getBinarizedImage in interface ScannedImage
        Returns:
        The binarized image, which may be null if pulled from caches
      • getOriginalImage

        public java.awt.image.BufferedImage getOriginalImage()
        Description copied from interface: ScannedImage
        Gets the original image scanned by the OCR.
        Specified by:
        getOriginalImage in interface ScannedImage
        Returns:
        The original image, which may be null if pulled from caches
      • getOriginalFile

        public java.io.File getOriginalFile()
        Description copied from interface: ScannedImage
        Gets the original File scanned by the OCR.
        Specified by:
        getOriginalFile in interface ScannedImage
        Returns:
        The original File, which may be null if pulled from caches