edges {magick}R Documentation

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

Other image: _index_, analysis, animation, attributes(), color, composite, defines, device, editing, effects(), fx, geometry, morphology, ocr, options(), painting, segmentation, transform(), video

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()
}

[Package magick version 2.8.4 Index]