Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

edges

Edge / Line Detection


Description

Best results are obtained by finding edges with image_canny() and then performing Hough-line detection on the edge image.

Usage

image_edge(image, radius = 1)

image_canny(image, geometry = "0x1+10%+30%")

image_hough_draw(
  image,
  geometry = NULL,
  color = "red",
  bg = "transparent",
  size = 3,
  overlay = FALSE
)

image_hough_txt(image, geometry = NULL, format = c("mvg", "svg"))

Arguments

image

magick image object returned by image_read() or image_graph()

radius

edge size in pixels

geometry

geometry string, see details.

color

a valid color string such as "navyblue" or "#000080". Use "none" for transparency.

bg

background color

size

size in points to draw the line

overlay

composite the drawing atop the input image. Only for bg = 'transparent'.

format

output format of the text, either svg or mvg

Details

For Hough-line detection, the geometry format is {W}x{H}+{threshold} defining the size and threshold of the filter used to find 'peaks' in the intermediate search image. For canny edge detection the format is {radius}x{sigma}+{lower%}+{upper%}. More details and examples are available at the imagemagick website.

See Also

Examples

if(magick_config()$version > "6.8.9"){
shape <- demo_image("shape_rectangle.gif")
rectangle <- image_canny(shape)
rectangle %>% image_hough_draw('5x5+20')
rectangle %>% image_hough_txt(format = 'svg') %>% cat()
}

magick

Advanced Graphics and Image-Processing in R

v2.7.2
MIT + file LICENSE
Authors
Jeroen Ooms [aut, cre] (<https://orcid.org/0000-0002-4035-0289>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.