createNormalizeMatrix method
Creates a new Artifact with the specified dimensions by resizing.
If the current Artifact is punctuation, it will not be cropped and will be centered in the new Artifact.
Implementation
Artifact createNormalizeMatrix(
final int desiredWidth,
final int desiredHeight,
) {
// help resizing by ensuring there's a border
final Artifact source = isPunctuation() ? this : trim();
final Artifact wrapped = _wrapGridWithFalse(source);
final double density = wrapped.rows == 0
? 0
: wrapped.countOnPixels() / (wrapped.rows * wrapped.cols);
final double fillThreshold = _computeDownscaleFillThreshold(density);
return _resizeGrid(
wrapped,
desiredWidth,
desiredHeight,
fillThreshold: fillThreshold,
);
}