2

I'd like to remove certain elements from the images because I receive a lot of products with images that don't suit my needs. In fact, some sites send me their xml files containing products with images, but these images may contain the name of their site written in the top right-hand corner or all over the place (for example). I'd just like to modify these images so that I don't see these names anymore (they're probably copyrighted but I have their authorization to modify them). I've seen that you can apply certain caches to certain parts of the image in python, but when the site name is all over the image it's more complex. Is there a way around this? Thanks in advance

Here's my code:

    response = requests.get(item["Image"])
    image_data = response.content
    image_originale = Image.open(BytesIO(image_data))
    image_originale.save("./imageItem.jpg")

    image = cv2.imread('./imageItem.jpg')
    # Dimensions de l'image
    hauteur, largeur, _ = image.shape
    # Coordonnées et dimensions de la région à masquer
    # x = largeur - (largeur // 4)  # Coin supérieur droit de l'image
    x = largeur - (largeur // 4)
    y = 0  # Coin supérieur gauche de l'image
    largeur_zone = largeur // 4
    hauteur_zone = hauteur // 6
    # Créer un masque pour la région à masquer (tout en noir sauf la zone à remplacer)
    masque = np.zeros(image.shape[:2], dtype=np.uint8)
    masque[y:y+hauteur_zone, x:x+largeur_zone] = 255
    # Remplacer la zone masquée par des pixels blancs
    image_masquee = image.copy()
    image_masquee[y:y+hauteur_zone, x:x+largeur_zone] = 255
    # Appliquer le masque à l'image d'origine
    resultat = cv2.bitwise_and(image, image, mask=masque)
    # Fusionner l'image masquée avec l'image d'origine
    resultat_final = cv2.bitwise_or(resultat, image_masquee)
    # Afficher l'image résultante
    cv2.imshow('Image résultante', resultat_final)
    cv2.waitKey(0)
    cv2.destroyAllWindows()
Nicolas
  • 107
  • 10
  • Maybe this project is what you are looking for? https://github.com/zuruoke/watermark-removal – Jonas Jul 27 '23 at 13:50
  • 1
    Or take a look at this post https://stackoverflow.com/questions/66775536/removing-transparent-watermark-from-an-image-python – Jonas Jul 27 '23 at 13:53

0 Answers0