{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\nVector field quiver plot\n=========================\n\nDemonstration of vector field quiver plot.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import numpy as np\nimport matplotlib.pyplot as plt\nimport pyimof\n\n# --- Load the MiniCooper sequence\n\nI0, I1 = pyimof.data.minicooper()\n\n# --- Estimate the optical flow\n\nu, v = pyimof.solvers.ilk(I0, I1)\n\nnorm = np.sqrt(u*u + v*v)\n\n# --- Display it with different options\n\nfig = plt.figure(figsize=((9, 7)))\nax0, ax1, ax2, ax3 = fig.subplots(2, 2, True, True).ravel()\nfig.tight_layout()\n\nax0.imshow(I0, cmap='gray')\nax0.set_axis_off()\nax0.set_title(\"Reference image\")\n\npyimof.display.quiver(u, v, ax=ax1)\nax1.set_title(\"Raw arrows\")\n\npyimof.display.quiver(u, v, c=norm, bg=I0, ax=ax2,\n                      cmap='jet', bg_cmap='gray')\nax2.set_title(\"Arrows colored according to their norm over Image\")\n\npyimof.display.quiver(u, v, bg=norm, ax=ax3, color='r')\nax3.set_title(\"Red arrows over magnitude\")\n\nplt.show()"
      ]
    }
  ],
  "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.7.3"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}