{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "In this notebook, I'm going to test some colors on my spectrometer." ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": true }, "outputs": [], "source": [ "import numpy as np\n", "import matplotlib.pyplot as plt\n", "import skimage.io\n", "from ipywidgets import interact\n", "%matplotlib inline" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let's write a simple function that displays a single color image:" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "98916b219e294d0f9bf62d26f05320ba" } }, "metadata": {}, "output_type": "display_data" } ], "source": [ "@interact\n", "def draw_uniform_color(r=(0, 255),\n", " g=(0, 255),\n", " b=(0, 255),\n", " alpha=(0, 255)):\n", " \"Draws a uniformly colored rectangle.\"\n", " w, h = 1400, 1200\n", " img = np.ones((h, w, 4), dtype=np.float)\n", " img *= np.array((r, g, b, alpha)) / 255.\n", " plt.figure(figsize=(10, 8))\n", " plt.imshow(img)\n", " plt.axis('off')\n", " plt.show()" ] }, { "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.6.1" }, "toc": { "colors": { "hover_highlight": "#DAA520", "navigate_num": "#000000", "navigate_text": "#333333", "running_highlight": "#FF0000", "selected_highlight": "#FFD700", "sidebar_border": "#EEEEEE", "wrapper_background": "#FFFFFF" }, "moveMenuLeft": true, "nav_menu": { "height": "13px", "width": "253px" }, "navigate_menu": true, "number_sections": true, "sideBar": true, "threshold": 4, "toc_cell": false, "toc_section_display": "block", "toc_window_display": false, "widenNotebook": false } }, "nbformat": 4, "nbformat_minor": 1 }