Band Math X with large neighborhood

Hi
I want to perform Band Math X with a large neighborhood (> 10). I have the error describe here:
https://bugs.orfeo-toolbox.org/view.php?id=1119

So I have compile the OTB with the following change in the code, as describe in the aforementioned link.

  m_SizeNeighbourhood=20; //line 69

I also modified the error message to be sure

// line 603
  //Checking formulas consistency
  if (m_VNotAllowedVarName.size()>0)
  {
    std::stringstream sstm;
    sstm << "Following variables not allowed : ";
    for(unsigned int i=0; i<m_VNotAllowedVarName.size(); ++i)
      sstm << m_VNotAllowedVarName[i].name << " ";
    sstm << "Neighborhood size: " << m_SizeNeighbourhood; // Modif fauvel
    sstm << std::endl;
    itkExceptionMacro(<< sstm.str());
  }

After a compilation, it is still not working, I got the following error

otbcli_BandMathX -il /media/Data/Data/Sebioref/CropImages/ortho_10_470.tif -out /tmp/toto.tif -exp "mean(im1b1N50x50)" -ram 2048
2019-09-18 10:56:21 (INFO): No kwl metadata found in file /media/Data/Data/Sebioref/CropImages/ortho_10_470.tif
2019-09-18 10:56:21 (INFO): Default RAM limit for OTB is 128 MB
2019-09-18 10:56:21 (INFO): GDAL maximum cache size is 796 MB
2019-09-18 10:56:21 (INFO): OTB will use at most 4 threads
2019-09-18 10:56:21 (INFO): Image #1 has 3 components
2019-09-18 10:56:21 (INFO): Using expression : mean(im1b1N50x50)
2019-09-18 10:56:21 (FATAL): itk::ERROR: BandMathXImageFilter(0x5558f2dd1c40): Following variables not allowed : im1b1N50x50 Neighborhood size: 20

So the modification seems fine, but I cannot use neighborhood order larger than 10. I check the code, but I did not see where the size of the neighborhood is checked…

If you have any idea ??

Mathieu

Hello,

Your modification should work, two things:

  • neighborhood are centered, and you can only use odd number for neighborhood sizes. im1b1N50x50 is not possible, im1b1N51x51 is if m_SizeNeighbourhood is high enough.

  • The maximum neighborhood size is 2*m_SizeNeighbourhood +1 so m_SizeNeighbourhood=20 is too low for a neighborhood of size 50.

Cédric

Yes it works … I was aware about the two points but I got lost in my too many parallel activities and I forgot them :frowning:

Thanks again Cédric for your help.

Best regards,

Mathieu