PixelMath is a pixel-by-pixel process. The med(image) function returns the median of the specified image ($T by default), which remains invariant during PixelMath execution.
To compute the median of the sum of two or more images you need a script. Such a script is rather easy to write though:
#include <pjsr/ImageOp.jsh>
#include <pjsr/StdButton.jsh>
function MedianOfTwoAdded( img1, img2 )
{
var imgs = new Image;
imgs.assign( img1 );
imgs.apply( img2, ImageOp_Add );
var m = imgs.median();
imgs.free();
return m;
}
function main()
{
var vA = View.viewById( "A" );
var vB = View.viewById( "B" );
if ( vA.isNull || vB.isNull )
{
(new MessageBox( "Source image(s) not available.",
TITLE, StdIcon_Error, StdButton_Ok )).execute();
return;
}
console.writeln( format( "%.6f\n", MedianOfTwoAdded( vA.image, vB.image ) ) );
console.show();
}
main();
Just replace "A" and "B" with the identifiers of your images (or rename your images to "A" and "B"), and run the script. If more than a few images are required, the above script is easily generalizable to image lists of arbitrary length using arrays.