Home Restore Damged Photos
Post
Cancel

Restore Damged Photos

How to Restore Damaged Photos?

We can restore damaged photos by preparing two images one with a damaged image and the other with an image that the damaged areas(want to restore) are marked manually. Note that the color of marked area is better to be white.
Then, apply cv2.inpaint(src, inpaintMask, dst, inpaintRadius, flags) where:

  • src : Damaged image.

  • inpaintMask : The image that mark manually.

  • dst : Output image.

  • inpaintRadius : Radius of a circular neighborhood of each point inpainted that is considered by the algorithm.

  • flags : Inpainting method that is cv2.INPAINT_NS or cv2.INPAINT_TELEA





Steps of Restoring image.



  1. Prepare 2 images.

  2. Thresholding the marked image.

  3. Make our marks thicker by cv2.dilate(src, dst, kernel, anchor, iterations) where:

    • src : Input image.

    • dst : Output image.

    • kernel : Structuring element used for dilation.

    • anchor : Position of the anchor within the element. Default = (-1, -1)(means the anchor is at the element center.)

    • iterations : number of times dilation is applied.

  4. Get the restored image by cv2.inpaint().





Implementation

This post is licensed under CC BY 4.0 by the author.