- java.lang.Object
-
- com.uddernetworks.newocr.recognition.DefaultScannedImage
-
- All Implemented Interfaces:
ScannedImage
public class DefaultScannedImage extends java.lang.Object implements ScannedImage
An object to store line data forImageLetters 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 voidaddLine(int y, java.util.List<ImageLetter> databaseCharacterList)Adds a line containingImageLetters.java.awt.image.BufferedImagegetBinarizedImage()Gets the binarized image before any preprocessingit.unimi.dsi.fastutil.ints.Int2ObjectMap<java.util.List<ImageLetter>>getGrid()Returns the raw, mutable grid ofImageLetters 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.intgetLineCount()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.FilegetOriginalFile()Gets the originalFilescanned by the OCR.java.awt.image.BufferedImagegetOriginalImage()Gets the original image scanned by the OCR.java.lang.StringgetPrettyString()Gets the string of a scanned imagejava.util.Optional<ImageLetter>letterAt(int index)Gets the letter at the given index of the actualScannedImage.getPrettyString()position, meaning newlines are not returned.ScannedImagestripLeadingSpaces()Removes all common leading spaces, just like howOCRUtils.removeLeadingSpaces(String)removes empty spaces, but with actualImageLetterobjects.
-
-
-
Method Detail
-
getPrettyString
public java.lang.String getPrettyString()
Description copied from interface:ScannedImageGets the string of a scanned image- Specified by:
getPrettyStringin interfaceScannedImage- Returns:
- The string of a scanned image
-
stripLeadingSpaces
public ScannedImage stripLeadingSpaces()
Description copied from interface:ScannedImageRemoves all common leading spaces, just like howOCRUtils.removeLeadingSpaces(String)removes empty spaces, but with actualImageLetterobjects.- Specified by:
stripLeadingSpacesin interfaceScannedImage- Returns:
- The current
ScannedImage
-
letterAt
public java.util.Optional<ImageLetter> letterAt(int index)
Description copied from interface:ScannedImageGets the letter at the given index of the actualScannedImage.getPrettyString()position, meaning newlines are not returned.- Specified by:
letterAtin interfaceScannedImage- 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:ScannedImageGets the line at the stored index. This is NOT by the y value.- Specified by:
getGridLineAtIndexin interfaceScannedImage- Parameters:
index- The index of the row- Returns:
- The row
- Throws:
java.lang.IndexOutOfBoundsException
-
getLineCount
public int getLineCount()
Description copied from interface:ScannedImagegets the amount of lines in the image.- Specified by:
getLineCountin interfaceScannedImage- 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:ScannedImageReturns the raw, mutable grid ofImageLetters internally used with the key of the mpa being the exact Y position of the line.- Specified by:
getGridin interfaceScannedImage- Returns:
- The raw, mutable grid of values
-
addLine
public void addLine(int y, java.util.List<ImageLetter> databaseCharacterList)Description copied from interface:ScannedImageAdds a line containingImageLetters.- Specified by:
addLinein interfaceScannedImage- Parameters:
y- The exact Y position of the linedatabaseCharacterList- A list ofImageLetters as the line
-
getLine
public java.util.List<ImageLetter> getLine(int y)
Description copied from interface:ScannedImageGets the line at the given index value.- Specified by:
getLinein interfaceScannedImage- 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:ScannedImageGets both the line Y and values at the given index value.- Specified by:
getLineEntryin interfaceScannedImage- 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:ScannedImageGets the binarized image before any preprocessing- Specified by:
getBinarizedImagein interfaceScannedImage- Returns:
- The binarized image, which may be null if pulled from caches
-
getOriginalImage
public java.awt.image.BufferedImage getOriginalImage()
Description copied from interface:ScannedImageGets the original image scanned by the OCR.- Specified by:
getOriginalImagein interfaceScannedImage- Returns:
- The original image, which may be null if pulled from caches
-
getOriginalFile
public java.io.File getOriginalFile()
Description copied from interface:ScannedImageGets the originalFilescanned by the OCR.- Specified by:
getOriginalFilein interfaceScannedImage- Returns:
- The original File, which may be null if pulled from caches
-
-