ocv_deslant: Deslant images by putting cursive text upright

View source: R/deslant.R

ocv_deslantR Documentation

Deslant images by putting cursive text upright

Description

This algorithm sets handwritten text in images upright by removing cursive writing style. One can use it as a preprocessing step for handwritten text recognition.

  • image_deslant expects a magick-image and performs grayscaling before doing deslanting

  • ocv_deslant expects a ocv-image and does not perform grayscaling before doing deslanting

Usage

ocv_deslant(image, bgcolor = 255, lower_bound = -1, upper_bound = 1)

image_deslant(image, bgcolor = 255, lower_bound = -1, upper_bound = 1)

Arguments

image

an object of class opencv-image (for ocv_deslant) with pixel values between 0 and 255 or a magick-image (for image_deslant)

bgcolor

integer value with the background color to use to fill the gaps of the sheared image that is returned. Defaults to white: 255

lower_bound

lower bound of shear values. Defaults to -1

upper_bound

upper bound of shear values. Defaults to 1

Value

an object of class opencv-image or magick-image with the deslanted image

Examples



library(magick)
library(opencv)
library(image.textlinedetector)
path <- system.file(package = "image.textlinedetector", "extdata", "cursive.png")
img  <- ocv_read(path)
img  <- ocv_grayscale(img)
img
up   <- ocv_deslant(img)
up

img  <- image_read(path)
img
image_deslant(img)



image.textlinedetector documentation built on Nov. 10, 2023, 1:09 a.m.