Artifact class

Represents a 2D grid of boolean values, primarily used for image processing and pattern recognition tasks.

This class provides various ways to create, manipulate, and analyze boolean matrices, including methods for resizing, comparing, and extracting information from the grid.

Constructors

Artifact(int cols, int rows)
Main constructor
Artifact.fromAsciiDefinition(List<String> template)
Creates a Matrix from an ASCII representation.
factory
Artifact.fromAsciiWithNewlines(String input)
Creates a Matrix from a multi-line ASCII string representation.
factory
Artifact.fromFlatListOfBool(List<bool> inputList, int width)
Creates a Matrix from a flat list of boolean values.
factory
Artifact.fromJson(Map<String, dynamic> json)
Creates a Matrix from JSON data.
factory
Artifact.fromMatrix(Artifact value)
Creates a new Artifact instance from an existing Artifact.
factory
Artifact.fromPoints(List<Point<int>> connectedPoints)
Creates a new Artifact from a list of connected points.
factory
Artifact.fromUint8List(Uint8List pixels, int width)
Creates a Matrix from a Uint8List, typically used for image data.
factory

Properties

area int
Area size of the matrix
no setter
cols int
The number of columns in the matrix.
getter/setter pair
enclosures int
Gets the number of enclosed regions in the matrix.
no setter
font String
Font this matrix template is based on
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
isEmpty bool
The grid contains one or more True values
no setter
isNotEmpty bool
All entries in the grid are false
no setter
locationAdjusted IntOffset
the location moved to
getter/setter pair
locationFound IntOffset
the location of this matrix.
getter/setter pair
matchingCharacter String
The character that this artifact matches.
getter/setter pair
matchingCharacterDescription String
Returns a human-readable description of the matching character.
no setter
matchingScore double
The score of the match
getter/setter pair
matrix Uint8List
The 2D list representing the boolean grid.
no setter
needsInspection bool
Tag the artifact as needing more attention during inspection
getter/setter pair
rectAdjusted IntRect
the rectangle location of this matrix.
no setter
rectFound IntRect
the rectangle location of this matrix.
no setter
rows int
The number of rows in the matrix.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
verticalLineLeft bool
Determines if there's a vertical line on the left side of the matrix.
no setter
verticalLineRight bool
Determines if there's a vertical line on the right side of the matrix.
no setter
wasPartOfSplit bool
Indicates whether this artifact was created as part of a splitting operation
getter/setter pair

Methods

aspectRatioOfContent() double
Calculates the aspect ratio of the content within the matrix.
cellGet(int x, int y) bool
Retrieves the value of a cell at the specified coordinates.
cellSet(int x, int y, bool value) → void
Sets the value of a cell at the specified coordinates.
clear() → void
Empty the content
createNormalizeMatrix(int desiredWidth, int desiredHeight) Artifact
Creates a new Artifact with the specified desired width and height, by resizing the current Artifact.
debugPrintGrid() → void
Prints the grid to the debug console.
discardableContent() bool
Determines if this artifact contains content that can be discarded.
extractSubGrid({required IntRect rect}) Artifact
Extracts a sub-grid from a larger binary image matrix.
findSubArtifacts() List<Artifact>
Finds the connected components (artifacts) in a binary image matrix.
findSubRegions() List<IntRect>
Identifies distinct regions in a dilated binary image.
getContentRect() IntRect
Calculates the bounding rectangle of the content in the matrix.
getHistogramHorizontal() List<int>
Returns the horizontal histogram of the matrix.
getHistogramVertical() List<int>
Returns the vertical histogram of the matrix.
gridToString({bool forCode = false, String onChar = '#', String offChar = '.'}) String
Converts the matrix to a string representation.
gridToStrings({String onChar = '#', String offChar = '.'}) List<String>
Converts the matrix to a list of strings.
isConsideredLine() bool
Determines if the current Matrix is considered a line based on its aspect ratio.
isPunctuation() bool
smaller (~30%) in height artifacts will be considered punctuation
mergeArtifact(Artifact toMerge) → void
Merges the current artifact with another artifact.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
padTopBottom({required int paddingTop, required int paddingBottom}) → void
Adds padding to the top and bottom of the matrix.
setBothLocation(IntOffset location) → void
rect setting helper
setGrid(Uint8List grid, int cols) → void
Sets the grid of the Matrix object.
setGridFromBools(List<List<bool>> input) → void
Sets the grid of the Matrix object from a 2D list of boolean values.
toJson() Map<String, dynamic>
Converts the Matrix object to a JSON-serializable Map.
toString() String
Returns a string representation of this artifact.
override
toText({String onChar = '#', bool forCode = false}) String
Converts the matrix to a text representation.
trim() Artifact
Trims the matrix by removing empty rows and columns from all sides.

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

sortMatrices(List<Artifact> list) → void
Sorts a list of Artifact objects based on their vertical and horizontal positions.
sortRectangles(List<IntRect> list, {double threshold = 5.0}) → void
Sorts a list of IntRect objects based on their vertical and horizontal positions.