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

superpixels

SLIC and SLICO superpixel implementations


Description

SLIC and SLICO superpixel implementations

Usage

superpixels(
  input_image,
  method = "slic",
  superpixel = 200,
  compactness = 20,
  return_slic_data = FALSE,
  return_lab_data = FALSE,
  return_labels = FALSE,
  write_slic = "",
  verbose = FALSE
)

Arguments

input_image

either a 2-dimensional or a 3-dimensional input image (the range of the pixel values should be preferably in the range 0 to 255)

method

a character string specifying the method to use. Either "slic" or "slico"

superpixel

a numeric value specifying the number of superpixels to use

compactness

a numeric value specifying the compactness parameter. The compactness parameter is needed only if method is "slic". The "slico" method adaptively chooses the compactness parameter for each superpixel differently.

return_slic_data

a boolean. If TRUE then the resulted slic or slico data will be returned

return_lab_data

a boolean. If TRUE then the Lab data will be returned ( the Lab-colour format )

return_labels

a boolean. If TRUE then the labels will be returned

write_slic

a character string. If not an empty string ("") then it should be a path to the output file with extension .bin ( for instance "/my_dir/output.bin" ). The data will be saved in binary format.

verbose

a boolean. If TRUE then information will be printed in the R session

References

https://www.epfl.ch/labs/ivrl/research/slic-superpixels/

Examples

library(OpenImageR)

#-------------------
# 3-dimensional data
#-------------------

path = system.file("tmp_images", "slic_im.png", package = "OpenImageR")

im = readImage(path)

res = superpixels(input_image = im, method = "slic", superpixel = 200,

                  compactness = 20, return_slic_data = TRUE)


#-------------------
# 2-dimensional data
#-------------------

im_2d = im[,,1]

res_mt = superpixels(input_image = im_2d, method = "slic", superpixel = 200,

                     compactness = 20, return_slic_data = TRUE)

OpenImageR

An Image Processing Toolkit

v1.1.8
GPL-3
Authors
Lampros Mouselimis [aut, cre] (<https://orcid.org/0000-0002-8024-1546>), Sight Machine [cph] (findHOGFeatures function of the SimpleCV computer vision platform), Johannes Buchner [cph] (average_hash, dhash and phash functions of the ImageHash python library), Mohammad Haghighat [cph] (Gabor Feature Extraction), Radhakrishna Achanta [cph] (Author of the C++ code of the SLIC and SLICO algorithms (for commercial use please contact the author))
Initial release
2021-05-04

We don't support your browser anymore

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