image_textlines_astar {image.textlinedetector} | R Documentation |
Text Line Segmentation based on the A* Path Planning Algorithm
Description
Text Line Segmentation based on the A* Path Planning Algorithm
Usage
image_textlines_astar(x, morph = FALSE, step = 2, mfactor = 5, trace = FALSE)
Arguments
x |
an object of class magick-image |
morph |
logical indicating to apply a morphological 5x5 filter |
step |
step size of A-star |
mfactor |
multiplication factor in the cost heuristic of the A-star algorithm |
trace |
logical indicating to show the evolution of the line detection |
Value
a list with elements
n: the number of lines found
overview: an opencv-image of the detected areas
paths: a list of data.frame's with the x/y location of the baseline paths
textlines: a list of opencv-image's, one for each rectangular text line area
lines: a data.frame with the x/y positions of the detected lines
Examples
library(opencv)
library(magick)
library(image.textlinedetector)
path <- system.file(package = "image.textlinedetector", "extdata", "example.png")
img <- image_read(path)
img <- image_resize(img, "x1000")
areas <- image_textlines_astar(img, morph = TRUE, step = 2, mfactor = 5, trace = TRUE)
areas <- lines(areas, img)
areas$n
areas$overview
areas$lines
areas$textlines[[2]]
areas$textlines[[4]]
combined <- lapply(areas$textlines, FUN=function(x) image_read(ocv_bitmap(x)))
combined <- do.call(c, combined)
combined
image_append(combined, stack = TRUE)
plt <- image_draw(img)
lapply(areas$paths, FUN=function(line){
lines(x = line$x, y = line$y, col = "red")
})
dev.off()
plt
[Package image.textlinedetector version 0.2.3 Index]