LargeScaleMeanShift does not recognize NA


I want to segment a subset of a Landsat 8 multiband image. The image contains NA values (-32748) as I have clipped the image to a polygon shape. The image is only 334 x 361 pixels with 30x30m per pixel.

Configuration setup

My system: Windows10
Version of the OTB: 7.0
I installed the OTB with: the binaries

Description of my issue

I want to run several segmentations using LargeScaleMeanShift, however no matter which parameter settings I use, the output always consists of only 5 single polyongs, which cover the different NA areas and the actual image part with data (see below). I tried to apply generic region merging and it works. Hence I guess that the problem should be related to the NA-areas. I already tried to apply a mask image, but that did not work (LSMS does not allow to include a mask).

I used the settings -spatialr 2 -ranger 10 -minsize 10 -tilesizex 50 -tilesizey 50 -mode.vector.out but the outcome looks like this (here from R):

Any suggestions why this problem occurs and how to avoid it?

Dear @oldi,
As far as I know, LargeScaleMeanShift doesn’t support the no-data. It might be an interesting feature to propose.

Is it possible to process the full image. Then you could use your mask to crop the output vector file.

Dear @julienosman,

LSMS worked perfectly well for the much larger World-View 2 imagery, which also contained NA values. Same area, but more pixels. The NA values were successfully ignored. For the smaller Landsat 8 image it did not work. Probably the Landsat image is too small as it is only 350x350 pixels?

I also saw that the boundary between the image part and the areas with NA is “blurry” and that there is always a very steep gradient in the Digital Numbers. Somehow there are values reaching 12000 instead of he normal spectral values e.g. 0.2. Perhaps these values occur because the NA values are not recognized as such? But why is this problem not occurring for the WV2 scene?

I tried to use a mask but LSMS does not provide an option to apply a mask.

I can copy a download-link for the L8 imagery if it would help.

It would help. Thank you !

Here it comes

Thank you

Hello @oldi

The dynamic of the input image should be taken into account when choosing the ranger parameter. According to the documentation:

Threshold on spectral signature euclidean distance (expressed in radiometry unit) to consider neighborhood pixel for averaging. Higher values will be less edge-preserving (more similar to simple average in neighborhood), whereas lower values will result in less noise smoothing. Note that this parameter has no effect on processing time.

The values of your input Landsat image lies between 0 and 1, therefore a ranger of 10 is too high. I tried with your image and a value of 0.05 and obtained the following results:


It think a better segmentation can be produced by tuning the ranger and spatialr parameters.

I hope that helps,

Dear @Cedric

that´s fantastic! Many thanks! I knew it has something to do with the values, but could not get my head around it. Okay, the ranger value was simply far too high.

This definitely helped. I hope also that others can build on this information.

Thank you again,