agent.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:ccmas-imgen 作者: ccmas-imgen 项目源码 文件源码
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))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号