user30985
user30985

Reputation: 683

How to save results of SuperpixelImageSegmentation as a raster

I am using library(SuperpixelImageSegmentation) to segmenting my image with associated coordinate NZTM. I would like to save get the segment results as a raster/vector file with associated coordinate NZTM. When I run my script as below, it has error " Error in (function (classes, fdef, mtable) : unable to find an inherited method for function ‘writeRaster’ for signature ‘"array", "character"". How to fix it?

library(SuperpixelImageSegmentation)
library(OpenImageR)
library(sp)
library(raster)
library(rgdal)
memory.limit(size=800000)
path = 'C:/Data/SLICO/image.tif'
im = OpenImageR::readImage(path)
init = Image_Segmentation$new()

spx = init$spixel_segmentation(input_image = im, 
                               superpixel =400, 
                               AP_data = TRUE,
                               use_median = TRUE, 
                               sim_wL = 3, 
                               sim_wA = 10, 
                               sim_wB = 10,
                               sim_color_radius = 10, 
                               verbose = TRUE)
str(spx)

OpenImageR::imageShow(spx$AP_image_data)
b=writeRaster(spx$AP_image_data, filename='C:/Data/test.tif', format="GTiff", overwrite=TRUE)

enter image description here

Upvotes: 0

Views: 99

Answers (0)

Related Questions