Subtracting Spectrum (S2MSI)

Hello everyone
Please, I need some help.
I´m trying to calculate the average of 5 pixels from water, then subtract this average in the whole scene (S2MSI), for all bands.
Do someone has a tip of advice on how to do this in SNAP?
Thank you very much!
Amália

Is the average for specific fixed 5 pixels so you are subtracting the same value from all pixels in the scene or a moving window so are subtracting different values from each pixel in your scene?

The average is for specific fixed 5 pixels of the water, then subtracting the same value from all pixels in the scene

If you want to do a Dark Object Subtraction, there is a specific operator for this.
In Optical / Pre-Processing in the menu. You need to have the S3TBX installed.

But you can also calculate the average for the 5 pixels.
This can be done by creating a mask. Draw a geometry containing the five pixels.
Then you can use the statistics tool to compute the statistic for the masked region.