R/RcppExports.R

Defines functions thinImage whichToFill rgb2grayscale rgba2rgb addToFeatures cleanBinaryImage

Documented in addToFeatures cleanBinaryImage rgb2grayscale rgba2rgb thinImage whichToFill

# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

#' cleanBinaryImage
#' 
#' Removes alpha channel from png image.
#'
#' @param img A matrix of 1s and 0s.
#' 
#' @return png image with the alpha channel removed
#' 
cleanBinaryImage <- function(img) {
    .Call(`_handwriter_cleanBinaryImage`, img)
}

#' addToFeatures
#' 
#' @param FeatureSet The current list of features that have been calculated
#' @param LetterList List of all letters and their information
#' @param vectorDims Vectors with image Dims
#' 
#' @return A list consisting of current features calculated in FeatureSet as well as measures of compactness, loop count, and loop dimensions
#' 
addToFeatures <- function(FeatureSet, LetterList, vectorDims) {
    .Call(`_handwriter_addToFeatures`, FeatureSet, LetterList, vectorDims)
}

#' rgba2rgb
#' 
#' Removes alpha channel from png image.
#'
#' @param img A 3-d array with slices R, G, B, and alpha.
#' @return img as a 3D array with alpha channel removed
#' 
rgba2rgb <- function(img) {
    .Call(`_handwriter_rgba2rgb`, img)
}

#' rgba2grayscale
#' 
#' Changes RGB image to grayscale
#'
#' @param img A 3D array with slices R, G, and B
#' @return img as a 3D array as grayscale
#' 
#' @export
rgb2grayscale <- function(img) {
    .Call(`_handwriter_rgb2grayscale`, img)
}

#' whichToFill
#' 
#' Finds pixels in the plot that shouldn't be white and makes them black. 
#' Quick and helpful cleaning for before the thinning algorithm runs.
#'
#' @param img A binary matrix.
#' @return A cleaned up image.
#' 
#' @export
whichToFill <- function(img) {
    .Call(`_handwriter_whichToFill`, img)
}

#' thinImage
#' 
#' This function returns a vector of locations for black pixels in the thinned image.
#' Thinning done using Zhang - Suen algorithm.
#'
#' @param img A binary matrix of the text that is to be thinned.
#' @return A thinned, one pixel wide, image.
#' 
#' @export
thinImage <- function(img) {
    .Call(`_handwriter_thinImage`, img)
}

Try the handwriter package in your browser

Any scripts or data that you put into this service are public.

handwriter documentation built on Oct. 13, 2023, 5:10 p.m.