def similarity(self, imgA, imgB):
"""Given two images of the same size, this function compute the similarity of the pixel
values. The function compute the differences of RGB values of a pixel and weight it with
the alpha value.
:param imgA: Image to be compared.
:param imgB: Image to be compared.
:returns:
Similarity of two images.
"""
#
# print(imgA)
# print(imgB)
delta_R = imgA[:,:,0] - imgB[:,:,0]
delta_G = imgA[:,:,1] - imgB[:,:,1]
delta_B = imgA[:,:,2] - imgB[:,:,2]
delta = (np.absolute(delta_R) + np.absolute(delta_G) + np.absolute(delta_B)) / 3
return (1 - np.mean(delta))
评论列表
文章目录