Art_class.py 文件源码

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

项目:artorithmia 作者: alichtner 项目源码 文件源码
def extract_symmetry(self):
        """
        Calculate the symmetry of the image by substracting left from right.

        Input:  None
        Output: None
        """
        # currently this is only for horizontal symmetry
        if len(self.image.shape) == 3:
            height, width, _ = self.image.shape
        else:
            height, width = self.image.shape
        if width % 2 != 0:
            width -= 1
            pixels = height * width
            left = self.image[:, :width/2]
            right = self.image[:, width/2:-1]
        else:
            pixels = height * width
            left = self.image[:, :width/2]
            right = self.image[:, width/2:]
        left_gray = color.rgb2gray(left)
        right_gray = color.rgb2gray(right)
        self.symmetry = np.abs(left_gray -
                               np.fliplr(right_gray)).sum()/(pixels/1.*2)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号