How to create mask for different types of images using opencv - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Data Science (https://python-forum.io/forum-44.html) +--- Thread: How to create mask for different types of images using opencv (/thread-9748.html) |
How to create mask for different types of images using opencv - Prince_Bhatia - Apr-26-2018 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 RE: How to create mask for different types of images using opencv - island747 - Jul-25-2023 USE photoshop, btw thanks for the code verry helpful RE: How to create mask for different types of images using opencv - Pedroski55 - Jul-29-2023 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! |