utilities library

This library is part of the Textify package. Collection of utility functions for image processing and text extraction.

Classes

IntOffset
A 2D offset with integer coordinates.
IntRect
A class representing a rectangle with integer coordinates and dimensions.

Functions

artifactFromImage(Image image) Future<Artifact>
Creates a Artifact from a Image.
artifactValleysOffsets(Artifact artifact) List<int>
Returns a list of column indices where the artifact should be split
calculateThreshold(List<int> histogram) int
Calculates an appropriate threshold for identifying valleys in a histogram
computeAdaptiveThreshold(Uint8List pixels, int width, int height) int
Computes an adaptive threshold for converting a grayscale image to black and white.
computeKernelSize(int width, int height, double scaleFactor) int
Computes the appropriate kernel size for dilation based on image dimensions.
copyArtifactGrid(Artifact source, Artifact target, int offsetX, int offsetY) → void
Copies the contents of a source Matrix into a target Matrix, with an optional offset.
createImageFromPixels(Uint8List pixels, int width, int height) Future<Image>
Creates a new Image from a Uint8List of pixel data.
dilateArtifact({required Artifact matrixImage, required int kernelSize}) Artifact
Applies dilation morphological operation to a binary image.
floodFill(Artifact binaryPixels, Artifact visited, int startX, int startY) List<Point<int>>
Performs a highly optimized flood fill algorithm on a binary image matrix.
floodFillToRect(Artifact binaryPixels, Artifact visited, int startX, int startY) IntRect
Performs a flood fill algorithm and directly calculates the bounding rectangle without storing all individual points.
hammingDistancePercentageOfTwoArtifacts(Artifact inputGrid, Artifact templateGrid) double
Calculates the normalized Hamming distance between two matrices.
imageToBlackOnWhite(Image inputImage, {double contrast = 0}) Future<Image>
Converts a color image to a binary (black and white) image.
imageToUint8List(Image image) Future<Uint8List>
Converts a Image to a Uint8List representation.
offsetArtifacts(List<Artifact> matrices, int x, int y) → void
Applies an offset to the location of a list of matrices.
splitArtifactByColumns(Artifact artifactToSplit, List<int> offsets) List<Artifact>
Splits the given matrix into multiple row matrices based on the provided row offsets.