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)
评论列表
文章目录