Giter Site home page Giter Site logo

poisson-blending-in-5lines's Introduction

poisson-blending-in-5lines

This project is a simple implementation of Poisson Blending algorithm whose code size is 5 lines. It uses scipy and contain only esssential logics. i.e. input validations are missing and single data type and channel are support.

The contants of poisson_blend.py are following. You can see that there are only 5 lines. They are all of out Poisson Blending algorithm. In fact, They are optimized for code size. It means that there are some redundant computations.

from scipy.ndimage import laplace
def poisson_blend(target_img, src_img, mask_img, iter: int = 1024):
    for _ in range(iter):
        target_img = target_img + 0.25 * mask_img * laplace(target_img - src_img)
    return target_img.clip(0, 1)

Above codes generate the folloing right image with three left images as its input. These input images area source image, mask image and target image from left to right.

output of poisson blending

Feature

  • Only importing gradients method support
  • Mixigin gradients methods is not support
  • Convergence checking of jacobi method is not suuport

Launch example notebook

$ git clone https://github.com/ar90n/poisson-blending-in-5lines.git
$ cd poisson-blending-in-5lines
$ poetry install
$ poetry run jupytext --to notebook ./notebook/example.py ./notebook/example.ipynb
$ poetry run jupyter notebook ./notebook/example.ipynb

References

License

This software is released under the Apache License, see LICENSE.

poisson-blending-in-5lines's People

Contributors

ar90n avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

rafaelperez

poisson-blending-in-5lines's Issues

[Question] mask_img == 255

Hi, Thank you for the nice implementation.

I have a question about your code, that is Line 26 of notebook.example.py
The source and the target are normalized by 255. But the mask becomes boolean [False, True].
I think this makes the difference as follows:
vinci_result=bool
[Boolean, mask_img == 255]
vinci_result
[Float, mask_img / 255]

Can you explain this?
Just to stop the blur of the mask? Or is there any more reason?
Why did you set it as Boolean? On the surface, the boolean setting looks better.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.