Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- "cells": [
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "print(hi)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "import cv2\n",
- "import numpy as np\n",
- "from matplotlib import pyplot as plt"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "img = cv2.imread('GrayGradient.png',0)\n",
- "ret,thresh1 = cv2.threshold(img,127,255,cv2.THRESH_BINARY)\n",
- "ret,thresh2 = cv2.threshold(img,127,255,cv2.THRESH_BINARY_INV)\n",
- "ret,thresh3 = cv2.threshold(img,127,255,cv2.THRESH_TRUNC)\n",
- "ret,thresh4 = cv2.threshold(img,127,255,cv2.THRESH_TOZERO)\n",
- "ret,thresh5 = cv2.threshold(img,127,255,cv2.THRESH_TOZERO_INV)\n",
- "\n",
- "titles = ['Original Image','BINARY','BINARY_INV','TRUNC','TOZERO','TOZERO_INV']\n",
- "images = [img, thresh1, thresh2, thresh3, thresh4, thresh5]\n",
- "\n"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "for i in xrange(6):\n",
- " plt.subplot(2,3,i+1),plt.imshow(images[i],'gray')\n",
- " plt.title(titles[i])\n",
- " plt.xticks([]),plt.yticks([])\n",
- "\n",
- "plt.show()"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 2
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement