Unknown exception during large mean shift


I’m trying to run mean shift segmentation on an hyperspectral airborne image.

Configuration setup

My system: Windows 10
Version of the OTB: OTB 8.1.0
I installed the OTB with: binaries and QGIS packages

If relevant, you may also provide:
QGIS version: 3.22.1-Białowieża
Python version: 3.10.8

Description of my issue

I’m trying to run a mean shift segmentation of my airborne hyperspectral image both with OTB in QGIS and via the binary GUI, but the results are the same.
`2023-01-05 11:02:13 (INFO) LargeScaleMeanShift: Default RAM limit for OTB is 256 MB
2023-01-05 11:02:13 (INFO) LargeScaleMeanShift: GDAL maximum cache size is 1622 MB
2023-01-05 11:02:13 (INFO) LargeScaleMeanShift: OTB will use at most 8 threads
2023-01-05 11:02:13 (INFO) LargeScaleMeanShift: Smoothing step…
2023-01-05 11:02:13 (INFO): Loading metadata from official product
2023-01-05 11:02:13 (INFO) LargeScaleMeanShift: Margin of 501 pixels applied to each tile to stabilized mean shift filtering.

2023-01-05 11:02:13 (INFO) LargeScaleMeanShift: Mode Search is disabled.

2023-01-05 11:02:13 (INFO) LargeScaleMeanShift: Number of tiles: 4 x 23
2023-01-05 11:02:13 (INFO) LargeScaleMeanShift: Tile shifting …
2023-01-05 11:02:56 (FATAL) LargeScaleMeanShift: Caught unknown exception during application execution.`

Any suggestion?
I see that the RAM size is quite limited, but I can’t find an option to increase that.


Can you try adding -ram 2048 as a parameter to your call? This is how you can tell the application to use the ram you defined. Your error looks like there is not enough memory for the processing

Let me know

Best regards

Kind Thibaut,

Thank you for your answer, I’ve tried following your advice and ran the command as

otbcli_LargeScaleMeanShift.bat -in hyperspectralfile.dat -mode.vector.out shapefileout.shp -ram 2048

But still to no avail:

  1. OTB output still read “2023-01-09 11:41:26 (INFO) LargeScaleMeanShift: Default RAM limit for OTB is 256 MB”
  2. It still crashed with “2023-01-09 11:45:18 (FATAL) LargeScaleMeanShift: Caught unknown exception during application execution.”

I’ve done more tests and indeed it seems to be a memory problem: if I reduce the number of bands in the image (to 3-4, rather than 186), the algorithm runs. So, it seems that the issue is in the lack of increase of available RAM, no matter the command.

Can you try to set the environment variable OTB_MAX_RAM_HINT to the (max ram of you PC - 4Go) for windows to run correctly before calling the application. In this case try without the “ram” parameter and let me know,

Best regards

Dear Thibaut,

Setting the environmental variable seems to have worked as the Defalut RAM limit is now 28000. I still incur in memory errors for big images with many bands and pixels, but it’s not defaulting to 256 MB anymore.