Hi Salvatore,
Let's say you have two images A and B. If the sky background is the dominant feature in both images, this PixelMath expression does what you want if you apply it to B with the rescale result option disabled:
$T - med( $T ) + med( A )
Alternatively, you can impose a particular background value; for example, this expression:
$T - med( $T ) + 0.05
fixes a background value of 0.05 when applied to any image, again with rescale result disabled. This expression assumes that the original background is less than 0.05; otherwise the expression would lead to negative values, which would be truncated to zero.
You can also set the background in a more adaptive way. For example:
$T - med( $T ) + max( med( A ), med( B ) )
forces the largest background of A and B in both images.
Hope this helps.