Skip to content

Commit

Permalink
BAM!
Browse files Browse the repository at this point in the history
  • Loading branch information
Erkaman committed Feb 4, 2018
0 parents commit d9e11cd
Show file tree
Hide file tree
Showing 333 changed files with 124,655 additions and 0 deletions.
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
cmake_minimum_required (VERSION 3.8)
project (poisson_blend)

set (CMAKE_CXX_STANDARD 11)

include_directories(src/)

add_executable(poisson_blend src/main.cpp src/lodepng.cpp)

set_target_properties(poisson_blend PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}")
21 changes: 21 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2018 Eric Arnebäck

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
172 changes: 172 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
# poisson_blend - A simple, readable implementation of Poisson Blending

An implementation of Poisson Blending, that demonstrates the concepts explained in [my article](https://erkaman.github.io/posts/poisson_blending.html).

To use the progam, you specify a source image and a target image. The source image is seamlessly copied and pasted
into the target image, at some specified pixel location.

By running the command line

```
poisson_blend -source img/kitten.png -target img/library.png -mask img/kittenmask.png -output result.png -mx 280 -my 340
```

An image of a kitten can be seamlessly copied and pasted into the library, at the position (280, 340), as can be seen below.
The mask specifies which pixels of the kitten should actually be copied and pasted. The remaining pixels are ignored.
Note that only pure red pixels of RGB color `(255,0,0)` are considered part of the mask.

The result of the above command line can be seen below:


<table><thead>
</thead><tbody>
<tr>
<td align="center"><img src="img/kitten.png" alt="kitten" width="37" height="46"></td>
<td align="center"><img src="img/library.png" alt="library" width="240" height="164"></td>
<td align="center"><img src="img/kittenmask.png" alt="kitten mask" width="37" height=46"></td>
<td align="center"><img src="img/kitten_library.png" alt="kitten mask" width="240" height="164"></td>
</tr>
<tr>
<td align="center">source</td>
<td align="center">target</td>
<td align="center">mask</td>
<td align="center">result</td>
</tr>
</tbody></table>

## Gallery

A small gallery of images made with this program are presented below.

<table><thead>
</thead><tbody>
<tr>
<td align="center"><img src="img/penguin.png" alt="penguin" width="49" height="74"></td>
<td align="center"><img src="img/library.png" alt="library" width="240" height="164"></td>
<td align="center"><img src="img/penguin_library.png" alt="penguin library" width="240" height="164"></td>
</tr>
<tr>
<td align="center">source</td>
<td align="center">target</td>
<td align="center">result</td>
</tr>
</tbody></table>


<table><thead>
</thead><tbody>
<tr>
<td align="center"><img src="img/moon.png" alt="moon" width="194" height="129"></td>
<td align="center"><img src="img/gothenburg.png" alt="gothenburg" width="204" height="163"></td>
<td align="center"><img src="img/moon_gothenburg.png" alt="moon gothenburg" width="204" height="163"></td>
</tr>
<tr>
<td align="center">source</td>
<td align="center">target</td>
<td align="center">result</td>
</tr>
</tbody></table>

<table><thead>
</thead><tbody>
<tr>
<td align="center"><img src="img/penguin.png" alt="penguin" width="49" height="74"></td>
<td align="center"><img src="img/beach.png" alt="beach" width="240" height="164"></td>
<td align="center"><img src="img/penguin_beach.png" alt="penguin beach" width="240" height="164"></td>
</tr>
<tr>
<td align="center">source</td>
<td align="center">target</td>
<td align="center">result</td>
</tr>
</tbody></table>


<table><thead>
</thead><tbody>
<tr>
<td align="center"><img src="img/eagle.png" alt="eagle" width="166" height="135"></td>
<td align="center"><img src="img/liberty.png" alt="liberty" width="240" height="180"></td>
<td align="center"><img src="img/eagle_liberty.png" alt="eagle liberty" width="240" height="180"></td>
</tr>
<tr>
<td align="center">source</td>
<td align="center">target</td>
<td align="center">result</td>
</tr>
</tbody></table>

<table><thead>
</thead><tbody>
<tr>
<td align="center"><img src="img/watereagle.png" alt="water eagle" width="148" height="55"></td>
<td align="center"><img src="img/lake.png" alt="lake" width="270" height="202"></td>
<td align="center"><img src="img/watereagle_lake.png" alt="water eagle lake" width="270" height="202"></td>
</tr>
<tr>
<td align="center">source</td>
<td align="center">target</td>
<td align="center">result</td>
</tr>
</tbody></table>


<table><thead>
</thead><tbody>
<tr>
<td align="center"><img src="img/balloon.png" alt="balloon" width="93" height="112"></td>
<td align="center"><img src="img/collosseum.png" alt="colosseum" width="266" height="199"></td>
<td align="center"><img src="img/balloon_collosseum.png" alt="balloon colosseum" width="266" height="199"></td>
</tr>
<tr>
<td align="center">source</td>
<td align="center">target</td>
<td align="center">result</td>
</tr>
</tbody></table>

## Building

The only dependencies are [lodepng](https://github.com/lvandeve/lodepng) and [Eigen](http://eigen.tuxfamily.org/index.php?title=Main_Page).
Both of which are included within this repository.

We use CMake for building. If on Linux or OS X, you can build it in the terminal by doing something like:

```
mkdir build && cd build && cmake .. && make
```

If on Windows, create a `build/` folder, and run `cmake ..` from
inside that folder. This will create a visual studio solution(if you
have visual studio). Launch that solution, and then simply compile the
project named `poisson_blend`.

## Image Sources

Below we list the soures of all images that we used in the gallery.

- [kitten.png](https://www.flickr.com/photos/rondeboom/9296207416/)
- [library.png](https://www.flickr.com/photos/uowarchives/5513608992/)
- [gothenburg.png](https://www.flickr.com/photos/belola/4257701496/)
- [moon.png](https://www.flickr.com/photos/dcmaster/7533083314/)
- [penguin.png](https://www.flickr.com/photos/141457238@N03/26834524313/)
- [beach.png](https://www.flickr.com/photos/notcub/2568905280)
- [liberty.png](https://www.flickr.com/photos/reinholdbehringer/3698799772/)
- [eagle.png](https://www.flickr.com/photos/bobengr/32130057682/)
- [lake.png](https://www.flickr.com/photos/74444001@N00/62802646)
- [watereagle.png](https://www.flickr.com/photos/mickthompson/16549423644)
- [collosseum.png](https://www.flickr.com/photos/sandravoetbal/4075677218)
- [balloon.png](https://www.flickr.com/photos/prestonkemp/4655399966/)













Binary file added img/balloon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/balloon_collosseum.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/balloonmask.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/beach.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/collosseum.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/eagle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/eagle_liberty.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/eaglemask.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/gothenburg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/kitten.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/kitten_library.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/kittenmask.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/lake.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/liberty.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/library.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/moon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/moon_gothenburg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/moonmask.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/penguin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/penguin_beach.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/penguin_library.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/penguinmask.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/poissson_blend.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/watereagle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/watereagle_lake.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/watereaglemask.png
19 changes: 19 additions & 0 deletions src/Eigen/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
include(RegexUtils)
test_escape_string_as_regex()

file(GLOB Eigen_directory_files "*")

escape_string_as_regex(ESCAPED_CMAKE_CURRENT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")

foreach(f ${Eigen_directory_files})
if(NOT f MATCHES "\\.txt" AND NOT f MATCHES "${ESCAPED_CMAKE_CURRENT_SOURCE_DIR}/[.].+" AND NOT f MATCHES "${ESCAPED_CMAKE_CURRENT_SOURCE_DIR}/src")
list(APPEND Eigen_directory_files_to_install ${f})
endif()
endforeach(f ${Eigen_directory_files})

install(FILES
${Eigen_directory_files_to_install}
DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen COMPONENT Devel
)

install(DIRECTORY src DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen COMPONENT Devel FILES_MATCHING PATTERN "*.h")
41 changes: 41 additions & 0 deletions src/Eigen/Cholesky
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra.
//
// This Source Code Form is subject to the terms of the Mozilla
// Public License v. 2.0. If a copy of the MPL was not distributed
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.

#ifndef EIGEN_CHOLESKY_MODULE_H
#define EIGEN_CHOLESKY_MODULE_H

#include "Core"

#include "src/Core/util/DisableStupidWarnings.h"

/** \defgroup Cholesky_Module Cholesky module
*
*
*
* This module provides two variants of the Cholesky decomposition for selfadjoint (hermitian) matrices.
* Those decompositions are also accessible via the following methods:
* - MatrixBase::llt()
* - MatrixBase::ldlt()
* - SelfAdjointView::llt()
* - SelfAdjointView::ldlt()
*
* \code
* #include <Eigen/Cholesky>
* \endcode
*/

#include "src/Cholesky/LLT.h"
#include "src/Cholesky/LDLT.h"
#ifdef EIGEN_USE_LAPACKE
#include "src/misc/lapacke.h"
#include "src/Cholesky/LLT_LAPACKE.h"
#endif

#include "src/Core/util/ReenableStupidWarnings.h"

#endif // EIGEN_CHOLESKY_MODULE_H
/* vim: set filetype=cpp et sw=2 ts=2 ai: */
48 changes: 48 additions & 0 deletions src/Eigen/CholmodSupport
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra.
//
// This Source Code Form is subject to the terms of the Mozilla
// Public License v. 2.0. If a copy of the MPL was not distributed
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.

#ifndef EIGEN_CHOLMODSUPPORT_MODULE_H
#define EIGEN_CHOLMODSUPPORT_MODULE_H

#include "SparseCore"

#include "src/Core/util/DisableStupidWarnings.h"

extern "C" {
#include <cholmod.h>
}

/** \ingroup Support_modules
* \defgroup CholmodSupport_Module CholmodSupport module
*
* This module provides an interface to the Cholmod library which is part of the <a href="http://www.suitesparse.com">suitesparse</a> package.
* It provides the two following main factorization classes:
* - class CholmodSupernodalLLT: a supernodal LLT Cholesky factorization.
* - class CholmodDecomposiiton: a general L(D)LT Cholesky factorization with automatic or explicit runtime selection of the underlying factorization method (supernodal or simplicial).
*
* For the sake of completeness, this module also propose the two following classes:
* - class CholmodSimplicialLLT
* - class CholmodSimplicialLDLT
* Note that these classes does not bring any particular advantage compared to the built-in
* SimplicialLLT and SimplicialLDLT factorization classes.
*
* \code
* #include <Eigen/CholmodSupport>
* \endcode
*
* In order to use this module, the cholmod headers must be accessible from the include paths, and your binary must be linked to the cholmod library and its dependencies.
* The dependencies depend on how cholmod has been compiled.
* For a cmake based project, you can use our FindCholmod.cmake module to help you in this task.
*
*/

#include "src/CholmodSupport/CholmodSupport.h"

#include "src/Core/util/ReenableStupidWarnings.h"

#endif // EIGEN_CHOLMODSUPPORT_MODULE_H

Loading

0 comments on commit d9e11cd

Please sign in to comment.