Inpainting is a set of image processing algorithms where damaged, missing or unwanted parts of an image are filled in using the neighbouring pixels. It can also be used to remove forground objects. This is a GUI application that helps you do just that. It has an interactive and user-friendly GUI for marking the regions of the images.
The frontend GUI is developed using PyQt. The backend inpainting operations are done using OpenCV library. Currently, OpenCV provides two algorithms for inpainting which are-
- cv2.INPAINT_TELEA: An image inpainting technique based on the fast marching method (Telea, 2004)
- cv2.INPAINT_NS: Navier-stokes, Fluid dynamics, and image and video inpainting (Bertalmío et al., 2001)
I've mentioned how you can quickly incorporate other inpainting algorithms with this GUI applications down below. Later on, I'll try to incorporate recent deep learning methods that perform way better than these classical image processing algorithms.
PyQt, Numpy, OpenCV3, qimage2ndarray
open up console in the project directory and enter this
python inpainter.py
Let's say you want to add the inpainting algorithm Deepfill. Here's how you can do it:
1. Open up editpage.py. Go to the function setupUi() of class Editpage. Add the following line at the very end of this function.
self.addInpaintingMethod("Deepfill")
This will add your new method's name in the dropdown selection list of the GUI editing page.
2. Now, in backend.py you can add a function that will call your inpainting algorithm.
def inpaint_deepfill(image, mask):
# call your custom algorithm for inpainting here and pass your image and mask to your algorithm
# return your output image with format numpy ndarray, for now I am just returning the input image
return image
3. Last thing you need to do is call your inpainting method in backend.py from editor.py. Go to the function inpaint() of editor.py. Add an elif condition which checks self._method
by your method's name and calls the corresponding inpainting method in backend.py
def inpaint(self):
img = np.array(self._current_image)
mask = rgb_view(self._mask)
if self._method == "Navier-Stokes":
output_rgb = backend.inpaint_cv2(img, mask,method="ns")
elif self._method == "Telea":
output_rgb = backend.inpaint_cv2(img, mask,method="telea")
elif self._method == "Deepfill": # add these lines
output_rgb = backend.inpaint_deepfill(img, mask) # to call your inpainting algorithm
else:
raise Exception("this inpainting method is not recognized!")
output = array2qimage(output_rgb)
Feel free to fork the project and contribute. You can incorporate recent deep learning methods, make the GUI more easy to use, include relevant photo editing features.