# LargeScaleMeanShift

**URL:** <https://forum.orfeo-toolbox.org/t/largescalemeanshift/815>\
**Category:** OTB Usage\
**Created:** [October 7, 2020, 4:25pm UTC](https://forum.orfeo-toolbox.org/t/largescalemeanshift/815 "2020-10-07T16:25:56Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![kadirim](https://forum.orfeo-toolbox.org/user_avatar/forum.orfeo-toolbox.org/kadirim/32/362_2.png) [@kadirim](https://forum.orfeo-toolbox.org/u/kadirim)\
**Post date:** [October 7, 2020, 4:25pm UTC](https://forum.orfeo-toolbox.org/t/largescalemeanshift/815/1 "2020-10-07T16:25:56Z")

</div>

## Context

- Segmentation of Spot7 image subset.

### Configuration setup

**My system** : \*Windows10  
**Version of the OTB** : \*7.1  
**I installed the OTB with** : \*the binaries,

## Description of my issue

- When i run my segmentation i have a “bad allocation” error : Caught std::exception during application execution: bad allocation
- I putted as RAM limit : -ram 25000
- I have 32 GO of available RAM
- the segmentation use all my available RAM and crash befor Shapefile generating.
- Image size is : 15360 x12875 pixel x 4 bands : UInt16

=\> Segmentation commande : otbcli\_LargeScaleMeanShift -in image -spatialr 7 -ranger 10 -minsize 100 -mode.vector.out image\_seg.shp -ram 25000

What should I to do ?

Thanks  
Mohamed.

---

<div class="post-metadata">

**Author:** ![wkcmark](https://forum.orfeo-toolbox.org/letter_avatar_proxy/v4/letter/w/c68b51/32.png) [@wkcmark](https://forum.orfeo-toolbox.org/u/wkcmark)\
**Post date:** [October 8, 2020, 7:03am UTC](https://forum.orfeo-toolbox.org/t/largescalemeanshift/815/2 "2020-10-08T07:03:22Z")

</div>

Hello Mohamed. I am having a similar issue with LargeScaleMeanShift. Is the issue the same as I describe below??

‘LargeScaleMeanShift’ has failed with return status -1. Please refer to ‘LargeScaleMeanShift’ documentation and check log tab.

The crash appears to happen in the ‘Computing Stats on input image’ stage.

The log states:

(FATAL) LargeScaleMeanShift: Caught std::exception during application execution: bad allocation

---

<div class="post-metadata">

**Author:** ![kadirim](https://forum.orfeo-toolbox.org/user_avatar/forum.orfeo-toolbox.org/kadirim/32/362_2.png) [@kadirim](https://forum.orfeo-toolbox.org/u/kadirim)\
**Post date:** [October 8, 2020, 7:12am UTC](https://forum.orfeo-toolbox.org/t/largescalemeanshift/815/3 "2020-10-08T07:12:50Z")

</div>

Hi Mark and thx for the reply,  
I don’t think so. I put all the error message :

Estimated memory for full processing: 9806.98MB (avail.: 256 MB), optimal image partitioning: 39 blocks  
2020-10-07 17:55:24 (INFO): Estimation will be performed in 40 blocks of 15360x322 pixels  
Computing stats on input image …: 100% [\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*] (19s)  
2020-10-07 18:09:56 (FATAL) LargeScaleMeanShift: Caught std::exception during application execution: bad allocation

---

<div class="post-metadata">

**Author:** ![julienosman](https://forum.orfeo-toolbox.org/user_avatar/forum.orfeo-toolbox.org/julienosman/32/1492_2.png) [@julienosman](https://forum.orfeo-toolbox.org/u/julienosman)\
**Post date:** [October 8, 2020, 7:20am UTC](https://forum.orfeo-toolbox.org/t/largescalemeanshift/815/4 "2020-10-08T07:20:20Z")

</div>

Dear @kadirim,  
Your issue looks very similar to what @wkcmark describes [here](https://forum.orfeo-toolbox.org/t/largescalemeanshift-is-there-a-maximum-file-size/809). I will try to reproduce your bug, to understand what happens.  
Best regards.  
Julien.

---

<div class="post-metadata">

**Author:** ![wkcmark](https://forum.orfeo-toolbox.org/letter_avatar_proxy/v4/letter/w/c68b51/32.png) [@wkcmark](https://forum.orfeo-toolbox.org/u/wkcmark)\
**Post date:** [October 8, 2020, 7:49am UTC](https://forum.orfeo-toolbox.org/t/largescalemeanshift/815/5 "2020-10-08T07:49:05Z")

</div>

@julienosman if you need any further info on this let me know. I really need to get this up and running again.

---

<div class="post-metadata">

**Author:** ![oldi](https://forum.orfeo-toolbox.org/user_avatar/forum.orfeo-toolbox.org/oldi/32/32_2.png) [@oldi](https://forum.orfeo-toolbox.org/u/oldi)\
**Post date:** [October 8, 2020, 3:14pm UTC](https://forum.orfeo-toolbox.org/t/largescalemeanshift/815/6 "2020-10-08T15:14:45Z")

</div>

Does the procedure work with a subset of the image? You could it to crop a much smaller portion and check if it runs then. If not then there is a deeper problem, if it runs through then it might be “simply” a memory problem

---

<div class="post-metadata">

**Author:** ![kadirim](https://forum.orfeo-toolbox.org/user_avatar/forum.orfeo-toolbox.org/kadirim/32/362_2.png) [@kadirim](https://forum.orfeo-toolbox.org/u/kadirim)\
**Post date:** [October 8, 2020, 4:08pm UTC](https://forum.orfeo-toolbox.org/t/largescalemeanshift/815/7 "2020-10-08T16:08:23Z")

</div>

Dear @oldi  
It seems be a memory problem even with 32 GO of Memory RAM.  
I will try with Grass according to @wkcmark advice.  
Regrads

---

<div class="post-metadata">

**Author:** ![wkcmark](https://forum.orfeo-toolbox.org/letter_avatar_proxy/v4/letter/w/c68b51/32.png) [@wkcmark](https://forum.orfeo-toolbox.org/u/wkcmark)\
**Post date:** [October 9, 2020, 7:11am UTC](https://forum.orfeo-toolbox.org/t/largescalemeanshift/815/8 "2020-10-09T07:11:13Z")

</div>

@oldi yes it works on smaller areas for me. However in the previous version it was running fine with big dataset.

---

<div class="post-metadata">

**Author:** ![oldi](https://forum.orfeo-toolbox.org/user_avatar/forum.orfeo-toolbox.org/oldi/32/32_2.png) [@oldi](https://forum.orfeo-toolbox.org/u/oldi)\
**Post date:** [October 14, 2020, 8:33am UTC](https://forum.orfeo-toolbox.org/t/largescalemeanshift/815/9 "2020-10-14T08:33:28Z")

</div>

It could also be due to errors at the image boundary. You can try to make a much larger subset, with some decent distance to the image boundary.

---

<div class="post-metadata">

**Author:** ![wkcmark](https://forum.orfeo-toolbox.org/letter_avatar_proxy/v4/letter/w/c68b51/32.png) [@wkcmark](https://forum.orfeo-toolbox.org/u/wkcmark)\
**Post date:** [November 21, 2021, 11:27am UTC](https://forum.orfeo-toolbox.org/t/largescalemeanshift/815/10 "2021-11-21T11:27:17Z")

</div>

@julienosman did you ever get anywhere with this? I’ve run into the error again.
