{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "source": [
    "# Frame difference vs motion estimation + residual"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false,
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "import matplotlib.image as mpimg\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAfwAAAEPCAYAAACnVHakAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAAPYQAAD2EBqD+naQAAIABJREFUeJzt3Xu0HFWd6PHvDyEJBDAuMGQQEQiEQUXR8DCjiYk4QGR8\n4gPGx5WHFx3kIuMVhquOjo4zXhkRQViylgzq4AuD4AuCvEUeRgPB6xAeYkJ4RgJ5nARCIOz7R9U5\n6e6cc3L6nO6q7q7vZ61eqd5V3fuXPv3rX9XeVd2RUkKSJPW2rcoOQJIktZ8FX5KkCrDgS5JUARZ8\nSZIqwIIvSVIFWPAlSaoAC74kSRVgwZckqQIs+JIkVYAFv4tExIERcXNErI2IjRHxqrJjktRe5r1a\nxYLfJSJia2Ae8CLgE8AHgQdKDaoNImLXiLgkIlZGxOqIuDwi9iw7LqkMVcj7iJgWEV/Ld2qejojn\nI2L3suPqRVuXHYBGbCqwO3B8SumisoNph4iYCNwA7AD8K/Ac8I/ADRFxQEppZYnhSWXo+bwHZgAf\nB+7KbweUG07v8gi/e+yS/7t6uI0iYrsCYmmXk8g+4I5MKX01pfR14DBgV+CTpUYmlaMKef9TYFJK\n6dXA98sOppdZ8LtARFxEduSbgHn5kNd1EXFRRPRFxF4RcUVErAEuzh/zhoj4UUQ8EBHrI2JZRJwV\nERManvvb+XO8NCJ+kS8/GBH/kK/fPyKuzecPl0bEMYPE98KIODvvY31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jwJUmqgP8P\nsvkNMzrpBmYAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7f837f59e828>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# loading the frames\n",
    "frame_0 = mpimg.imread('i/smw_background_ball_1.png')\n",
    "frame_1 = mpimg.imread('i/smw_background_ball_2.png')\n",
    "# showing the frames\n",
    "f, (plt1, plt2) = plt.subplots(1, 2)\n",
    "plt1.set_title('frame_0');plt1.imshow(frame_0,interpolation='nearest');\n",
    "plt2.set_title('frame_1');plt2.imshow(frame_1,interpolation='nearest');"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Frame difference"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAWEAAAFiCAYAAAAna2l5AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAAPYQAAD2EBqD+naQAAGANJREFUeJzt3X+Q5HV95/Hni187Aq6UwO7eHP6AIJ6JtiCK4U4wkUTM\nWJh4WEKiZQmlpRwoolVyKBYq6FGm5LhNcKN1XkWzMSmyFqfWzYEKkSCCW4DSeiI5I4IwYW9BZFdg\nWFg+98e3l+rp7p3dnp2Zz/TwfFR11fb7+/luv78726/5zOf77e+klIIkqY69ajcgSc9khrAkVWQI\nS1JFhrAkVWQIS1JFhrAkVWQIS1JFhrAkVWQIS1JFhrAkVbRgIZzk7CR3JXksyc1JXrVQryVJo2pB\nQjjJacBngYuAY4DbgWuSHLIQrydJoyoLcQOfJDcD3y+lnNt5HuCXwNpSymd6xh4MnAz8Apie92Yk\nafGNAS8ErimlPDjbwH3m+5WT7AscC3x6R62UUpJ8Gzh+wC4nA387331I0hLwNuArsw2Y9xAGDgH2\nBjb11DcBLx4w/hcAb3nLWzj00EOZnJxkYmJiAdpaHPZf36gfw6j3D6N/DHva/+bNm9m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B75FM0M8eET6fyXN+YQLaL55/BmwFTi9a8yivI+r/2N0HfB/ormd5WM0\n3y1fWbunWXp9bSd8t/c8/kfXmI/TzAoeBa4Bjqzdd1dvg3rfDryja8wKmmuJH+j85/wHYFXt3ju9\n/Xfg553/K/cD39wRwEu991mO6bqeEF7SxwD8Hc1lpI/RXPXwFeDwUem/0+ME0O68R/8PcOaAMQv+\nPvZWlpJUUfU1YUl6JjOEJakiQ1iSKjKEJakiQ1iSKjKEJakiQ1iSKjKEJakiQ1iSKjKEJakiQ1iS\nKjKEJami/w/82d/97I64sQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7f837c47a748>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.imshow(np.subtract(frame_0[:,:,0], frame_1[:,:,0]),interpolation='nearest',cmap=plt.cm.binary);"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAVgAAAFdCAYAAABGoXXzAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAAPYQAAD2EBqD+naQAAEXJJREFUeJzt3X+MnHWdwPH3pz+gBdbU8DOeyI+jcNXzqBT0OA6horJL\nQKJ/CMWL8S4Y/AFRvJTYoNEcOUJsQEToHYm5QxEkeDljeqGFoJA7IB5HuW0UFoVYKHeFQguF3pYe\n2H7vj5l63S20O7Pzme/O7PuVbMI+zDPfz7S77336zMyzUUpBktR5M2oPIEn9ysBKUhIDK0lJDKwk\nJTGwkpTEwEpSEgMrSUlmZd55RBwMnA08DWzPXEuSumQOcDRwdyll895umBpYGnG9LXkNSarhU8Dt\ne7tBdmCfBrj66is45pgj27qD5ctvZunSSzo5U0+YzOP+5R3Pd3iaiXv1fya3/7+svZNzT/xkW/tu\n2PDi5BafpFkzX2p73weeeZA/P+q0tvf/+JVntL1vTZP9/h4YGOjgNBPz1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31BwqW0SsAJYAHwNGI2LX\nUfwrpZS+vNxjKWWUxj8Vfy8iRoHNpZTxR3j95NvAgxGxDLiTxjnYi2m8TK2frQSujIhngceAk2h8\nf3+v6lRJpuTLtAAi4gs0XiN3ODAMXFZKeaTuVLkiYidvfp75L0spP+j2PLVExM+B4X5+mRZARJxD\n40mf44B1wLWllH+oO1WuiDgQuAr4OI3TfhuA24GrSim/qzlbhikbWEnqdX153kOSpgIDK0lJDKwk\nJTGwkpTEwEpSEgMrSUkMrCQlMbCSlMTASlISAytJSQysJCX5P7dKNm9HT/2aAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7f8360131d68>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# the block we want to motion estimate\n",
    "ball = frame_0[27:37,1:11,]\n",
    "\n",
    "block_size = 10\n",
    "plt.imshow(ball,interpolation='nearest');"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Motion estimation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAWEAAAFiCAYAAAAna2l5AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAAPYQAAD2EBqD+naQAAGf1JREFUeJzt3Xuw3GWd5/H3N0ACBLJnSwxZVjGYAIOjZTQEYdaExMwA\ngfHColzGKUsuFrhAMdSMstRqwejOriWaZUGoSdVkZ3S8YtigrJJwR4zEjMGEYgyXwcRwSySQcA6B\nEAjP/vHrYN9yTnef7vN0d96vqi5OP7/nd/r745zzOU+eb3efSCkhScpjXO4CJGlvZghLUkaGsCRl\nZAhLUkaGsCRlZAhLUkaGsCRlZAhLUkaGsCRlZAhLUkYdC+GIuDgi1kfEKxGxMiJmdeqxJKlXdSSE\nI+Is4OvAVcD7gLXA8og4pBOPJ0m9KjrxBj4RsRL4ZUrpstL9AJ4Erk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dqPBV4qPQz+q/AeXXmdPzn2LeylKSM\nsu8JS9LezBCWpIwMYUnKyBCWpIwMYUnKyBCWpIwMYUnKyBCWpIwMYUnKyBCWpIwMYUnKyBCWpIz+\nP+is+7YYGQqrAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7f83600a20b8>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# let's pretend we had motion estimation (full scan, reduced scan(lfp)...) \n",
    "# and that the motion vectors were:\n",
    "x = 26 \n",
    "y = 10\n",
    "predicted_frame = np.array(frame_1)\n",
    "\n",
    "# applying the motion compensation\n",
    "predicted_frame[x:(x+block_size),y:(y+block_size),] = ball\n",
    "\n",
    "plt.imshow(predicted_frame,interpolation='nearest');"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Frame difference vs motion estimation + residual"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAfwAAAEPCAYAAACnVHakAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAAPYQAAD2EBqD+naQAAIABJREFUeJzt3XucHFWZ//HPN1xmIBhRICQDgiCXxQyDioK4AgsYgUHw\nggoq621xAQERURDBH8ptWRREFCO6YXcV0UXQBdwIBoKK3EFlnIAggXCbISaISchlAsn5/XGqm+qa\nnkvP9G26vu/Xa16pPnW66ulOP/1Unbq0QgiYmZlZa5vU6ADMzMys9lzwzczMcsAF38zMLAdc8M3M\nzHLABd/MzCwHXPDNzMxywAXfzMwsB1zwzczMcsAF38zMLAdc8G0QSQdIWifpbam2KyX9JdPvFZKu\nkNSf9L8waZ8m6WeSlkhaK+nT9X4NZs1M0seTnNmm0bHUQrO+PkkLJV3R6DgaxQW/DEkfSz6s5f7O\nb3R8dZK953IA1mXavgx8BPgWcBRwVdJ+KbA/cC7wz8Cvahem2dhk8vxt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vZmaWAy74ZmZmOeCCb2ZmlgP/Hxb9AvI7a1cbAAAAAElFTkSu\nQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7f835a50a5c0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "f, (plt1, plt2) = plt.subplots(1, 2)\n",
    "plt1.set_title('Frame difference');plt1.imshow(np.subtract(frame_0[:,:,0], frame_1[:,:,0]),interpolation='nearest',cmap=plt.cm.binary);\n",
    "plt2.set_title('Motion estimation');plt2.imshow(np.subtract(predicted_frame[:,:,0], frame_1[:,:,0]),interpolation='nearest',cmap=plt.cm.binary);"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
