How to complete the parameters in LSMS step 1 and 2

Hi everyone.

when i use the tools Mean ShiftSmothing (step1) and LSMSSegmentation (step2) there are quite parameters that i don’t know how to complet them.

In the first hand whe i tried with the step 1 I leave all the defect parameters, I don’t change them as you can see in the comand and in the image

otbcli_MeanShiftSmoothing -in I:\carlos\Imagery\nuevas_img\15\104001003F5F1500_15.tif -fout I:\carlos\Imagery\nuevas_img\ok\smooth.tif -foutpos I:\carlos\Imagery\nuevas_img\ok\smooth_pos.tif -spatialr 15 -ranger 0.25 -thres 0.1 -maxiter 100

By the other hand, to complete Step2, i’ve tried tons of numbers in spatial radius and range radius parameters, finally i found the correct ones but I don’t know why these numbers are the correct ones. I don’t know why but 2000 and 200 always fix whit my images, as you can check in the pic and in the code.

otbcli_LSMSSegmentation -in I:\carlos\Imagery\nuevas_img\15\filtered.tif -inpos I:\carlos\Imagery\nuevas_img\15\spatial.tif -out I:\carlos\Imagery\nuevas_img\15\segmentation.tif -spatialr 2000 -ranger 200 -minsize 1 -tilesizex 4728 -tilesizey 6359

And the result is always quite good whit this parameters

If someone could explain me why i don’t have to change the parameters in the first step, and how can i now which value use to the range radius and spatial radius I will appreciate a lot (probably the problem is tha i dont understand at all the meaning of this both parameters even reading the meaning of the cook-book)

Thanks in advance.

Well, setting spatial radius to such a high value basically makes it ignored by the application. You could as well untick the filtered position and spatial radius boxes.

Regarding range radius this is related to the range of you spectral bands so it is hard to tell but the value sounds reasonnable for a DN remote sensing images with 11 or 12 bits depth.

If you really want to ge to the bottom of what do those parameters mean, I can only encourage you to read the corresponding paper:

Hi Michel,

Thanks so much for your fedback.
I am quite new Orfeo user, so bit lost.
The problem we have is that the -spatialr -ranger are not clear for us.
As we undestand the range is the morfe common value in the bands histogram. With WorldView 3 imagery 8 bands and 0.3m it should be around 2000 check the pic.

But if we want to segment image with diferent objects such as forest, buildings, roads -spatialr is not clear if need value around 20-200.

Could you try to explain the more suitable values for diferente images such as WV 3 8 bands, WV 3 RGB and Sentinel?


I can not recommend values, segmentation parameters depend on objects of interest and segmentation itself is an ill-posed problem …

What you should know:

  • Spatial radius has a large impact on processing time but does not control fragmentation of segmentation, it only controls the size of the support window.
  • Range radius is a threshold on the euclidean distance between pixels signatures to be averaged (or not) in the pixels within range radius. You can see this as how much the pixel signature can deviate while still belonging to the object of interest.
  • Satellites image noise is not gaussian. A given range radius will likely not fit the full dynamic range, and will lead to fragmentation in higher parts of the range and under-segmentation in lower parts.

@alobo did an in depth review of mean-shift parameters in OTB, maybe he can give you some hints.

Thank you so much Michel!

So helpfull