import cv2 import numpy as np import os # Set the directory where images are stored image_dir = 'path_to_images/' output_dir = 'path_to_output/' # Load one image to manually get the logo coordinates sample_image = cv2.imread(os.path.join(image_dir, 'sample_image.jpg')) # Set the coordinates of the logo (x, y, width, height) logo_coords = (x, y, w, h) # Create a mask for the logo mask = np.zeros_like(sample_image[:, :, 0]) # Same size as image, single channel cv2.rectangle(mask, (logo_coords[0], logo_coords[1]), (logo_coords[0] + logo_coords[2], logo_coords[1] + logo_coords[3]), 255, -1) # Function to remove logo using inpainting def remove_logo(image, mask): # Inpaint the area of the logo result = cv2.inpaint(image, mask, 3, cv2.INPAINT_TELEA) return result # Process all images for filename in os.listdir(image_dir): if filename.endswith('.jpg') or filename.endswith('.png'): img = cv2.imread(os.path.join(image_dir, filename)) result = remove_logo(img, mask) cv2.imwrite(os.path.join(output_dir, filename), result) print("Logo removal completed for all images.")