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 Connect adjacent pixels with the same pixel intensities to do blob extraction
image_split Splits the image according to pixel intensities
image_fuzzycmeans Fuzzy c-means segmentation of the histogram of color components
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.
Examples
# Split an image by colorimg <- image_quantize(logo,4)layers <- image_split(img)layers
# This returns the original imageimage_flatten(layers)# From the IM websiteobjects <- image_convert(demo_image("objects.gif"), colorspace ="Gray")objects
# Split image in blobs of connected pixel levelsif(magick_config()$version >"6.9.0"){objects |> image_connect(connectivity =4)|> image_split()# Fuzzy c-meansimage_fuzzycmeans(logo)logo |> image_convert(colorspace ="HCL")|> image_fuzzycmeans(smoothing =5)}