0

I have an 3D image (for example a MRI). I want to use the SLIC algorithm for segmentation.

Package OpenImageR provides the function superpixels. In the description (see https://search.r-project.org/CRAN/refmans/OpenImageR/html/superpixels.html) is written, one can give a 3D image as input.

But even for the simple example provided at the link above, it will not work...

library(OpenImageR)

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

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

im = readImage(path)

dim(im)
# [1] 360 360   4

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

                  compactness = 20, return_slic_data = TRUE)

# Error: In interface_superpixels(input_image, method, superpixel, compactness,  :
#  The input data has more than 3 dimensions. The dimensions were reduced from 4 to 3!

I can not imagine an array with dim = c(x, y, 3) to store any 3-dimensional image...

My questions:

Most important: IS there a package providing to use SLIC at "real" 3-dimensional images?

For my curiosity: Why does the mentioned function restricts 3D images to dim = c(x, y, 3)?

Allerleirauh
  • 115
  • 3
  • I'm not sure why you receive this error. You should receive a warning because "slic_im.png" has 4 dimensions and these were reduced to 3 but not an error. I just run the example of the documentation with the same "path" that you used and it returns the results. Which OpenImageR version do you use? When I use `packageVersion('OpenImageR')` I receive ‘1.2.5’ which is the current version on CRAN. You can still open an issue on the Github repository (https://github.com/mlampros/OpenImageR/issues), but you have to make sure first that you have installed the latest version of the R package correctly – lampros Sep 21 '22 at 03:46
  • Oh, sorry I get this as a warning, right. But I do not want that it reduces the third dimension to three... My real life example has dimension 512, 512, 44 – Allerleirauh Sep 21 '22 at 05:39

0 Answers0