{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Problem 7 Image Stitching\n", "\n", "This section of the notebook continues the image stiching problem. Be sure to have a `figures` folder in the same directory as the notebook. The `figures` folder should contain the files:\n", "\n", " Berkeley_banner_1.jpg\n", " Berkeley_banner_2.jpg\n", " stacked_pieces.jpg\n", " lefthalfpic.jpg\n", " righthalfpic.jpg\n", " \n", "Note: This structure is present in the provided HW2 zip file." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Run the next block of code before proceeding\n" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false, "tags": [ "worksheet-0" ] }, "outputs": [], "source": [ "import numpy as np\n", "import numpy.matlib\n", "import matplotlib.pyplot as plt\n", "from mpl_toolkits.mplot3d import Axes3D\n", "from numpy import pi, cos, exp, sin\n", "import matplotlib.image as mpimg\n", "import matplotlib.transforms as mtransforms\n", "\n", "\n", "%matplotlib inline\n", "\n", "#loading images\n", "image1=mpimg.imread('figures/Berkeley_banner_1.jpg')\n", "image1=image1/255.0\n", "image2=mpimg.imread('figures/Berkeley_banner_2.jpg')\n", "image2=image2/255.0\n", "image_stack=mpimg.imread('figures/stacked_pieces.jpg')\n", "image_stack=image_stack/255.0\n", "\n", "\n", "image1_marked=mpimg.imread('figures/lefthalfpic.jpg')\n", "image1_marked=image1_marked/255.0\n", "image2_marked=mpimg.imread('figures/righthalfpic.jpg')\n", "image2_marked=image2_marked/255.0\n", "\n", "def euclidean_transform_2to1(transform_mat,translation,image,position,LL,UL):\n", " new_position=np.round(transform_mat.dot(position)+translation)\n", " new_position=new_position.astype(int)\n", "\n", " \n", " if (new_position>=LL).all() and (new_position