{"action":"created","comment":{"url":"https://api.github.com/repos/scikit-image/scikit-image/pulls/comments/30804402","id":30804402,"diff_hunk":"@@ -58,36 +66,25 @@ def resize(image, output_shape, order=1, mode='constant', cval=0, clip=True,\n     (100, 100)\n \n     \"\"\"\n-\n-    rows, cols = output_shape[0], output_shape[1]\n-    orig_rows, orig_cols = image.shape[0], image.shape[1]\n-\n-    row_scale = float(orig_rows) / rows\n-    col_scale = float(orig_cols) / cols\n-\n-    # 3-dimensional interpolation\n-    if len(output_shape) == 3 and (image.ndim == 2\n-                                   or output_shape[2] != image.shape[2]):\n-        dim = output_shape[2]\n-        orig_dim = 1 if image.ndim == 2 else image.shape[2]\n-        dim_scale = float(orig_dim) / dim\n-\n-        map_rows, map_cols, map_dims = np.mgrid[:rows, :cols, :dim]\n-        map_rows = row_scale * (map_rows + 0.5) - 0.5\n-        map_cols = col_scale * (map_cols + 0.5) - 0.5\n-        map_dims = dim_scale * (map_dims + 0.5) - 0.5\n-\n-        coord_map = np.array([map_rows, map_cols, map_dims])\n-\n-        image = _convert_warp_input(image, preserve_range)\n-\n-        out = ndimage.map_coordinates(image, coord_map, order=order,\n-                                      mode=mode, cval=cval)\n-\n-        _clip_warp_output(image, out, order, mode, cval, clip)\n-\n-    else:  # 2-dimensional interpolation\n-\n+    output_shape = np.asarray(output_shape)\n+    orig_shape = image.shape\n+    if len(orig_shape) < len(output_shape):\n+        orig_shape = orig_shape + (1, ) * (len(output_shape) - len(orig_shape))\n+    elif len(output_shape) < len(orig_shape):\n+        orig_shape = orig_shape[:-1]\n+    orig_shape = np.asarray(orig_shape)\n+\n+    dim_scales = orig_shape.astype('f8') / output_shape","path":"skimage/transform/_warps.py","position":57,"original_position":57,"commit_id":"3a45e3c89a2a99462aea72c0d223a09234fba882","original_commit_id":"3a45e3c89a2a99462aea72c0d223a09234fba882","user":{"login":"grlee77","id":6528957,"avatar_url":"https://avatars.githubusercontent.com/u/6528957?v=3","gravatar_id":"","url":"https://api.github.com/users/grlee77","html_url":"https://github.com/grlee77","followers_url":"https://api.github.com/users/grlee77/followers","following_url":"https://api.github.com/users/grlee77/following{/other_user}","gists_url":"https://api.github.com/users/grlee77/gists{/gist_id}","starred_url":"https://api.github.com/users/grlee77/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grlee77/subscriptions","organizations_url":"https://api.github.com/users/grlee77/orgs","repos_url":"https://api.github.com/users/grlee77/repos","events_url":"https://api.github.com/users/grlee77/events{/privacy}","received_events_url":"https://api.github.com/users/grlee77/received_events","type":"User","site_admin":false},"body":"I agree that section is confusing and will try to clarify/simplify it.  \r\n\r\nthe 'f8' that was a lazy shorthand for np.float64.  Making sure one of the arrays is floating avoids an integer division problem there for python 2.x. \r\n\r\n","created_at":"2015-05-21T14:01:51Z","updated_at":"2015-05-21T14:01:51Z","html_url":"https://github.com/scikit-image/scikit-image/pull/1522#discussion_r30804402","pull_request_url":"https://api.github.com/repos/scikit-image/scikit-image/pulls/1522","_links":{"self":{"href":"https://api.github.com/repos/scikit-image/scikit-image/pulls/comments/30804402"},"html":{"href":"https://github.com/scikit-image/scikit-image/pull/1522#discussion_r30804402"},"pull_request":{"href":"https://api.github.com/repos/scikit-image/scikit-image/pulls/1522"}}},"pull_request":{"url":"https://api.github.com/repos/scikit-image/scikit-image/pulls/1522","id":35885434,"html_url":"https://github.com/scikit-image/scikit-image/pull/1522","diff_url":"https://github.com/scikit-image/scikit-image/pull/1522.diff","patch_url":"https://github.com/scikit-image/scikit-image/pull/1522.patch","issue_url":"https://api.github.com/repos/scikit-image/scikit-image/issues/1522","number":1522,"state":"open","locked":false,"title":"ENH: n-dimensional transforms","user":{"login":"grlee77","id":6528957,"avatar_url":"https://avatars.githubusercontent.com/u/6528957?v=3","gravatar_id":"","url":"https://api.github.com/users/grlee77","html_url":"https://github.com/grlee77","followers_url":"https://api.github.com/users/grlee77/followers","following_url":"https://api.github.com/users/grlee77/following{/other_user}","gists_url":"https://api.github.com/users/grlee77/gists{/gist_id}","starred_url":"https://api.github.com/users/grlee77/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grlee77/subscriptions","organizations_url":"https://api.github.com/users/grlee77/orgs","repos_url":"https://api.github.com/users/grlee77/repos","events_url":"https://api.github.com/users/grlee77/events{/privacy}","received_events_url":"https://api.github.com/users/grlee77/received_events","type":"User","site_admin":false},"body":"This is a pretty simple pull request extending n-dimensional support to the following transforms:\r\n- `skimage.transform.rescale`\r\n- `skimage.transform.resize`\r\n- `skimage.transform.pyramid_*`\r\n\r\nThis is useful for me as I work primarily in medical imaging where data is often either 3D volumetric or 3D+time.\r\n\r\nAs was previously the case, resize still calls the two-dimensional interpolations implemented in `_shared/interpolation.pyx` for 2D or 2D+color images, while all other cases use `scipy.ndimage.map_coordinates`.  Previously `map_coordinates` was set up explicitly for 3D only.\r\n\r\nThe changes to `resize` are substantially smaller than the diff would indicate at first glance, because I switched the order of the  if / else statement calling the 2D or n-D interpolation code.  (The logic for when to call 2D seemed slightly simpler to express)\r\n\r\nA multichannel argument was added to `rescale` to indicate that the last axis should not be reshaped.  This defaults to True for 3D inputs to replicate the previous behaviour for 2D+color images.  To do a true 3D rescale, the user must explicitly specify ``multichannel=False``.\r\n\r\nSimilarly in `pyramids.py`:\r\nThe `_smooth` function previously always looped 2D smoothing operations over the last axis if the input was 3D.  Now there is a new `multichannel` argument that explicitly controls this behavior of looping over the last axis, regardless of image dimension.  As for `rescale` above, `multichannel` defaults to None which will result in a call to a small function to replicate the old behaviour of True for 3D inputs and False otherwise.","created_at":"2015-05-20T23:06:01Z","updated_at":"2015-05-21T14:01:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0d4bddcb20deed78bc4849ca42514fe0d51d7cd1","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/scikit-image/scikit-image/pulls/1522/commits","review_comments_url":"https://api.github.com/repos/scikit-image/scikit-image/pulls/1522/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/1522/comments","statuses_url":"https://api.github.com/repos/scikit-image/scikit-image/statuses/3a45e3c89a2a99462aea72c0d223a09234fba882","head":{"label":"grlee77:nd_resize","ref":"nd_resize","sha":"3a45e3c89a2a99462aea72c0d223a09234fba882","user":{"login":"grlee77","id":6528957,"avatar_url":"https://avatars.githubusercontent.com/u/6528957?v=3","gravatar_id":"","url":"https://api.github.com/users/grlee77","html_url":"https://github.com/grlee77","followers_url":"https://api.github.com/users/grlee77/followers","following_url":"https://api.github.com/users/grlee77/following{/other_user}","gists_url":"https://api.github.com/users/grlee77/gists{/gist_id}","starred_url":"https://api.github.com/users/grlee77/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grlee77/subscriptions","organizations_url":"https://api.github.com/users/grlee77/orgs","repos_url":"https://api.github.com/users/grlee77/repos","events_url":"https://api.github.com/users/grlee77/events{/privacy}","received_events_url":"https://api.github.com/users/grlee77/received_events","type":"User","site_admin":false},"repo":{"id":23844497,"name":"scikit-image","full_name":"grlee77/scikit-image","owner":{"login":"grlee77","id":6528957,"avatar_url":"https://avatars.githubusercontent.com/u/6528957?v=3","gravatar_id":"","url":"https://api.github.com/users/grlee77","html_url":"https://github.com/grlee77","followers_url":"https://api.github.com/users/grlee77/followers","following_url":"https://api.github.com/users/grlee77/following{/other_user}","gists_url":"https://api.github.com/users/grlee77/gists{/gist_id}","starred_url":"https://api.github.com/users/grlee77/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grlee77/subscriptions","organizations_url":"https://api.github.com/users/grlee77/orgs","repos_url":"https://api.github.com/users/grlee77/repos","events_url":"https://api.github.com/users/grlee77/events{/privacy}","received_events_url":"https://api.github.com/users/grlee77/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/grlee77/scikit-image","description":"Image Processing SciKit (Toolbox for SciPy)","fork":true,"url":"https://api.github.com/repos/grlee77/scikit-image","forks_url":"https://api.github.com/repos/grlee77/scikit-image/forks","keys_url":"https://api.github.com/repos/grlee77/scikit-image/keys{/key_id}","collaborators_url":"https://api.github.com/repos/grlee77/scikit-image/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/grlee77/scikit-image/teams","hooks_url":"https://api.github.com/repos/grlee77/scikit-image/hooks","issue_events_url":"https://api.github.com/repos/grlee77/scikit-image/issues/events{/number}","events_url":"https://api.github.com/repos/grlee77/scikit-image/events","assignees_url":"https://api.github.com/repos/grlee77/scikit-image/assignees{/user}","branches_url":"https://api.github.com/repos/grlee77/scikit-image/branches{/branch}","tags_url":"https://api.github.com/repos/grlee77/scikit-image/tags","blobs_url":"https://api.github.com/repos/grlee77/scikit-image/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/grlee77/scikit-image/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/grlee77/scikit-image/git/refs{/sha}","trees_url":"https://api.github.com/repos/grlee77/scikit-image/git/trees{/sha}","statuses_url":"https://api.github.com/repos/grlee77/scikit-image/statuses/{sha}","languages_url":"https://api.github.com/repos/grlee77/scikit-image/languages","stargazers_url":"https://api.github.com/repos/grlee77/scikit-image/stargazers","contributors_url":"https://api.github.com/repos/grlee77/scikit-image/contributors","subscribers_url":"https://api.github.com/repos/grlee77/scikit-image/subscribers","subscription_url":"https://api.github.com/repos/grlee77/scikit-image/subscription","commits_url":"https://api.github.com/repos/grlee77/scikit-image/commits{/sha}","git_commits_url":"https://api.github.com/repos/grlee77/scikit-image/git/commits{/sha}","comments_url":"https://api.github.com/repos/grlee77/scikit-image/comments{/number}","issue_comment_url":"https://api.github.com/repos/grlee77/scikit-image/issues/comments{/number}","contents_url":"https://api.github.com/repos/grlee77/scikit-image/contents/{+path}","compare_url":"https://api.github.com/repos/grlee77/scikit-image/compare/{base}...{head}","merges_url":"https://api.github.com/repos/grlee77/scikit-image/merges","archive_url":"https://api.github.com/repos/grlee77/scikit-image/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/grlee77/scikit-image/downloads","issues_url":"https://api.github.com/repos/grlee77/scikit-image/issues{/number}","pulls_url":"https://api.github.com/repos/grlee77/scikit-image/pulls{/number}","milestones_url":"https://api.github.com/repos/grlee77/scikit-image/milestones{/number}","notifications_url":"https://api.github.com/repos/grlee77/scikit-image/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/grlee77/scikit-image/labels{/name}","releases_url":"https://api.github.com/repos/grlee77/scikit-image/releases{/id}","created_at":"2014-09-09T18:00:05Z","updated_at":"2015-03-05T22:53:39Z","pushed_at":"2015-05-20T22:50:03Z","git_url":"git://github.com/grlee77/scikit-image.git","ssh_url":"git@github.com:grlee77/scikit-image.git","clone_url":"https://github.com/grlee77/scikit-image.git","svn_url":"https://github.com/grlee77/scikit-image","homepage":"http://scikit-image.org","size":39056,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"scikit-image:master","ref":"master","sha":"1a32745645bb31203d4d18ae1f1e118af8b672a4","user":{"login":"scikit-image","id":897180,"avatar_url":"https://avatars.githubusercontent.com/u/897180?v=3","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://avatars.githubusercontent.com/u/897180?v=3","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}","created_at":"2011-07-07T22:07:20Z","updated_at":"2015-05-21T05:23:03Z","pushed_at":"2015-05-21T07:02:26Z","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":68105,"stargazers_count":706,"watchers_count":706,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":361,"mirror_url":null,"open_issues_count":177,"forks":361,"open_issues":177,"watchers":706,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/scikit-image/scikit-image/pulls/1522"},"html":{"href":"https://github.com/scikit-image/scikit-image/pull/1522"},"issue":{"href":"https://api.github.com/repos/scikit-image/scikit-image/issues/1522"},"comments":{"href":"https://api.github.com/repos/scikit-image/scikit-image/issues/1522/comments"},"review_comments":{"href":"https://api.github.com/repos/scikit-image/scikit-image/pulls/1522/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/1522/commits"},"statuses":{"href":"https://api.github.com/repos/scikit-image/scikit-image/statuses/3a45e3c89a2a99462aea72c0d223a09234fba882"}}}}