Last active
May 11, 2018 12:42
-
-
Save hmaarrfk/0c096a2ed2aaaf38b8bfccfe6300cd82 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"[[0 0 0 0 0 0]\n", | |
" [0 0 0 0 0 0]\n", | |
" [0 0 1 1 0 0]\n", | |
" [0 0 1 1 0 0]\n", | |
" [0 0 0 0 0 0]\n", | |
" [0 0 0 0 0 0]]\n" | |
] | |
} | |
], | |
"source": [ | |
"import numpy as np\n", | |
"from skimage.draw import rectangle\n", | |
"\n", | |
"from skimage.draw import rectangle_perimeter\n", | |
"\n", | |
"img = np.zeros(shape=(6, 6), dtype=int)\n", | |
"rr, cc = rectangle(start=(2, 2), extent=(2, 2))\n", | |
"img[rr, cc] = 1\n", | |
"print(img)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"[[0 0 0 0 0 0]\n", | |
" [0 2 2 2 2 0]\n", | |
" [0 2 0 0 2 0]\n", | |
" [0 2 0 0 2 0]\n", | |
" [0 2 2 2 2 0]\n", | |
" [0 0 0 0 0 0]]\n" | |
] | |
} | |
], | |
"source": [ | |
"img = np.zeros(shape=(6, 6), dtype=int)\n", | |
"rr, cc = rectangle_perimeter(start=(2, 2), extent=(2, 2))\n", | |
"img[rr, cc] = 2\n", | |
"print(img)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"[[0 0 0 0 0 0]\n", | |
" [0 0 0 0 0 0]\n", | |
" [0 0 1 1 0 0]\n", | |
" [0 0 1 1 0 0]\n", | |
" [0 0 0 0 0 0]\n", | |
" [0 0 0 0 0 0]]\n", | |
"[[0 0 0 0 0 0]\n", | |
" [0 2 2 2 2 0]\n", | |
" [0 2 0 0 2 0]\n", | |
" [0 2 0 0 2 0]\n", | |
" [0 2 2 2 2 0]\n", | |
" [0 0 0 0 0 0]]\n" | |
] | |
} | |
], | |
"source": [ | |
"img = np.zeros(shape=(6, 6), dtype=int)\n", | |
"rr, cc = rectangle(start=(2, 2), end=(3, 3))\n", | |
"img[rr, cc] = 1\n", | |
"print(img)\n", | |
"\n", | |
"img = np.zeros(shape=(6, 6), dtype=int)\n", | |
"rr, cc = rectangle_perimeter(start=(2, 2), end=(3, 3))\n", | |
"img[rr, cc] = 2\n", | |
"print(img)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 5, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"[[0 0 0 0 0 0]\n", | |
" [0 0 0 0 0 0]\n", | |
" [0 0 1 1 1 0]\n", | |
" [0 0 1 1 1 0]\n", | |
" [0 0 1 1 1 0]\n", | |
" [0 0 0 0 0 0]]\n", | |
"[[0 0 0 0 0 0]\n", | |
" [0 0 2 2 2 0]\n", | |
" [0 2 0 0 0 2]\n", | |
" [0 2 0 0 0 2]\n", | |
" [0 2 0 0 0 2]\n", | |
" [0 0 2 2 2 0]]\n" | |
] | |
} | |
], | |
"source": [ | |
"from skimage.draw import circle\n", | |
"from skimage.draw import circle_perimeter\n", | |
"\n", | |
"\n", | |
"img = np.zeros(shape=(6, 6), dtype=int)\n", | |
"rr, cc = circle(3, 3, 2)\n", | |
"img[rr, cc]= 1\n", | |
"print(img)\n", | |
"\n", | |
"img = np.zeros(shape=(6, 6), dtype=int)\n", | |
"rr, cc = circle_perimeter(3, 3, 2)\n", | |
"img[rr, cc]= 2\n", | |
"print(img)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"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.5" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment