Python Forum
How to create mask for different types of images using opencv
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to create mask for different types of images using opencv
#1
I am trying to create a watermark remover in python using opencv. I have 10000 different images of 10 types of watermark in it, i have created an opencv that can remove watermark from 1 image when i create the mask of it. Right now i am creating mask using paint, how can i create mask of each watermarked image? Please consider the position of the watermark is same at each location. Below is my code and attached are the samples of watermark

import cv2
import matplotlib.pyplot as plt
import numpy as np
import random

def main():

    path = "D:\\imageRestoration\\"
    imgpath = path + "IndiaProperty.jpg"
    maskpath = path + "mask_India.jpg"
    img = cv2.imread(imgpath, 1)
    img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)

    mask = cv2.imread(maskpath, 0)    
    output1 = cv2.inpaint(img, mask, 5, cv2.INPAINT_TELEA)

    output2 = cv2.inpaint(img, mask, 5, cv2.INPAINT_NS)

    output = [img, mask, output1, output2 ]
    titles = ["Damaged Image","Mask", "TELEA", "NS"]

    cv2.imwrite("Damaged.jpg", cv2.cvtColor(output1, cv2.COLOR_RGB2BGR))

    for i in range(4):
        plt.subplot(2, 2, i+1)
        plt.imshow(output[i], cmap="gray")
        plt.title(titles[i])
        plt.xticks([])
        plt.yticks([])

        plt.show()


    if __name__ == "__main__":
        main()
enter image description here

Attached Files

Thumbnail(s)
       
Reply
#2
USE photoshop, btw thanks for the code verry helpful Heart
Reply
#3
Tricky! I remember doing something like this but I can't find what I made now!

There is a dedicated cv2 forum somewhere, probably better if you ask there!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Create your own Mnist images (NNW, MNIST) stalfilip 1 1,867 Dec-25-2019, 08:27 AM
Last Post: scidam

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020