library(OpenImageR)
#-----------
# read image
#-----------
path = system.file("tmp_images", "slic_im.png", package = "OpenImageR")
im = readImage(path)
im = im[,, 1:3]
#--------------------
# compute superpixels
#--------------------
res = superpixels(input_image = im, method = "slic", superpixel = 200,
compactness = 20, return_labels = TRUE)
#-------------------------
# compute the bounding box ( for subset of superpixels )
#-------------------------
bbox = superpixel_bbox_subset(res$labels, superpixel_subset = c(0, 10, 30))
Run the code above in your browser using DataLab