{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "This is an [jupyter](http://jupyter.org) notebook.\n", "Lectures about Python, useful both for beginners and experts, can be found at http://scipy-lectures.github.io.\n", "\n", "Open the notebook by (1) copying this file into a directory, (2) in that directory typing \n", "jupyter-notebook\n", "and (3) selecting the notebook." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Poisson Image Editing" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Seamless Image Cloning\n", "\n", "***\n", " A notebook by ***Dhruv Ilesh Shah***\n", "***\n", "\n", "In this exercise, we will learn and implement Seamless Image Cloning by employing the Poisson Solver.\n", "\n", "***Packages Used:*** Python 2.7, Numpy, Matplotlib, openCV 3.1.0, `gimp 2.8` (recommended)\n", "\n", "*openCV has been used only for Image importing purposes, and can be replaced by PIL as well. Similarly, Matplotlib has been used only for displaying results inline.*\n", "***" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Motivation\n", "\n", "Image cloning and morphing have been some of the most common purposes of Image Processing and editing. Most of us have used these tools at a very abstract level through packages like Photoshop or GIMP etc. But have you ever thought about what goes into actuating this process? Here we explain the math behind the idea and the algorithm for seamlessly cloning an image *(or a portion thereof)* onto another image. The dictionary defines ***seamless*** as *smooth and without seams or obvious joins* and hence our objective would be to make an image as smooth and natural as possible.\n", "\n", "Soon after, we'll get our hands dirty by actually coding the algorithm and running it on a sample image to achieve the results for oursef. Towards the end, we will also look at the various parameters that can be tweaked to achieve better results.\n", "***" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Understanding Seamless Cloning\n", "\n", "Say you want to clone/morph a portion of image 1 onto a position on image 2. The simplest way to start off is to simply **paste** that portion of image on the other. But well, as you'd expect, the border has a very *sharp* change in features (known as gradient) and hence we can easily claim that the image is forged. What we need is a way to create a softer gradient, so that the image looks more natural.\n", "\n", "![Seamless Cloning Example](images/seamless_cloning_ex.jpg)\n", "