Hi, 
after repeating several tests with 'runShepherdSegmentation',I used the output to derive a shapefile to use with 'pixelStats2SHP' for feature extraction. Although everything works correctly, this last function requires a considerable processing time in my case, about two days. 
Could you kindly explain to me why it takes so long and if there is a way to optimize the timing. 
Thank you, I enclose the code I used.
Segmentation:
import rsgislib
from rsgislib.segmentation import segutils
import shutil
#input path
img='/home/ubuntu/input/layer_stack.tif'
#output path
img_clump='/home/ubuntu/output/output_raster.tif'
#mean path
img_mean='/home/ubuntu/input/mean.tif'
segutils.runShepherdSegmentation(img,img_clump,img_mean,gdalformat='GTiff',numClusters=500,minPxls=435,distThres=500,sampling=500,kmMaxIter=500)
Feature extraction:
import rsgislib
from rsgislib import zonalstats
#path input shp
inputimage='/home/ubuntu/input/layer_stack.tif'
#path input shp
inputvector='/home/ubuntu/output/shp_mask.shp'
#path output shp + fe
outputvector='/home/ubuntu/output/output_fe.shp'
#pixelStats2SHP
zonalattributes = zonalstats.ZonalAttributes(calcCount=False, calcMin=False, calcMax=False, calcMean=True, calcStdDev=True, calcMode=False, calcSum=False)
rsgislib.zonalstats.pixelStats2SHP(inputimage, inputvector, outputvector, zonalattributes, True ,True, True, zonalstats.METHOD_POLYCONTAINSPIXELCENTER)