Subtraction Operator

Original Images ( Operands )

Image 1 Image 2
operandOne operandTwo

Details

Performs subtraction operation on two pixel intensities ( from two different images ), not difference operation i.e. absolute subtraction, so putting operand images in different order may result into different images

Image_1 - Image_2 != Image_2 - Image_1

It’s pretty evident that after application of subtraction operator on two equal sized images, resulting pixel intensity values may be out of range ( > 255 ), which can’t be stored in a 24-bit RGB image. For putting pixel intensities in [0, 255] range, we can consider either of following two ways

It doesn’t matter how you place operands, when you want to scale pixel intensities, because before scaling pixel intensity absolute value to be taken only.

Resulting Image = Image_1 - Image_2

Clipped Scaled
result result

Resulting Image = Image_2 - Image_1

Clipped Scaled
result result