Guest User

Untitled

a guest
Jul 21st, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. {
  2. "cells": [
  3. {
  4. "cell_type": "code",
  5. "execution_count": 1,
  6. "metadata": {},
  7. "outputs": [
  8. {
  9. "data": {
  10. "text/plain": [
  11. "array([[11, 21, 31, 41],\n",
  12. " [12, 22, 32, 42],\n",
  13. " [13, 23, 33, 43],\n",
  14. " [14, 24, 34, 44]])"
  15. ]
  16. },
  17. "execution_count": 1,
  18. "metadata": {},
  19. "output_type": "execute_result"
  20. }
  21. ],
  22. "source": [
  23. "import numpy as np\n",
  24. "arr = np.array([[11,21,31,41],[12,22,32,42],[13,23,33,43],[14,24,34,44]])\n",
  25. "arr"
  26. ]
  27. },
  28. {
  29. "cell_type": "code",
  30. "execution_count": 4,
  31. "metadata": {},
  32. "outputs": [
  33. {
  34. "data": {
  35. "text/plain": [
  36. "array([[ 0, 0, 255, 255],\n",
  37. " [ 0, 0, 255, 255],\n",
  38. " [ 0, 0, 255, 255],\n",
  39. " [ 0, 0, 255, 255]])"
  40. ]
  41. },
  42. "execution_count": 4,
  43. "metadata": {},
  44. "output_type": "execute_result"
  45. }
  46. ],
  47. "source": [
  48. "#arrの要素のうち30より大きい物を255, そうでないものを0\n",
  49. "arr_thres = np.where(arr>30, 255, 0)\n",
  50. "arr_thres"
  51. ]
  52. },
  53. {
  54. "cell_type": "code",
  55. "execution_count": null,
  56. "metadata": {},
  57. "outputs": [],
  58. "source": []
  59. }
  60. ],
  61. "metadata": {
  62. "kernelspec": {
  63. "display_name": "Python 2",
  64. "language": "python",
  65. "name": "python2"
  66. },
  67. "language_info": {
  68. "codemirror_mode": {
  69. "name": "ipython",
  70. "version": 2
  71. },
  72. "file_extension": ".py",
  73. "mimetype": "text/x-python",
  74. "name": "python",
  75. "nbconvert_exporter": "python",
  76. "pygments_lexer": "ipython2",
  77. "version": "2.7.12"
  78. }
  79. },
  80. "nbformat": 4,
  81. "nbformat_minor": 2
  82. }
Add Comment
Please, Sign In to add comment