{"cells":[{"metadata":{},"cell_type":"markdown","source":"# Removing logos from pictures"},{"metadata":{},"cell_type":"markdown","source":"I'll take the wild guess that Monet didn't put huge white logos in the corners of his work. Therefore, I've been trying to remove these huge logos in the pictures before using them in order to improve my results.\n\nHowever, while doing research online I found that most of the codes already available need a mask of the logo to be removed. I don't really feel like manually making 500 masks on paint so I've been trying to find a way of removing (or at least blur) the logos.\n\nThis code is extremelly simple and does a pretty poor job at removing them as it changes other parts of the image besides the logo.\n\nNext steps? Maybe train another GAN to remove logos and watermarks?"},{"metadata":{},"cell_type":"markdown","source":"# 1 - Image with a logo"},{"metadata":{"trusted":true},"cell_type":"code","source":"import cv2\nimport numpy as np\nimport matplotlib.pyplot as plt\n\nimg = cv2.imread('/kaggle/input/gan-getting-started/photo_jpg/03a2b7ce83.jpg')\nimg = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) \n\nplt.imshow(img)\nplt.axis('off')","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# Mask"},{"metadata":{"trusted":true},"cell_type":"code","source":"lower = np.array([100, 100, 100])\nupper = np.array([255, 255, 225])\nshapeMask = cv2.inRange(img, lower, upper)\n\nshapeMask[40:215,40:215]=0\n\nplt.imshow(shapeMask)\nplt.axis('off')","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# Image with the mask applied and smoothed"},{"metadata":{"trusted":true},"cell_type":"code","source":"dst = cv2.inpaint(img,shapeMask,3,cv2.INPAINT_TELEA)\n\nplt.imshow(dst)\nplt.axis('off')","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# 2 - Image without logo"},{"metadata":{"trusted":true},"cell_type":"code","source":"img = cv2.imread('/kaggle/input/gan-getting-started/photo_jpg/03be88270f.jpg')\nimg = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) \n\nplt.imshow(img)\nplt.axis('off')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"lower = np.array([100, 100, 100])\nupper = np.array([255, 255, 225])\nshapeMask = cv2.inRange(img, lower, upper)\n\nshapeMask[40:215,40:215]=0\n\nplt.imshow(shapeMask)\nplt.axis('off')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"dst = cv2.inpaint(img,shapeMask,3,cv2.INPAINT_TELEA)\n\nplt.imshow(dst)\nplt.axis('off')","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"As I said, pretty bad."}],"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat":4,"nbformat_minor":4}