Hi,

I am trying to implement a pixel-wise operation with BandMathX. Let’s say we have a one-dimensional image X, I want to compute for every pixel

where x_i is the pixel to be processed, \bar{x} is the mean value of X, N_i is the neighborhood of x_i (e.g., a square window of size 3x3), j \in N_i is the neighbors of x_i and \sigma^2_{x} is the variance of the image.

In order to use BandMathX, the expression can be written like this:

where |N_i| is the number of neighbors of x_i and \bar{x}_i is the local mean in the neighborhood of x_i.

If we consider a square window of size 3, I have tried the following expression (among others …):

```
9 * (im1b1 - im1b1Mean) * (mean(im1b1N3x3) - im1b1Mean) / im1b1Var
```

But I got this error

```
RuntimeError: Exception thrown in otbApplication Application_Execute: /home/mfauvel/Iota2InstallDir/iota2/scripts/install/OTB/OTB/Modules/Filtering/MathParserX/src/otbParserX.cxx:235:
itk::ERROR: ParserXImpl(0x12d7400):
Message: Can't evaluate function/operator "-": Argument 1 of function/operator "-" is of type 'm' whereas type 'c' was expected.
Formula: 9 * (im1b1 - im1b1Mean) * (mean(im1b1N3x3) - im1b1Mean) / im1b1Var
Token: -
Position: 43
```

I understand that `mean(im1b13x3)`

is not of the same type than `im1b1Mean`

. I read the cookbook and I don’t see where I am wrong.

After several tries, I suspect that `mean(im1b1N3x3)`

cannot be used in combination with scalar operation.

So my question: is it possible to perform such operation in one pass ? I can pre-compute the local mean, but it’s less elegant

Mathieu