from PIL import Image, ImageOps
import matplotlib.pyplot as plt
# Load the image
image_path = '/mnt/data/1000005810.jpg'
img = Image.open(image_path)
# Convert to RGB just in case
img = img.convert('RGB')
# Crop the face region roughly (manual approximation for this image)
width, height = img.size
center_x = width // 2
center_y = height // 2
# We'll take a square crop around the center for symmetry check
crop_size = min(width, height) // 2
left = center_x - crop_size // 2
top = center_y - crop_size // 2
right = center_x + crop_size // 2
bottom = center_y + crop_size // 2
face_crop = img.crop((left, top, right, bottom))
# Split into left and right halves
face_width, face_height = face_crop.size
left_half = face_crop.crop((0, 0, face_width // 2, face_height))
right_half = face_crop.crop((face_width // 2, 0, face_width, face_height))
# Mirror the halves to compare
left_mirror = ImageOps.mirror(left_half)
right_mirror = ImageOps.mirror(right_half)
# Combine for visualization: original halves mirrored
left_combo = Image.new('RGB', (face_width, face_height))
left_combo.paste(left_half, (0, 0))
left_combo.paste(left_mirror, (face_width // 2, 0))
right_combo = Image.new('RGB', (face_width, face_height))
right_combo.paste(right_mirror, (0, 0))
right_combo.paste(right_half, (face_width // 2, 0))
# Plot original crop and the mirrored versions
fig, axes = plt.subplots(1, 3, figsize=(12, 6))
axes[0].imshow(face_crop)
axes[0].set_title("Original Face Crop")
axes[0].axis("off")
axes[1].imshow(left_combo)
axes[1].set_title("Left Side Mirrored")
axes[1].axis("off")
axes[2].imshow(right_combo)
axes[2].set_title("Right Side Mirrored")
axes[2].axis("off")
plt.tight_layout()
plt.show()