1
Map Gab / Re: Jurassic Park (Sega Megadrive/Genesis)
« on: March 07, 2025, 07:31:25 am »
cool, love the big brachiosaur head. the two-version approach is nice also!
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
from PIL import Image
import numpy as np
def compare_images(image_path1, image_path2, output_path):
img1 = Image.open(image_path1)
img2 = Image.open(image_path2)
if img1.size != img2.size:
raise ValueError("Images must be the same size.")
# Convert images to numpy arrays
arr1 = np.array(img1)
arr2 = np.array(img2)
if arr1.shape != arr2.shape:
raise ValueError("Images must have the same number of channels.")
# Find where pixels are the same (set to black) and different (set to red)
diff = np.zeros_like(arr1)
mask = np.any(arr1 != arr2, axis=-1) # True where pixels differ
diff[..., 0] = mask * 255 # Red channel
diff[..., 1] = 0 # Green channel
diff[..., 2] = 0 # Blue channel
# Convert back to image
output_img = Image.fromarray(diff)
output_img.save(output_path)