segmentation: Image Segmentation

Description Usage Arguments Details See Also Examples

Description

Basic image segmentation like connected components labelling, blob extraction and fuzzy c-means

Usage

1
2
3
4
5
image_connect(image, connectivity = 4)

image_split(image, keep_color = TRUE)

image_fuzzycmeans(image, min_pixels = 1, smoothing = 1.5)

Arguments

image

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

connectivity

number neighbor colors which are considered part of a unique object

keep_color

if TRUE the output images retain the color of the input pixel. If FALSE all matching pixels are set black to retain only the image mask.

min_pixels

the minimum number of pixels contained in a hexahedra before it can be considered valid (expressed as a percentage)

smoothing

the smoothing threshold which eliminates noise in the second derivative of the histogram (higher values gives smoother second derivative)

Details

image_connect performs blob extraction by scanning the image, pixel-by-pixel from top-left to bottom-right where regions of adjacent pixels which share the same set of intensity values get combined.

See Also

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# Split an image by color
img <- image_quantize(, 4)
layers <- image_split(img)
layers

# This returns the original image
image_flatten(layers)

# From the IM website
objects <- image_convert(demo_image("objects.gif"), colorspace = "Gray")
objects

# Split image in blobs of connected pixel levels
if(magick_config()$version > "6.9.0"){
objects %>%
  image_connect(connectivity = 4) %>%
  image_split()

# Fuzzy c-means
image_fuzzycmeans()

 %>%
  image_convert(colorspace = "HCL") %>%
  image_fuzzycmeans(smoothing = 5)
}

ropensci/magick documentation built on Jan. 15, 2019, 3:27 a.m.