Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. "cells": [
  2. {
  3. "cell_type": "code",
  4. "execution_count": null,
  5. "metadata": {},
  6. "outputs": [],
  7. "source": [
  8. "print(hi)"
  9. ]
  10. },
  11. {
  12. "cell_type": "code",
  13. "execution_count": null,
  14. "metadata": {},
  15. "outputs": [],
  16. "source": [
  17. "import cv2\n",
  18. "import numpy as np\n",
  19. "from matplotlib import pyplot as plt"
  20. ]
  21. },
  22. {
  23. "cell_type": "code",
  24. "execution_count": null,
  25. "metadata": {},
  26. "outputs": [],
  27. "source": [
  28. "img = cv2.imread('GrayGradient.png',0)\n",
  29. "ret,thresh1 = cv2.threshold(img,127,255,cv2.THRESH_BINARY)\n",
  30. "ret,thresh2 = cv2.threshold(img,127,255,cv2.THRESH_BINARY_INV)\n",
  31. "ret,thresh3 = cv2.threshold(img,127,255,cv2.THRESH_TRUNC)\n",
  32. "ret,thresh4 = cv2.threshold(img,127,255,cv2.THRESH_TOZERO)\n",
  33. "ret,thresh5 = cv2.threshold(img,127,255,cv2.THRESH_TOZERO_INV)\n",
  34. "\n",
  35. "titles = ['Original Image','BINARY','BINARY_INV','TRUNC','TOZERO','TOZERO_INV']\n",
  36. "images = [img, thresh1, thresh2, thresh3, thresh4, thresh5]\n",
  37. "\n"
  38. ]
  39. },
  40. {
  41. "cell_type": "code",
  42. "execution_count": null,
  43. "metadata": {},
  44. "outputs": [],
  45. "source": [
  46. "for i in xrange(6):\n",
  47. " plt.subplot(2,3,i+1),plt.imshow(images[i],'gray')\n",
  48. " plt.title(titles[i])\n",
  49. " plt.xticks([]),plt.yticks([])\n",
  50. "\n",
  51. "plt.show()"
  52. ]
  53. }
  54. ],
  55. "metadata": {
  56. "kernelspec": {
  57. "display_name": "Python 3",
  58. "language": "python",
  59. "name": "python3"
  60. }
  61. },
  62. "nbformat": 4,
  63. "nbformat_minor": 2
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement