{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import cv2\n",
    "import matplotlib.pyplot as plt\n",
    "import dautil as dl"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "context = dl.nb.Context('applying_surf')\n",
    "lr = dl.nb.LatexRenderer(chapter=11, context=context)\n",
    "lr.render(r'S(x, y)=\\sum_{i=0}^{x}\\sum_{j=0}^{y} I(i,j)')\n",
    "lr.render(r'H(p,\\sigma)=\\begin{pmatrix} L_{xx}(p,\\sigma) &amp; L_{xy}(p,\\sigma) \\\\ L_{xy}(p,\\sigma) &amp; L_{yy}(p,\\sigma) \\end{pmatrix} ')\n",
    "lr.render(r'\\sigma_\\text{approx} = \\text{Current filter size} * \\left( \\frac{\\text{Base Filter Scale} }{\\text{Base Filter Size}} \\right)')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "%matplotlib inline\n",
    "img = cv2.imread('covers.jpg')\n",
    "plt.title('Original')\n",
    "dl.plotting.img_show(plt.gca(), img)\n",
    "gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)\n",
    "\n",
    "plt.figure()\n",
    "plt.title('Gray')\n",
    "dl.plotting.img_show(plt.gca(), gray, cmap=plt.cm.gray)\n",
    "surf = cv2.xfeatures2d.SURF_create()\n",
    "(kps, descs) = surf.detectAndCompute(gray, None)\n",
    "img2 = cv2.drawKeypoints(gray, kps, None, (0, 0, 255))\n",
    "\n",
    "plt.figure()\n",
    "plt.title('With Keypoints')\n",
    "dl.plotting.img_show(plt.gca(), img2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "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.4.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
