def make_diff_image(im1, im2):
 ds = im1.shape
 es = im2.shape
 diff = np.empty((max(ds[0], es[0]), max(ds[1], es[1]), 4), dtype=int)
 diff[..., :3] = 128
 diff[..., 3] = 255
 diff[:ds[0], :ds[1], :min(ds[2], 3)] += im1[..., :3]
 diff[:es[0], :es[1], :min(es[2], 3)] -= im2[..., :3]
 diff = np.clip(diff, 0, 255).astype(np.ubyte)
 return diff

def make_diff_image ( im1 , im2 ) : ds = im1 . shape es = im2 . shape diff = np . empty ( ( max ( ds [ 0 ] , es [ 0 ] ) , max ( ds [ 1 ] , es [ 1 ] ) , 4 ) , dtype = int ) diff [ ... , : 3 ] = 128 diff [ ... , 3 ] = 255 diff [ : ds [ 0 ] , : ds [ 1 ] , : min ( ds [ 2 ] , 3 ) ] += im1 [ ... , : 3 ] diff [ : es [ 0 ] , : es [ 1 ] , : min ( es [ 2 ] , 3 ) ] -= im2 [ ... , : 3 ] diff = np . clip ( diff , 0 , 255 ) . astype ( np . ubyte ) return diff
return image array showing the differences between im1 and im2 .