morphology: Morphological image operations

View source: R/morphology.R

morphologyR Documentation

Morphological image operations

Description

Apply imaage morphological operations

Usage

morphology(
  input,
  operation,
  radius,
  type = "binary",
  value = 1,
  shape = "ball",
  radiusIsParametric = FALSE,
  thickness = 1,
  lines = 3,
  includeCenter = FALSE
)

Arguments

input

input image

operation

operation to apply

"close"

Morpholgical closing

"dilate"

Morpholgical dilation

"erode"

Morpholgical erosion

"open"

Morpholgical opening

radius

radius of structuring element

type

type of morphology

"binary"

Binary operation on a single value

"grayscale"

Grayscale operations

value

value to operation on (type='binary' only)

shape

shape of the structuring element ( type='binary' only )

"ball"

spherical structuring element

"box"

box shaped structuring element

"cross"

cross shaped structuring element

"annulus"

annulus shaped structuring element

"polygon"

polygon structuring element

radiusIsParametric

used parametric radius boolean (shape='ball' and shape='annulus' only)

thickness

thickness (shape='annulus' only)

lines

number of lines in polygon (shape='polygon' only)

includeCenter

include center of annulus boolean (shape='annulus' only)

Value

antsImage is output

Author(s)

Avants BB

Examples


fi <- antsImageRead(getANTsRData("r16"), 2)
mask <- getMask(fi)
dilatedBall <- morphology(mask,
  operation = "dilate", radius = 3,
  type = "binary", shape = "ball"
)
erodedBox <- morphology(mask,
  operation = "erode", radius = 3,
  type = "binary", shape = "box"
)
openedAnnulus <- morphology(mask,
  operation = "open", radius = 5,
  type = "binary", shape = "annulus", thickness = 2
)
out <- morphology(mask, operation = "open", radius = 5, type = "binary", shape = "polygon")
out <- morphology(mask, operation = "open", radius = 5, type = "binary", shape = "cross")
out <- morphology(mask, operation = "close", radius = 5, type = "binary", shape = "polygon")
out <- morphology(mask, operation = "erode", radius = 5, type = "binary", shape = "polygon")
out <- morphology(mask, operation = "dilate", radius = 5, type = "binary", shape = "polygon")
testthat::expect_error(morphology(mask, operation = "open", radius = 5, shape = "hey"))

stnava/ANTsR documentation built on April 13, 2025, 4:10 a.m.