{"action":"created","comment":{"url":"https://api.github.com/repos/scikit-image/scikit-image/pulls/comments/93824942","pull_request_review_id":14360705,"id":93824942,"diff_hunk":"@@ -719,3 +722,172 @@ def threshold_triangle(image, nbins=256):\n         arg_level = nbins - arg_level - 1\n \n     return bin_centers[arg_level]\n+\n+\n+def _mean_std(image, w):\n+    \"\"\"Return local mean and standard deviation of each pixel using a\n+    neighborhood defined by a rectangular window with size w times w.\n+    The algorithm uses integral images to speedup computation. This is\n+    used by threshold_niblack and threshold_sauvola.\n+\n+    Parameters\n+    ----------\n+    image : (N, M) ndarray\n+        Input image.\n+    w : int\n+        Odd window size (e.g. 3, 5, 7, ..., 21, ...).\n+\n+    Returns\n+    -------\n+    m : 2-D array of same size of image with local mean values.\n+    s : 2-D array of same size of image with local standard\n+        deviation values.\n+\n+    References\n+    ----------\n+    .. [1] F. Shafait, D. Keysers, and T. M. Breuel, \"Efficient\n+           implementation of local adaptive thresholding techniques\n+           using integral images.\" in Document Recognition and\n+           Retrieval XV, (San Jose, USA), Jan. 2008.\n+           DOI:10.1117/12.767755\n+    \"\"\"\n+    from skimage.transform.integral import integral_image\n+\n+    if w == 1 or w % 2 == 0:\n+        raise ValueError(\n+            \"Window size w = %s must be odd and greater than 1.\" % (w))\n+    I = integral_image(image)  # Integral Image.\n+\n+    # Pad left and top of Integral image with zeros\n+    I = np.vstack((np.zeros((1, I.shape[1]), I.dtype), I))\n+    I = np.hstack((np.zeros((I.shape[0], 1), I.dtype), I))\n+\n+    kern = np.zeros((w + 1, w + 1))\n+    kern[0, 0], kern[-1, -1] = 1, 1\n+    kern[[0, -1], [-1, 0]] = -1","path":"skimage/filters/thresholding.py","position":63,"original_position":63,"commit_id":"fe89d6bdd61bedcba1fd3013e0f341d6581e9903","original_commit_id":"fe89d6bdd61bedcba1fd3013e0f341d6581e9903","user":{"login":"soupault","id":1315589,"avatar_url":"https://avatars.githubusercontent.com/u/1315589?v=3","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},"body":"Let's avoid 2 different ways of assignment here.","created_at":"2016-12-25T07:42:56Z","updated_at":"2016-12-25T07:52:05Z","html_url":"https://github.com/scikit-image/scikit-image/pull/2266#discussion_r93824942","pull_request_url":"https://api.github.com/repos/scikit-image/scikit-image/pulls/2266","_links":{"self":{"href":"https://api.github.com/repos/scikit-image/scikit-image/pulls/comments/93824942"},"html":{"href":"https://github.com/scikit-image/scikit-image/pull/2266#discussion_r93824942"},"pull_request":{"href":"https://api.github.com/repos/scikit-image/scikit-image/pulls/2266"}}},"pull_request":{"url":"https://api.github.com/repos/scikit-image/scikit-image/pulls/2266","id":82997250,"html_url":"https://github.com/scikit-image/scikit-image/pull/2266","diff_url":"https://github.com/scikit-image/scikit-image/pull/2266.diff","patch_url":"https://github.com/scikit-image/scikit-image/pull/2266.patch","issue_url":"https://api.github.com/repos/scikit-image/scikit-image/issues/2266","number":2266,"state":"open","locked":false,"title":"local threshold niblack sauvola (from Jeysonmc PR)","user":{"login":"sciunto","id":335370,"avatar_url":"https://avatars.githubusercontent.com/u/335370?v=3","gravatar_id":"","url":"https://api.github.com/users/sciunto","html_url":"https://github.com/sciunto","followers_url":"https://api.github.com/users/sciunto/followers","following_url":"https://api.github.com/users/sciunto/following{/other_user}","gists_url":"https://api.github.com/users/sciunto/gists{/gist_id}","starred_url":"https://api.github.com/users/sciunto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sciunto/subscriptions","organizations_url":"https://api.github.com/users/sciunto/orgs","repos_url":"https://api.github.com/users/sciunto/repos","events_url":"https://api.github.com/users/sciunto/events{/privacy}","received_events_url":"https://api.github.com/users/sciunto/received_events","type":"User","site_admin":false},"body":"This PR aims to revive #905. I rebased the original PR (not that easy) and squashed the commits (was helping). Now, I'm iterating over it to put it along our standards.\n\nNote that imagej also implements these algorithms. I think it's worth it to add them to skimage.\nhttp://imagej.net/Auto_Local_Threshold\n\nHere is a screenshot of what I got with the example implemented by the original author.\n![sphx_glr_plot_niblack_sauvola_001](https://cloud.githubusercontent.com/assets/335370/18029853/462b6ce2-6ca4-11e6-8769-6f943e7db020.png)\n\nTODO list:\n- [x] Add Jeyson Molina in contributors.txt\n- [x] DOI\n- [x] Remove convert float to ubyte\n- [x] Return threshold and not thresholded image? See #2121\n- [x] Split threshold_sauvola into 3 methods\n- [ ] p and q real constants or parameters?\n- [ ] Check implementation against papers\n- [ ] Check if tests can be improved.\n\nPapers:\n- Niblack DOI:10.1016/S0031-3203(99)00055-2\n- Wolf DOI:10.1007/s10044-003-0197-7\n- Phansalskar DOI:10.1109/ICCSP.2011.5739305\n","created_at":"2016-08-27T20:06:44Z","updated_at":"2016-12-25T07:52:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bcdf3c0dc5d39bc85b51eb41f195dcb17747b569","assignee":{"login":"emmanuelle","id":263366,"avatar_url":"https://avatars.githubusercontent.com/u/263366?v=3","gravatar_id":"","url":"https://api.github.com/users/emmanuelle","html_url":"https://github.com/emmanuelle","followers_url":"https://api.github.com/users/emmanuelle/followers","following_url":"https://api.github.com/users/emmanuelle/following{/other_user}","gists_url":"https://api.github.com/users/emmanuelle/gists{/gist_id}","starred_url":"https://api.github.com/users/emmanuelle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/emmanuelle/subscriptions","organizations_url":"https://api.github.com/users/emmanuelle/orgs","repos_url":"https://api.github.com/users/emmanuelle/repos","events_url":"https://api.github.com/users/emmanuelle/events{/privacy}","received_events_url":"https://api.github.com/users/emmanuelle/received_events","type":"User","site_admin":false},"assignees":[{"login":"emmanuelle","id":263366,"avatar_url":"https://avatars.githubusercontent.com/u/263366?v=3","gravatar_id":"","url":"https://api.github.com/users/emmanuelle","html_url":"https://github.com/emmanuelle","followers_url":"https://api.github.com/users/emmanuelle/followers","following_url":"https://api.github.com/users/emmanuelle/following{/other_user}","gists_url":"https://api.github.com/users/emmanuelle/gists{/gist_id}","starred_url":"https://api.github.com/users/emmanuelle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/emmanuelle/subscriptions","organizations_url":"https://api.github.com/users/emmanuelle/orgs","repos_url":"https://api.github.com/users/emmanuelle/repos","events_url":"https://api.github.com/users/emmanuelle/events{/privacy}","received_events_url":"https://api.github.com/users/emmanuelle/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/scikit-image/scikit-image/milestones/6","html_url":"https://github.com/scikit-image/scikit-image/milestone/6","labels_url":"https://api.github.com/repos/scikit-image/scikit-image/milestones/6/labels","id":1467848,"number":6,"title":"0.13","description":null,"creator":{"login":"ahojnnes","id":134307,"avatar_url":"https://avatars.githubusercontent.com/u/134307?v=3","gravatar_id":"","url":"https://api.github.com/users/ahojnnes","html_url":"https://github.com/ahojnnes","followers_url":"https://api.github.com/users/ahojnnes/followers","following_url":"https://api.github.com/users/ahojnnes/following{/other_user}","gists_url":"https://api.github.com/users/ahojnnes/gists{/gist_id}","starred_url":"https://api.github.com/users/ahojnnes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ahojnnes/subscriptions","organizations_url":"https://api.github.com/users/ahojnnes/orgs","repos_url":"https://api.github.com/users/ahojnnes/repos","events_url":"https://api.github.com/users/ahojnnes/events{/privacy}","received_events_url":"https://api.github.com/users/ahojnnes/received_events","type":"User","site_admin":false},"open_issues":28,"closed_issues":32,"state":"open","created_at":"2015-12-19T16:45:03Z","updated_at":"2016-12-24T14:09:53Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/scikit-image/scikit-image/pulls/2266/commits","review_comments_url":"https://api.github.com/repos/scikit-image/scikit-image/pulls/2266/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/2266/comments","statuses_url":"https://api.github.com/repos/scikit-image/scikit-image/statuses/fe89d6bdd61bedcba1fd3013e0f341d6581e9903","head":{"label":"sciunto:jeysonmc-localthresh_niblack_sauvola2","ref":"jeysonmc-localthresh_niblack_sauvola2","sha":"fe89d6bdd61bedcba1fd3013e0f341d6581e9903","user":{"login":"sciunto","id":335370,"avatar_url":"https://avatars.githubusercontent.com/u/335370?v=3","gravatar_id":"","url":"https://api.github.com/users/sciunto","html_url":"https://github.com/sciunto","followers_url":"https://api.github.com/users/sciunto/followers","following_url":"https://api.github.com/users/sciunto/following{/other_user}","gists_url":"https://api.github.com/users/sciunto/gists{/gist_id}","starred_url":"https://api.github.com/users/sciunto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sciunto/subscriptions","organizations_url":"https://api.github.com/users/sciunto/orgs","repos_url":"https://api.github.com/users/sciunto/repos","events_url":"https://api.github.com/users/sciunto/events{/privacy}","received_events_url":"https://api.github.com/users/sciunto/received_events","type":"User","site_admin":false},"repo":{"id":8113365,"name":"scikit-image","full_name":"sciunto/scikit-image","owner":{"login":"sciunto","id":335370,"avatar_url":"https://avatars.githubusercontent.com/u/335370?v=3","gravatar_id":"","url":"https://api.github.com/users/sciunto","html_url":"https://github.com/sciunto","followers_url":"https://api.github.com/users/sciunto/followers","following_url":"https://api.github.com/users/sciunto/following{/other_user}","gists_url":"https://api.github.com/users/sciunto/gists{/gist_id}","starred_url":"https://api.github.com/users/sciunto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sciunto/subscriptions","organizations_url":"https://api.github.com/users/sciunto/orgs","repos_url":"https://api.github.com/users/sciunto/repos","events_url":"https://api.github.com/users/sciunto/events{/privacy}","received_events_url":"https://api.github.com/users/sciunto/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sciunto/scikit-image","description":"Image Processing SciKit (Toolbox for SciPy)","fork":true,"url":"https://api.github.com/repos/sciunto/scikit-image","forks_url":"https://api.github.com/repos/sciunto/scikit-image/forks","keys_url":"https://api.github.com/repos/sciunto/scikit-image/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sciunto/scikit-image/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sciunto/scikit-image/teams","hooks_url":"https://api.github.com/repos/sciunto/scikit-image/hooks","issue_events_url":"https://api.github.com/repos/sciunto/scikit-image/issues/events{/number}","events_url":"https://api.github.com/repos/sciunto/scikit-image/events","assignees_url":"https://api.github.com/repos/sciunto/scikit-image/assignees{/user}","branches_url":"https://api.github.com/repos/sciunto/scikit-image/branches{/branch}","tags_url":"https://api.github.com/repos/sciunto/scikit-image/tags","blobs_url":"https://api.github.com/repos/sciunto/scikit-image/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sciunto/scikit-image/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sciunto/scikit-image/git/refs{/sha}","trees_url":"https://api.github.com/repos/sciunto/scikit-image/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sciunto/scikit-image/statuses/{sha}","languages_url":"https://api.github.com/repos/sciunto/scikit-image/languages","stargazers_url":"https://api.github.com/repos/sciunto/scikit-image/stargazers","contributors_url":"https://api.github.com/repos/sciunto/scikit-image/contributors","subscribers_url":"https://api.github.com/repos/sciunto/scikit-image/subscribers","subscription_url":"https://api.github.com/repos/sciunto/scikit-image/subscription","commits_url":"https://api.github.com/repos/sciunto/scikit-image/commits{/sha}","git_commits_url":"https://api.github.com/repos/sciunto/scikit-image/git/commits{/sha}","comments_url":"https://api.github.com/repos/sciunto/scikit-image/comments{/number}","issue_comment_url":"https://api.github.com/repos/sciunto/scikit-image/issues/comments{/number}","contents_url":"https://api.github.com/repos/sciunto/scikit-image/contents/{+path}","compare_url":"https://api.github.com/repos/sciunto/scikit-image/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sciunto/scikit-image/merges","archive_url":"https://api.github.com/repos/sciunto/scikit-image/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sciunto/scikit-image/downloads","issues_url":"https://api.github.com/repos/sciunto/scikit-image/issues{/number}","pulls_url":"https://api.github.com/repos/sciunto/scikit-image/pulls{/number}","milestones_url":"https://api.github.com/repos/sciunto/scikit-image/milestones{/number}","notifications_url":"https://api.github.com/repos/sciunto/scikit-image/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sciunto/scikit-image/labels{/name}","releases_url":"https://api.github.com/repos/sciunto/scikit-image/releases{/id}","deployments_url":"https://api.github.com/repos/sciunto/scikit-image/deployments","created_at":"2013-02-09T18:48:40Z","updated_at":"2015-01-31T03:43:02Z","pushed_at":"2016-12-24T13:53:42Z","git_url":"git://github.com/sciunto/scikit-image.git","ssh_url":"git@github.com:sciunto/scikit-image.git","clone_url":"https://github.com/sciunto/scikit-image.git","svn_url":"https://github.com/sciunto/scikit-image","homepage":"http://scikit-image.org","size":44878,"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":"412a342ebcdf0b42117fea1a0fbff33ca93953ff","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}","deployments_url":"https://api.github.com/repos/scikit-image/scikit-image/deployments","created_at":"2011-07-07T22:07:20Z","updated_at":"2016-12-24T11:23:18Z","pushed_at":"2016-12-24T16:03:38Z","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":44691,"stargazers_count":1359,"watchers_count":1359,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":701,"mirror_url":null,"open_issues_count":341,"forks":701,"open_issues":341,"watchers":1359,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/scikit-image/scikit-image/pulls/2266"},"html":{"href":"https://github.com/scikit-image/scikit-image/pull/2266"},"issue":{"href":"https://api.github.com/repos/scikit-image/scikit-image/issues/2266"},"comments":{"href":"https://api.github.com/repos/scikit-image/scikit-image/issues/2266/comments"},"review_comments":{"href":"https://api.github.com/repos/scikit-image/scikit-image/pulls/2266/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/2266/commits"},"statuses":{"href":"https://api.github.com/repos/scikit-image/scikit-image/statuses/fe89d6bdd61bedcba1fd3013e0f341d6581e9903"}}}}
{"actor":{"display_login":"soupault"}}