For images with real data types, pixel values ββcan be negative, and these three operations are equivalent:
real1 = Image[RandomReal[1, {10, 10}]]; real2 = Image[RandomReal[1, {10, 10}]]; ImageData[ImageDifference[real1, real2]] == Abs@ImageData [ImageSubtract[real1, real2]] == Abs[ImageData[real1] - ImageData[real2]] Out[4]= True
But this does not apply to images of integer data types. This is due to the fact that only positive values ββcan be stored in such images, and negative subtraction results are trimmed to zero in the output image:
int1 = Image[RandomInteger[255, {10, 10}], "Byte"]; int2 = Image[RandomInteger[255, {10, 10}], "Byte"];
This is still True :
ImageData[ImageDifference[int1, int2]] == Abs[ImageData[int1] - ImageData[int2]]
But these two are different due to clipping:
ImageData[ImageDifference[int1, int2]] == Abs@ImageData [ImageSubtract[int1, int2]]
Converting both input images to the data type βRealβ or βReal32β would be less cryptic.
source share