Skip to content

Unexpected result with minsize in LargeScaleMeanShift

The following runs

otbcli_LargeScaleMeanShift -in 'PL20200706_MICAPCAc_sub05.tif' -spatialr 5 -ranger 5 -minsize 1 -mode.vector.out MSw05_s5_r5_m1.shp -ram 256
otbcli_LargeScaleMeanShift -in 'PL20200706_MICAPCAc_sub05.tif' -spatialr 15 -ranger 5 -minsize 1 -mode.vector.out MSw05_s15_r5_m1.shp -ram 256
otbcli_LargeScaleMeanShift -in 'PL20200706_MICAPCAc_sub05.tif' -spatialr 21 -ranger 5 -minsize 1 -mode.vector.out MSw05_s21_r5_m1.shp -ram 256

all produce a 1 pixel grid segmentation. all produce a 1 pixel grid segmentation: image

(zoom of the upper-left corner)

According to the doc, "Minimum Segment Size. If, after the segmentation, a segment is of size strictly lower than this criterion, the segment is merged with the segment that has the closest sepctral signature". Rather, it seems like here 1-pixel segments have been enforced.

If I set -minsize 20, I do get a reasonable segmentation, but identical in all 3 cases:

otbcli_LargeScaleMeanShift -in 'PL20200706_MICAPCAc_sub05.tif' -spatialr 5 -ranger 5 -minsize 20 -mode.vector.out MSw05_s5_r5_m20.shp -ram 256

image

(zoom of the upper-left corner)

Instead, if I use otbcli_Segmentation, the minsize=1 parameter seems to work fine:

otbcli_Segmentation -in 'PL20200706_MICAPCAc_sub05.tif' -filter meanshift -filter.meanshift.spatialr 5 -filter.meanshift.ranger 5 -mode vector -mode.vector.minsize 1 -mode.vector.out 'MSw05_s5_r5_m1_B.shp'

image

Get the Input image: https://www.dropbox.com/s/u32tsw878dn31az/PL20200706_MICAPCAs_sub05.tif?dl=0