{"action":"created","comment":{"url":"https://api.github.com/repos/scikit-image/scikit-image/pulls/comments/187706441","pull_request_review_id":119547745,"id":187706441,"diff_hunk":"@@ -764,3 +764,76 @@ def rectangle(start, end=None, extent=None, shape=None):\n     coords = np.meshgrid(*[np.arange(st, en) for st, en in zip(tuple(tl),\n                                                                tuple(br))])\n     return coords\n+\n+\n+def rectangle_perimeter(start, end=None, extent=None, shape=None, clip=False):\n+    \"\"\"Generate coordinates of pixels that are exactly around a rectangle.\n+\n+    Parameters\n+    ----------\n+    start : tuple\n+        Origin point of the inner rectangle, e.g., ``(row, column)``.\n+    end : tuple\n+        End point of the inner rectangle ``(row, column)``.\n+        Either `end` or `extent` must be specified.\n+    extent : tuple\n+        The extent (size) of the inner rectangle.  E.g.,\n+        ``(num_rows, num_cols)``.\n+        Either `end` or `extent` must be specified.\n+    shape : tuple, optional\n+        Image shape used to determine the maximum bounds of the output\n+        coordinates. This is useful for clipping perimeters that exceed\n+        the image size. By default, no clipping is done.\n+    clip : bool, optional\n+        Whether to clip the perimeter to the provided shape. If this is set\n+        to True, the drawn figure will always be a closed polygon with all\n+        edges visible.\n+\n+    Returns\n+    -------\n+    coords : array of int, shape (Ndim, Npoints)\n+        The coordinates of all pixels in the rectangle.\n+\n+    Examples\n+    --------\n+    >>> import numpy as np\n+    >>> from skimage.draw import rectangle_perimeter\n+    >>> img = np.zeros((5, 6), dtype=np.uint8)\n+    >>> start = (2, 3)\n+    >>> end = (3, 4)\n+    >>> rr, cc = rectangle_perimeter(start, end=end, shape=img.shape)\n+    >>> img[rr, cc] = 1\n+    >>> img\n+    array([[0, 0, 0, 0, 0, 0],\n+           [0, 0, 1, 1, 1, 1],\n+           [0, 0, 1, 0, 0, 1],\n+           [0, 0, 1, 0, 0, 1],\n+           [0, 0, 1, 1, 1, 1]], dtype=uint8)\n+\n+    >>> img = np.zeros((5, 5), dtype=np.uint8)\n+    >>> rr, cc = rectangle_perimeter(start, end=(10, 10), shape=img.shape,\n+                                     clip=True)\n+    >>> img[rr, cc] = 1\n+    >>> img\n+    array([[0, 0, 0, 0, 0],\n+           [0, 0, 1, 1, 1],\n+           [0, 0, 1, 0, 1],\n+           [0, 0, 1, 0, 1],\n+           [0, 0, 1, 1, 1]], dtype=uint8)\n+\n+    \"\"\"\n+\n+    if extent is not None:\n+        end = np.array(start) + np.array(extent)","path":"skimage/draw/draw.py","position":73,"original_position":73,"commit_id":"05cbfc564051fff443953cb5b2192fc11361b381","original_commit_id":"05cbfc564051fff443953cb5b2192fc11361b381","user":{"login":"hmaarrfk","id":90008,"avatar_url":"https://avatars0.githubusercontent.com/u/90008?v=4","gravatar_id":"","url":"https://api.github.com/users/hmaarrfk","html_url":"https://github.com/hmaarrfk","followers_url":"https://api.github.com/users/hmaarrfk/followers","following_url":"https://api.github.com/users/hmaarrfk/following{/other_user}","gists_url":"https://api.github.com/users/hmaarrfk/gists{/gist_id}","starred_url":"https://api.github.com/users/hmaarrfk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hmaarrfk/subscriptions","organizations_url":"https://api.github.com/users/hmaarrfk/orgs","repos_url":"https://api.github.com/users/hmaarrfk/repos","events_url":"https://api.github.com/users/hmaarrfk/events{/privacy}","received_events_url":"https://api.github.com/users/hmaarrfk/received_events","type":"User","site_admin":false},"body":"`asarray` ok.\r\n\r\nI could add logic like:\r\n```python\r\n        extent = np.asarray(extent)\r\n        if (extent < 0).any():\r\n            raise ValueError(\"Extent should be positive.\")\r\n        end = np.array(start) + extent\r\n```\r\nbut then that would duplicate logic like \r\n```\r\n    tl = np.minimum(start, end)\r\n    br = np.maximum(start, end)\r\n```","created_at":"2018-05-11T19:07:28Z","updated_at":"2018-05-11T19:07:29Z","html_url":"https://github.com/scikit-image/scikit-image/pull/3069#discussion_r187706441","pull_request_url":"https://api.github.com/repos/scikit-image/scikit-image/pulls/3069","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/scikit-image/scikit-image/pulls/comments/187706441"},"html":{"href":"https://github.com/scikit-image/scikit-image/pull/3069#discussion_r187706441"},"pull_request":{"href":"https://api.github.com/repos/scikit-image/scikit-image/pulls/3069"}},"in_reply_to_id":187679271},"pull_request":{"url":"https://api.github.com/repos/scikit-image/scikit-image/pulls/3069","id":187278963,"html_url":"https://github.com/scikit-image/scikit-image/pull/3069","diff_url":"https://github.com/scikit-image/scikit-image/pull/3069.diff","patch_url":"https://github.com/scikit-image/scikit-image/pull/3069.patch","issue_url":"https://api.github.com/repos/scikit-image/scikit-image/issues/3069","number":3069,"state":"open","locked":false,"title":"Add `rectangle_perimeter` feature to `skimage.draw`","user":{"login":"hmaarrfk","id":90008,"avatar_url":"https://avatars0.githubusercontent.com/u/90008?v=4","gravatar_id":"","url":"https://api.github.com/users/hmaarrfk","html_url":"https://github.com/hmaarrfk","followers_url":"https://api.github.com/users/hmaarrfk/followers","following_url":"https://api.github.com/users/hmaarrfk/following{/other_user}","gists_url":"https://api.github.com/users/hmaarrfk/gists{/gist_id}","starred_url":"https://api.github.com/users/hmaarrfk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hmaarrfk/subscriptions","organizations_url":"https://api.github.com/users/hmaarrfk/orgs","repos_url":"https://api.github.com/users/hmaarrfk/repos","events_url":"https://api.github.com/users/hmaarrfk/events{/privacy}","received_events_url":"https://api.github.com/users/hmaarrfk/received_events","type":"User","site_admin":false},"body":"## Description\r\nThese are useful!\r\n\r\n\r\n## Checklist\r\n- [x] Clean style in [the spirit of PEP8](https://www.python.org/dev/peps/pep-0008/)\r\n- [x] [Docstrings for all functions](https://github.com/numpy/numpy/blob/master/doc/example.py)\r\n- [x] Gallery example in `./doc/examples` (new features only)\r\n- [x] Unit tests\r\n\r\n\r\n## References\r\n[If this is a bug-fix or enhancement, it closes issue # ]\r\n\r\n## For reviewers\r\n\r\n(Don't remove the checklist below.)\r\n\r\n- [ ] Check that the PR title is short, concise, and will make sense 1 year\r\n  later.\r\n- [ ] Check that new functions are imported in corresponding `__init__.py`.\r\n- [ ] Check that new features, API changes, and deprecations are mentioned in\r\n      `doc/release/release_dev.rst`.\r\n","created_at":"2018-05-10T19:06:27Z","updated_at":"2018-05-11T19:07:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"06865682122cd03ac99b12fdd4a2ef22740f90f3","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":360222353,"url":"https://api.github.com/repos/scikit-image/scikit-image/labels/status:%20needs%20review","name":"status: needs review","color":"fef2c0","default":false},{"id":314658482,"url":"https://api.github.com/repos/scikit-image/scikit-image/labels/type:%20new%20feature","name":"type: new feature","color":"8a64ae","default":false}],"milestone":{"url":"https://api.github.com/repos/scikit-image/scikit-image/milestones/7","html_url":"https://github.com/scikit-image/scikit-image/milestone/7","labels_url":"https://api.github.com/repos/scikit-image/scikit-image/milestones/7/labels","id":1646452,"number":7,"title":"0.14","description":"","creator":{"login":"soupault","id":1315589,"avatar_url":"https://avatars0.githubusercontent.com/u/1315589?v=4","gravatar_id":"","url":"https://api.github.com/users/soupault","html_url":"https://github.com/soupault","followers_url":"https://api.github.com/users/soupault/followers","following_url":"https://api.github.com/users/soupault/following{/other_user}","gists_url":"https://api.github.com/users/soupault/gists{/gist_id}","starred_url":"https://api.github.com/users/soupault/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/soupault/subscriptions","organizations_url":"https://api.github.com/users/soupault/orgs","repos_url":"https://api.github.com/users/soupault/repos","events_url":"https://api.github.com/users/soupault/events{/privacy}","received_events_url":"https://api.github.com/users/soupault/received_events","type":"User","site_admin":false},"open_issues":67,"closed_issues":169,"state":"open","created_at":"2016-03-15T19:16:06Z","updated_at":"2018-05-11T10:48:52Z","due_on":"2018-02-01T08:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/scikit-image/scikit-image/pulls/3069/commits","review_comments_url":"https://api.github.com/repos/scikit-image/scikit-image/pulls/3069/comments","review_comment_url":"https://api.github.com/repos/scikit-image/scikit-image/pulls/comments{/number}","comments_url":"https://api.github.com/repos/scikit-image/scikit-image/issues/3069/comments","statuses_url":"https://api.github.com/repos/scikit-image/scikit-image/statuses/05cbfc564051fff443953cb5b2192fc11361b381","head":{"label":"hmaarrfk:feature_rectangle_perimeter","ref":"feature_rectangle_perimeter","sha":"05cbfc564051fff443953cb5b2192fc11361b381","user":{"login":"hmaarrfk","id":90008,"avatar_url":"https://avatars0.githubusercontent.com/u/90008?v=4","gravatar_id":"","url":"https://api.github.com/users/hmaarrfk","html_url":"https://github.com/hmaarrfk","followers_url":"https://api.github.com/users/hmaarrfk/followers","following_url":"https://api.github.com/users/hmaarrfk/following{/other_user}","gists_url":"https://api.github.com/users/hmaarrfk/gists{/gist_id}","starred_url":"https://api.github.com/users/hmaarrfk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hmaarrfk/subscriptions","organizations_url":"https://api.github.com/users/hmaarrfk/orgs","repos_url":"https://api.github.com/users/hmaarrfk/repos","events_url":"https://api.github.com/users/hmaarrfk/events{/privacy}","received_events_url":"https://api.github.com/users/hmaarrfk/received_events","type":"User","site_admin":false},"repo":{"id":118949704,"name":"scikit-image","full_name":"hmaarrfk/scikit-image","owner":{"login":"hmaarrfk","id":90008,"avatar_url":"https://avatars0.githubusercontent.com/u/90008?v=4","gravatar_id":"","url":"https://api.github.com/users/hmaarrfk","html_url":"https://github.com/hmaarrfk","followers_url":"https://api.github.com/users/hmaarrfk/followers","following_url":"https://api.github.com/users/hmaarrfk/following{/other_user}","gists_url":"https://api.github.com/users/hmaarrfk/gists{/gist_id}","starred_url":"https://api.github.com/users/hmaarrfk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hmaarrfk/subscriptions","organizations_url":"https://api.github.com/users/hmaarrfk/orgs","repos_url":"https://api.github.com/users/hmaarrfk/repos","events_url":"https://api.github.com/users/hmaarrfk/events{/privacy}","received_events_url":"https://api.github.com/users/hmaarrfk/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/hmaarrfk/scikit-image","description":"Image Processing SciKit (Toolbox for SciPy)","fork":true,"url":"https://api.github.com/repos/hmaarrfk/scikit-image","forks_url":"https://api.github.com/repos/hmaarrfk/scikit-image/forks","keys_url":"https://api.github.com/repos/hmaarrfk/scikit-image/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hmaarrfk/scikit-image/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hmaarrfk/scikit-image/teams","hooks_url":"https://api.github.com/repos/hmaarrfk/scikit-image/hooks","issue_events_url":"https://api.github.com/repos/hmaarrfk/scikit-image/issues/events{/number}","events_url":"https://api.github.com/repos/hmaarrfk/scikit-image/events","assignees_url":"https://api.github.com/repos/hmaarrfk/scikit-image/assignees{/user}","branches_url":"https://api.github.com/repos/hmaarrfk/scikit-image/branches{/branch}","tags_url":"https://api.github.com/repos/hmaarrfk/scikit-image/tags","blobs_url":"https://api.github.com/repos/hmaarrfk/scikit-image/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hmaarrfk/scikit-image/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hmaarrfk/scikit-image/git/refs{/sha}","trees_url":"https://api.github.com/repos/hmaarrfk/scikit-image/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hmaarrfk/scikit-image/statuses/{sha}","languages_url":"https://api.github.com/repos/hmaarrfk/scikit-image/languages","stargazers_url":"https://api.github.com/repos/hmaarrfk/scikit-image/stargazers","contributors_url":"https://api.github.com/repos/hmaarrfk/scikit-image/contributors","subscribers_url":"https://api.github.com/repos/hmaarrfk/scikit-image/subscribers","subscription_url":"https://api.github.com/repos/hmaarrfk/scikit-image/subscription","commits_url":"https://api.github.com/repos/hmaarrfk/scikit-image/commits{/sha}","git_commits_url":"https://api.github.com/repos/hmaarrfk/scikit-image/git/commits{/sha}","comments_url":"https://api.github.com/repos/hmaarrfk/scikit-image/comments{/number}","issue_comment_url":"https://api.github.com/repos/hmaarrfk/scikit-image/issues/comments{/number}","contents_url":"https://api.github.com/repos/hmaarrfk/scikit-image/contents/{+path}","compare_url":"https://api.github.com/repos/hmaarrfk/scikit-image/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hmaarrfk/scikit-image/merges","archive_url":"https://api.github.com/repos/hmaarrfk/scikit-image/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hmaarrfk/scikit-image/downloads","issues_url":"https://api.github.com/repos/hmaarrfk/scikit-image/issues{/number}","pulls_url":"https://api.github.com/repos/hmaarrfk/scikit-image/pulls{/number}","milestones_url":"https://api.github.com/repos/hmaarrfk/scikit-image/milestones{/number}","notifications_url":"https://api.github.com/repos/hmaarrfk/scikit-image/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hmaarrfk/scikit-image/labels{/name}","releases_url":"https://api.github.com/repos/hmaarrfk/scikit-image/releases{/id}","deployments_url":"https://api.github.com/repos/hmaarrfk/scikit-image/deployments","created_at":"2018-01-25T18:13:27Z","updated_at":"2018-05-05T18:04:48Z","pushed_at":"2018-05-11T12:55:32Z","git_url":"git://github.com/hmaarrfk/scikit-image.git","ssh_url":"git@github.com:hmaarrfk/scikit-image.git","clone_url":"https://github.com/hmaarrfk/scikit-image.git","svn_url":"https://github.com/hmaarrfk/scikit-image","homepage":"http://scikit-image.org","size":54365,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"scikit-image:master","ref":"master","sha":"7383bad0c9a92fab5c8f7fb72e8cc657ab7de02a","user":{"login":"scikit-image","id":897180,"avatar_url":"https://avatars0.githubusercontent.com/u/897180?v=4","gravatar_id":"","url":"https://api.github.com/users/scikit-image","html_url":"https://github.com/scikit-image","followers_url":"https://api.github.com/users/scikit-image/followers","following_url":"https://api.github.com/users/scikit-image/following{/other_user}","gists_url":"https://api.github.com/users/scikit-image/gists{/gist_id}","starred_url":"https://api.github.com/users/scikit-image/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scikit-image/subscriptions","organizations_url":"https://api.github.com/users/scikit-image/orgs","repos_url":"https://api.github.com/users/scikit-image/repos","events_url":"https://api.github.com/users/scikit-image/events{/privacy}","received_events_url":"https://api.github.com/users/scikit-image/received_events","type":"Organization","site_admin":false},"repo":{"id":2014929,"name":"scikit-image","full_name":"scikit-image/scikit-image","owner":{"login":"scikit-image","id":897180,"avatar_url":"https://avatars0.githubusercontent.com/u/897180?v=4","gravatar_id":"","url":"https://api.github.com/users/scikit-image","html_url":"https://github.com/scikit-image","followers_url":"https://api.github.com/users/scikit-image/followers","following_url":"https://api.github.com/users/scikit-image/following{/other_user}","gists_url":"https://api.github.com/users/scikit-image/gists{/gist_id}","starred_url":"https://api.github.com/users/scikit-image/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scikit-image/subscriptions","organizations_url":"https://api.github.com/users/scikit-image/orgs","repos_url":"https://api.github.com/users/scikit-image/repos","events_url":"https://api.github.com/users/scikit-image/events{/privacy}","received_events_url":"https://api.github.com/users/scikit-image/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/scikit-image/scikit-image","description":"Image Processing SciKit (Toolbox for SciPy)","fork":false,"url":"https://api.github.com/repos/scikit-image/scikit-image","forks_url":"https://api.github.com/repos/scikit-image/scikit-image/forks","keys_url":"https://api.github.com/repos/scikit-image/scikit-image/keys{/key_id}","collaborators_url":"https://api.github.com/repos/scikit-image/scikit-image/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/scikit-image/scikit-image/teams","hooks_url":"https://api.github.com/repos/scikit-image/scikit-image/hooks","issue_events_url":"https://api.github.com/repos/scikit-image/scikit-image/issues/events{/number}","events_url":"https://api.github.com/repos/scikit-image/scikit-image/events","assignees_url":"https://api.github.com/repos/scikit-image/scikit-image/assignees{/user}","branches_url":"https://api.github.com/repos/scikit-image/scikit-image/branches{/branch}","tags_url":"https://api.github.com/repos/scikit-image/scikit-image/tags","blobs_url":"https://api.github.com/repos/scikit-image/scikit-image/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/scikit-image/scikit-image/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/scikit-image/scikit-image/git/refs{/sha}","trees_url":"https://api.github.com/repos/scikit-image/scikit-image/git/trees{/sha}","statuses_url":"https://api.github.com/repos/scikit-image/scikit-image/statuses/{sha}","languages_url":"https://api.github.com/repos/scikit-image/scikit-image/languages","stargazers_url":"https://api.github.com/repos/scikit-image/scikit-image/stargazers","contributors_url":"https://api.github.com/repos/scikit-image/scikit-image/contributors","subscribers_url":"https://api.github.com/repos/scikit-image/scikit-image/subscribers","subscription_url":"https://api.github.com/repos/scikit-image/scikit-image/subscription","commits_url":"https://api.github.com/repos/scikit-image/scikit-image/commits{/sha}","git_commits_url":"https://api.github.com/repos/scikit-image/scikit-image/git/commits{/sha}","comments_url":"https://api.github.com/repos/scikit-image/scikit-image/comments{/number}","issue_comment_url":"https://api.github.com/repos/scikit-image/scikit-image/issues/comments{/number}","contents_url":"https://api.github.com/repos/scikit-image/scikit-image/contents/{+path}","compare_url":"https://api.github.com/repos/scikit-image/scikit-image/compare/{base}...{head}","merges_url":"https://api.github.com/repos/scikit-image/scikit-image/merges","archive_url":"https://api.github.com/repos/scikit-image/scikit-image/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/scikit-image/scikit-image/downloads","issues_url":"https://api.github.com/repos/scikit-image/scikit-image/issues{/number}","pulls_url":"https://api.github.com/repos/scikit-image/scikit-image/pulls{/number}","milestones_url":"https://api.github.com/repos/scikit-image/scikit-image/milestones{/number}","notifications_url":"https://api.github.com/repos/scikit-image/scikit-image/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/scikit-image/scikit-image/labels{/name}","releases_url":"https://api.github.com/repos/scikit-image/scikit-image/releases{/id}","deployments_url":"https://api.github.com/repos/scikit-image/scikit-image/deployments","created_at":"2011-07-07T22:07:20Z","updated_at":"2018-05-11T06:39:03Z","pushed_at":"2018-05-11T12:29:12Z","git_url":"git://github.com/scikit-image/scikit-image.git","ssh_url":"git@github.com:scikit-image/scikit-image.git","clone_url":"https://github.com/scikit-image/scikit-image.git","svn_url":"https://github.com/scikit-image/scikit-image","homepage":"http://scikit-image.org","size":54323,"stargazers_count":2243,"watchers_count":2243,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1020,"mirror_url":null,"archived":false,"open_issues_count":420,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":1020,"open_issues":420,"watchers":2243,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/scikit-image/scikit-image/pulls/3069"},"html":{"href":"https://github.com/scikit-image/scikit-image/pull/3069"},"issue":{"href":"https://api.github.com/repos/scikit-image/scikit-image/issues/3069"},"comments":{"href":"https://api.github.com/repos/scikit-image/scikit-image/issues/3069/comments"},"review_comments":{"href":"https://api.github.com/repos/scikit-image/scikit-image/pulls/3069/comments"},"review_comment":{"href":"https://api.github.com/repos/scikit-image/scikit-image/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/scikit-image/scikit-image/pulls/3069/commits"},"statuses":{"href":"https://api.github.com/repos/scikit-image/scikit-image/statuses/05cbfc564051fff443953cb5b2192fc11361b381"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"hmaarrfk"}}