'stretch the edges of any image data areas in python-opencv

I'm trying to stretch the edges of the image (duplicate pixels) around data (not transparent) areas in picture.

for example:

before: before

after - the red line is only for you to see the difference after: (the red line is only for you to see the difference)

note: it's important not to change the dimension of the image, i'ts being used for geographical needs.

I would like to hear any ideas or suggestions from you, code snippets will be welcomed.

thank you!



Solution 1:[1]

This problem is called image outpainting and You can see very advanced deep learning based solutions in papers on paperswithcode.com. Current state-of-art is given by Basile Van Hoorick in work Image Outpainting and Harmonization using Generative Adversarial Networks. Code with possibility of usage is placed in his github profile. See Usage section on github to know how to use it.

There are 3 models available to use in Pretrained models section:

  • G_art.pt: Artistic
  • G_nat.pt: Natural
  • G_rec.pt: Reconstruction loss only (no adversarial loss)

I believe You'll have to use transfer learning to train and use this architecture in Your use case.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1