- comparer = Comparer(refImage, srcImage)
- precision = comparer.precision()
+ if isinstance(refImage, Image.Image) and isinstance(srcImage, Image.Image):
+ # Using PIL
+ numpyImages = False
+ comparer = Comparer(refImage, srcImage)
+ precision = comparer.precision()
+ else:
+ # Using numpy (for floating point images)
+ # TODO: drop PIL when numpy path becomes general enough
+ import numpy
+ assert not isinstance(refImage, Image.Image)
+ assert not isinstance(srcImage, Image.Image)
+ numpyImages = True
+ assert refImage.shape == srcImage.shape
+ diffImage = numpy.square(srcImage - refImage)
+ match = numpy.all(diffImage == 0)
+ if match:
+ precision = 24
+ else:
+ precision = 0