object OCR
Utility object for performing image preprocessing tasks for OCR.
This includes rotation correction, grayscale conversion, contrast adjustment, and optional binarization. All functions that manipulate pixels are pure and do not perform IO.
- Alphabetic
- By Inheritance
- OCR
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Type Members
- sealed trait ContrastLevel extends AnyRef
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def binarize(image: ImmutableImage, threshold: Int = 128): ImmutableImage
Binarizes an image by converting all pixels to either black or white based on a brightness threshold.
Binarizes an image by converting all pixels to either black or white based on a brightness threshold.
- image
the input image
- threshold
cutoff intensity (0–255) to determine black or white (default: 128)
- returns
a new binary (black-and-white) ImmutableImage
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @HotSpotIntrinsicCandidate() @native()
- def contrast(image: ImmutableImage, level: ContrastLevel): ImmutableImage
Adjusts image contrast by scaling the distance of pixel intensities from the midpoint (128).
Adjusts image contrast by scaling the distance of pixel intensities from the midpoint (128).
- image
the input image
- returns
a new ImmutableImage with adjusted contrast
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @HotSpotIntrinsicCandidate() @native()
- def grayscale(image: ImmutableImage): ImmutableImage
Converts an image to grayscale using a weighted luminance filter.
Converts an image to grayscale using a weighted luminance filter.
- image
the input image
- returns
a new grayscale ImmutableImage
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @HotSpotIntrinsicCandidate() @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @HotSpotIntrinsicCandidate() @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @HotSpotIntrinsicCandidate() @native()
- def prepareOCR(image: ImmutableImage, tilt: Double = 0.0, contrastFactor: Double = 1.4, threshold: Int = 128, doBinarize: Boolean = true): ImmutableImage
Performs a complete preprocessing pipeline for OCR: rotation correction, grayscale conversion, contrast adjustment, and optional binarization.
Performs a complete preprocessing pipeline for OCR: rotation correction, grayscale conversion, contrast adjustment, and optional binarization.
- image
the input image
- tilt
rotation angle in degrees (default: 0.0)
- contrastFactor
contrast multiplier (default: 1.4)
- threshold
threshold for binarization (default: 128)
- doBinarize
whether to perform binarization (default: true)
- returns
the processed ImmutableImage ready for OCR
- def rotate(image: ImmutableImage, radians: Double): ImmutableImage
Rotates an image to correct tilt or skew.
Rotates an image to correct tilt or skew.
- image
the input image
- radians
rotation angle in radians (positive = counterclockwise)
- returns
a new ImmutableImage rotated by the specified angle
- def saveAsJpeg(image: ImmutableImage, path: String, quality: Int = 90): Either[String, File]
Saves an image to disk in JPEG format with adjustable compression quality.
Saves an image to disk in JPEG format with adjustable compression quality.
- image
the image to save
- path
destination file path
- quality
compression quality (0–100, default: 90)
- returns
Either[String, File] with the output file or error message
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- object ContrastLevel
Deprecated Value Members
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated
- Deprecated
(Since version 9)