{ "metadata": { "name": "", "signature": "sha256:9e0238407be7fe0f22ad41a8ea71be7974a29d65fd6e727073e1d7cc2494d5d1" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "code", "collapsed": false, "input": [ "import numpy as np\n", "import matplotlib.pyplot as plt\n", "from quadtree import ellipseMatrix\n", "import time\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stderr", "text": [ "C:\\WinPython-64bit-2.7.9.3\\python-2.7.9.amd64\\lib\\site-packages\\matplotlib\\__init__.py:1318: UserWarning: This call to matplotlib.use() has no effect\n", "because the backend has already been chosen;\n", "matplotlib.use() must be called *before* pylab, matplotlib.pyplot,\n", "or matplotlib.backends is imported for the first time.\n", "\n", " warnings.warn(_use_error_msg)\n" ] } ], "prompt_number": 7 }, { "cell_type": "code", "collapsed": false, "input": [ "%run -p test_packing.py" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "0 50.0 184304.092036\n", "1 38.0 183802.842426\n", "2 29.0 183302.956059\n", "3 22.0 182804.429226\n", "4 17.0 182307.258231\n", "5" ] }, { "output_type": "stream", "stream": "stdout", "text": [ " 13.0 181811.439386\n", "6" ] }, { "output_type": "stream", "stream": "stdout", "text": [ " 10.0 181316.969013\n", "7" ] }, { "output_type": "stream", "stream": "stdout", "text": [ " 7.0 180823.843445\n", "8" ] }, { "output_type": "stream", "stream": "stdout", "text": [ " 6.0 180332.059025\n", "9" ] }, { "output_type": "stream", "stream": "stdout", "text": [ " 4.0 179841.612105\n", "10" ] }, { "output_type": "stream", "stream": "stdout", "text": [ " 3.0 179352.499048\n", "273.967000008" ] }, { "output_type": "stream", "stream": "stdout", "text": [ "\n" ] }, { "output_type": "stream", "stream": "stdout", "text": [ " " ] } ], "prompt_number": 2 }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 2 }, { "cell_type": "markdown", "metadata": {}, "source": [ "print \"draw\"\n", "start = time.time()\n", "\n", "for c in Objs:\n", " ellipseMatrix(c.y(), c.x(), c.a(), c.b(), c.theta(), Image, Label, XX, YY)\n", " \n", "print time.time()-start" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 2 }, { "cell_type": "markdown", "metadata": {}, "source": [ "plt.figure()\n", "plt.imshow(Image)\n", "plt.show()" ] }, { "cell_type": "code", "collapsed": false, "input": [ "Objs[0].theta()\n", "\n", "from matplotlib.patches import Ellipse\n", "from pylab import figure, show, rand" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 3 }, { "cell_type": "code", "collapsed": false, "input": [ "ells = [Ellipse(xy=[c.x(), c.y()], width=2*c.a(), height=2*c.b(), angle=c.theta()*180.0/np.pi) for c in Objs]\n", "\n", "fig = figure()\n", "ax = fig.add_subplot(111, aspect='equal')\n", "for e in ells:\n", " ax.add_artist(e)\n", " e.set_clip_box(ax.bbox)\n", " #e.set_alpha(rand())\n", " #e.set_facecolor([1.0,0,0])\n", " #e.set_edgecolor([1.0,0,0])\n", " e.set_facecolor(rand(3))\n", " \n", "ax.set_xlim(0, 2000)\n", "ax.set_ylim(0, 2000)\n", "\n", "show()" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 4 }, { "cell_type": "code", "collapsed": false, "input": [ "print " ], "language": "python", "metadata": {}, "outputs": [] } ], "metadata": {} } ] }