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 an Artifact from an ASCII representation.
factory
- Artifact.fromAsciiWithNewlines(String input)
-
Creates an Artifact from a multi-line ASCII string representation.
factory
-
Artifact.fromFlatListOfBool(List<
bool> inputList, int width) -
Creates an Artifact from a flat list of boolean values.
factory
-
Artifact.fromJson(Map<
String, dynamic> json) -
Creates an Artifact from JSON data.
factory
- Artifact.fromMatrix(Artifact value)
-
Creates a new Artifact instance from an existing Artifact.
factory
-
Artifact.fromPoints(List<
Point< connectedPoints)int> > -
Creates a new Artifact from a list of connected points.
factory
- Artifact.fromUint8List(Uint8List pixels, int width)
-
Creates an Artifact from a Uint8List, typically used for image data.
factory
Properties
- area → int
-
Area size of the matrix
no setter
- cachedEnclosures ↔ int?
-
Cached number of enclosures found (set by ArtifactRegionExt).
getter/setter pair
- cachedVerticalLineLeft ↔ bool?
-
Cached vertical left line detection (set by ArtifactAnalysisExt).
getter/setter pair
- cachedVerticalLineRight ↔ bool?
-
Cached vertical right line detection (set by ArtifactAnalysisExt).
getter/setter pair
- cols ↔ int
-
The number of columns in the grid.
getter/setter pair
- enclosures → int
-
Available on Artifact, provided by the ArtifactRegionExt extension
Lazily evaluates and caches the number of enclosed regions.no setter - font ↔ String
-
Font this 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 adjusted location.
getter/setter pair
- locationFound ↔ IntOffset
-
The location of this artifact in the source image.
getter/setter pair
- matchingCharacter ↔ String
-
The character that this artifact matches.
getter/setter pair
- matchingCharacterDescription → String
-
Available on Artifact, provided by the ArtifactSerializeExt extension
Returns a human-readable description of the matching character.no setter - matchingScore ↔ double
-
The score of the match
getter/setter pair
- matrix → Uint8List
-
The raw grid buffer.
no setter
- needsInspection ↔ bool
-
Tag the artifact as needing more attention during inspection
getter/setter pair
- rectAdjusted → IntRect
-
The rectangle location after adjustment.
no setter
- rectFound → IntRect
-
The rectangle location of this artifact.
no setter
- rows → int
-
The number of rows in the grid.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- verticalLineLeft → bool
-
Available on Artifact, provided by the ArtifactAnalysisExt extension
Lazily evaluates and caches vertical line detection on the left side.no setter - verticalLineRight → bool
-
Available on Artifact, provided by the ArtifactAnalysisExt extension
Lazily evaluates and caches vertical line detection on the right side.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
-
countOnPixels(
{IntRect? rect}) → int - Counts the number of "on" pixels within an optional rectangle.
-
countVerticalStems(
) → int -
Available on Artifact, provided by the ArtifactAnalysisExt extension
Estimates the number of strong vertical stems in a glyph. -
createNormalizeMatrix(
int desiredWidth, int desiredHeight) → Artifact -
Available on Artifact, provided by the ArtifactGridTransformExt extension
Creates a new Artifact with the specified dimensions by resizing. -
discardableContent(
) → bool - Determines if this artifact contains content that can be discarded.
-
erodeSoft(
) → Artifact -
Available on Artifact, provided by the ArtifactMorphologyExt extension
Creates a softly eroded version of this artifact. -
extractSubGrid(
{required IntRect rect}) → Artifact -
Available on Artifact, provided by the ArtifactGridTransformExt extension
Extracts a sub-grid from a larger binary image matrix. -
findSubArtifacts(
) → List< Artifact> -
Available on Artifact, provided by the ArtifactRegionExt extension
Finds the connected components (artifacts) in a binary image matrix. -
findSubRegions(
) → List< IntRect> -
Available on Artifact, provided by the ArtifactRegionExt extension
Identifies distinct regions in a dilated binary image. -
getContentRect(
) → IntRect - Calculates the bounding rectangle of the content in the matrix.
-
getHistogramHorizontal(
) → List< int> -
Available on Artifact, provided by the ArtifactAnalysisExt extension
Returns the horizontal histogram of the matrix. -
getHistogramVertical(
) → List< int> -
Available on Artifact, provided by the ArtifactAnalysisExt extension
Returns the vertical histogram of the matrix. -
gridToString(
{bool forCode = false, String onChar = '#', String offChar = '.'}) → String -
Available on Artifact, provided by the ArtifactSerializeExt extension
Converts the matrix to a string representation. -
gridToStrings(
{String onChar = '#', String offChar = '.'}) → List< String> -
Available on Artifact, provided by the ArtifactSerializeExt extension
Converts the matrix to a list of strings. -
hasLowerRightStroke(
) → bool -
Available on Artifact, provided by the ArtifactAnalysisExt extension
Detects ink density in the lower-right quadrant of the glyph. -
hasSameMatrixData(
Artifact other) → bool - Returns true when another artifact has identical normalized pixel data.
-
hasTopHeavyHorizontalBar(
) → bool -
Available on Artifact, provided by the ArtifactAnalysisExt extension
Returns true when the glyph preserves a distinctly top-heavy bar. -
isConsideredLine(
) → bool - Determines if the current Artifact is considered a line based on its aspect ratio.
-
isPunctuation(
) → bool - smaller (~40%) in height artifacts will be considered punctuation
-
mergeArtifact(
Artifact toMerge) → void -
Available on Artifact, provided by the ArtifactGridTransformExt extension
Merges the current artifact with another artifact in-place. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
padTopBottom(
{required int paddingTop, required int paddingBottom}) → void -
Available on Artifact, provided by the ArtifactGridTransformExt extension
Adds padding to the top and bottom of the matrix. -
removeDecorativeLineComponents(
) → Artifact -
Available on Artifact, provided by the ArtifactMorphologyExt extension
Returns a copy with very long decorative line components removed. -
setBothLocation(
IntOffset location) → void - rect setting helper
-
setGrid(
Uint8List grid, int cols) → void - Sets the grid from a flat Uint8List and column count.
-
setGridFromBools(
List< List< input) → voidbool> > - Sets the grid of the Artifact object from a 2D list of boolean values.
-
toJson(
) → Map< String, dynamic> -
Available on Artifact, provided by the ArtifactSerializeExt extension
Converts the Artifact object to a JSON-serializable Map. -
toString(
) → String -
Returns a string representation of this artifact.
override
-
toText(
{String onChar = '#', bool forCode = false}) → String -
Available on Artifact, provided by the ArtifactSerializeExt extension
Converts the matrix to a text representation. -
trim(
) → Artifact -
Available on Artifact, provided by the ArtifactGridTransformExt extension
Trims the matrix by removing empty rows and columns from all sides.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
artifactFromImage(
Image image) → Future< Artifact> - Creates a Artifact from a Image.
-
copyArtifactGrid(
Artifact source, Artifact target, int offsetX, int offsetY) → void - Copies the contents of a source Artifact into a target Artifact, with an optional offset.
-
hammingDistancePercentageOfTwoArtifacts(
Artifact inputGrid, Artifact templateGrid) → double - Calculates the normalized Hamming distance between two matrices.
-
offsetArtifacts(
List< Artifact> matrices, int x, int y) → void - Applies an offset to the location of a list of matrices.
-
sortMatrices(
List< Artifact> list) → void - Sorts a list of Artifact objects based on their vertical and horizontal positions.
-
sortRectangles(
List< IntRect> list, {double threshold = _defaultRectangleSortThreshold}) → void - Sorts a list of IntRect objects based on their vertical and horizontal positions.