diff --git a/1_Image_Representation/.ipynb_checkpoints/1. Images as Numerical Data-checkpoint.ipynb b/1_Image_Representation/.ipynb_checkpoints/1. Images as Numerical Data-checkpoint.ipynb deleted file mode 100644 index 2e99428..0000000 --- a/1_Image_Representation/.ipynb_checkpoints/1. Images as Numerical Data-checkpoint.ipynb +++ /dev/null @@ -1,144 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Images as Grids of Pixels" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Import resources" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "import numpy as np\n", - "import matplotlib.image as mpimg # for reading in images\n", - "\n", - "import matplotlib.pyplot as plt\n", - "import cv2 # computer vision library\n", - "\n", - "%matplotlib inline" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Read in and display the image" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Read in the image\n", - "image = mpimg.imread('images/waymo_car.jpg')\n", - "\n", - "# Print out the image dimensions\n", - "print('Image dimensions:', image.shape)\n", - "\n", - "# Change from color to grayscale\n", - "gray_image = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY)\n", - "\n", - "plt.imshow(gray_image, cmap='gray')" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Print specific grayscale pixel values\n", - "# What is the pixel value at x = 400 and y = 300 (on the body of the car)?\n", - "\n", - "x = 400\n", - "y = 300\n", - "\n", - "print(gray_image[y,x])\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "#Find the maximum and minimum grayscale values in this image\n", - "\n", - "max_val = np.amax(gray_image)\n", - "min_val = np.amin(gray_image)\n", - "\n", - "print('Max: ', max_val)\n", - "print('Min: ', min_val)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Create a 5x5 image using just grayscale, numerical values\n", - "tiny_image = np.array([[0, 20, 30, 150, 120],\n", - " [200, 200, 250, 70, 3],\n", - " [50, 180, 85, 40, 90],\n", - " [240, 100, 50, 255, 10],\n", - " [30, 0, 75, 190, 220]])\n", - "\n", - "# To show the pixel grid, use matshow\n", - "plt.matshow(tiny_image, cmap='gray')\n", - "\n", - "## TODO: See if you can draw a tiny smiley face or something else!" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [] - } - ], - "metadata": { - "anaconda-cloud": {}, - "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.4" - }, - "widgets": { - "state": {}, - "version": "1.1.2" - } - }, - "nbformat": 4, - "nbformat_minor": 1 -}