{"action":"created","comment":{"url":"https://api.github.com/repos/scikit-image/scikit-image/pulls/comments/80188323","id":80188323,"diff_hunk":"@@ -0,0 +1,264 @@\n+from __future__ import print_function, division\n+import numpy as np\n+from scipy import ndimage as ndi\n+from ..util import img_as_ubyte\n+from .._shared.utils import assert_nD\n+\n+\n+def kb(image, min_scale=10, max_scale=25, saliency_threshold=0.6, clustering_threshold=7):\n+    \"\"\"Finds salient regions in the given grayscale image.For each point x\n+    the method picks a scale s and calculates salient score Y(x,s).\n+    By comparing Y(x,s) of different points x the detector can rank\n+    the saliency of points and pick the most representative ones.\n+\n+    Parameters\n+    ----------\n+    image : ndarray\n+        Input grayscale image\n+    min_scale : int, optional\n+        Minimum scale for the keypoints detected.\n+    max_scale : int, optional\n+        Maximum scale for the keypoints detected.\n+    saliency_threshold : float, optional.\n+        Features with saliency score satisfying threshold will be considered.\n+    clustering_threshold : int, optional\n+        Variance among the regions should be smaller than this threshold\n+        for sufficient clustering.\n+\n+    Returns\n+    -------\n+    A : (n, 3) ndarray\n+        A 2d array with each row representing 3 values, '(y, x, scale)'\n+        where '(y,x)' are coordinates of the region and 'scale' is the\n+        size of corresponding salient region.\n+\n+    References\n+    ----------\n+    https://en.wikipedia.org/wiki/Kadir-Brady_saliency_detector\n+\n+    Examples\n+    --------\n+    >>> from skimage.feature import kb\n+    >>> from skimage.color import rgb2gray\n+    >>> from skimage.data import astronaut\n+    >>> image = astronaut()[100:300, 100:300]\n+    >>> kb(rgb2gray(image))\n+    array([[   0.875,  102.625,   12.75 ],\n+           [ 127.875,   72.125,   12.   ],\n+           [   1.875,  146.125,   12.   ],\n+           [ 163.875,  149.875,   14.   ],\n+           [  14.875,   75.125,   14.   ],\n+           [ 155.125,  105.875,   12.   ],\n+           [  92.75 ,   46.625,   14.   ],\n+           [ 159.625,  127.25 ,   18.25 ],\n+           [ 107.625,   16.5  ,   12.25 ],\n+           [   0.875,  191.875,   14.5  ],\n+           [  45.625,  142.125,   12.5  ],\n+           [ 137.875,  192.   ,   12.25 ],\n+           [ 106.625,   59.125,   13.   ],\n+           [  91.375,   18.5  ,   13.25 ],\n+           [ 152.   ,  184.125,   12.5  ],\n+           [ 149.125,   91.125,   12.   ],\n+           [ 122.75 ,   28.875,   12.75 ],\n+           [  82.625,  120.   ,   13.75 ],\n+           [  95.875,   30.75 ,   12.25 ],\n+           [  16.125,  165.25 ,   15.75 ],\n+           [  57.875,   76.375,   23.5  ],\n+           [  86.125,   56.5  ,   12.   ],\n+           [  80.75 ,   29.875,   12.5  ]])\n+\n+    Notes\n+    -----\n+    The radius of each region is 'scale/2'.\n+    \"\"\"\n+\n+    assert_nD(image, 2)\n+\n+    # scales for keypoints\n+    scales = np.array([_ for _ in range(min_scale, max_scale, 2)])\n+    # detect keypoints in scale-space\n+    base_regions = detect(image, scales)\n+    # pruning based on thresholds\n+    regions = prune(base_regions, saliency_threshold, clustering_threshold, K=7)\n+\n+    return regions.T\n+\n+\n+def detect(image, scales):\n+    \"\"\" Calculates the Shannon entropy of local image attributes for each region\n+    over a range of scales, and weight them based on the difference between\n+    the local descriptors around scale-space.\n+\n+    Parameters\n+    ----------\n+    image : ndarray\n+        Input grayscale image\n+    scales : ndarray\n+        Scales for key regions\n+    Returns\n+    -------\n+    A : (4, n) ndarray\n+        A 2d array with each column representing 4 values, '(gamma, scale, y, x)'\n+        where '(y, x)' are coordinates of the region, 'scale' is the\n+        size of salient region, and 'gamma' is the saliency score.\n+    \"\"\"\n+    image = img_as_ubyte(image)\n+    nr, nc = image.shape\n+    # find pixels that we are going to examine\n+    mask = np.ones((nr, nc))\n+    r, c = np.nonzero(mask)\n+    nPix = len(r)\n+\n+    nScales = len(scales)\n+    intensity_edges = [_ for _ in range(0, 257, 16)]\n+\n+    previous_h = np.zeros((len(intensity_edges)-1, nPix))\n+    weights = np.zeros((nScales, nPix))\n+    entropy = np.zeros((nScales, nPix))\n+\n+    # iterate through every possible region\n+    # iterate through scales\n+    for s_count in range(nScales):\n+        scale_size = scales[s_count]\n+        radius = int((scale_size)/2)\n+\n+        # iterate through pixels\n+        for i in range(nPix):","path":"skimage/feature/_kb.py","position":126,"original_position":126,"commit_id":"35e9657b0571d292492d1dffbab2e4e6af758a72","original_commit_id":"35e9657b0571d292492d1dffbab2e4e6af758a72","user":{"login":"jni","id":492549,"avatar_url":"https://avatars.githubusercontent.com/u/492549?v=3","gravatar_id":"","url":"https://api.github.com/users/jni","html_url":"https://github.com/jni","followers_url":"https://api.github.com/users/jni/followers","following_url":"https://api.github.com/users/jni/following{/other_user}","gists_url":"https://api.github.com/users/jni/gists{/gist_id}","starred_url":"https://api.github.com/users/jni/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jni/subscriptions","organizations_url":"https://api.github.com/users/jni/orgs","repos_url":"https://api.github.com/users/jni/repos","events_url":"https://api.github.com/users/jni/events{/privacy}","received_events_url":"https://api.github.com/users/jni/received_events","type":"User","site_admin":false},"body":"(and maybe `np.pad` and `util.crop`!)","created_at":"2016-09-23T06:34:02Z","updated_at":"2016-09-23T06:49:30Z","html_url":"https://github.com/scikit-image/scikit-image/pull/2299#discussion_r80188323","pull_request_url":"https://api.github.com/repos/scikit-image/scikit-image/pulls/2299","_links":{"self":{"href":"https://api.github.com/repos/scikit-image/scikit-image/pulls/comments/80188323"},"html":{"href":"https://github.com/scikit-image/scikit-image/pull/2299#discussion_r80188323"},"pull_request":{"href":"https://api.github.com/repos/scikit-image/scikit-image/pulls/2299"}}},"pull_request":{"url":"https://api.github.com/repos/scikit-image/scikit-image/pulls/2299","id":84660021,"html_url":"https://github.com/scikit-image/scikit-image/pull/2299","diff_url":"https://github.com/scikit-image/scikit-image/pull/2299.diff","patch_url":"https://github.com/scikit-image/scikit-image/pull/2299.patch","issue_url":"https://api.github.com/repos/scikit-image/scikit-image/issues/2299","number":2299,"state":"open","locked":false,"title":"Implemented Kadir and Brady's Saliency detection","user":{"login":"parulsethi","id":11822050,"avatar_url":"https://avatars.githubusercontent.com/u/11822050?v=3","gravatar_id":"","url":"https://api.github.com/users/parulsethi","html_url":"https://github.com/parulsethi","followers_url":"https://api.github.com/users/parulsethi/followers","following_url":"https://api.github.com/users/parulsethi/following{/other_user}","gists_url":"https://api.github.com/users/parulsethi/gists{/gist_id}","starred_url":"https://api.github.com/users/parulsethi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/parulsethi/subscriptions","organizations_url":"https://api.github.com/users/parulsethi/orgs","repos_url":"https://api.github.com/users/parulsethi/repos","events_url":"https://api.github.com/users/parulsethi/events{/privacy}","received_events_url":"https://api.github.com/users/parulsethi/received_events","type":"User","site_admin":false},"body":"## Description\r\nThis PR implements Kadir and Brady's Saliency detection algorithm which calculates the saliency score by measuring the entropy of the region's descriptor(to find locally complex regions) and weigh them by the difference over multiple scales to select features that are globally discriminative.\r\nResult over astronaut():\r\n<img width=\"486\" alt=\"screen shot 2016-09-09 at 12 07 44 am\" src=\"https://cloud.githubusercontent.com/assets/11822050/18388850/d8e08e16-76c0-11e6-92e7-6d2d52173e51.png\">\r\n\r\nAs this is my first contribution to not only scikit-image but open-source too, so please suggest the changes that are required in order to merge this, if you are interested in adding this feature.\r\nI haven't yet prepared the doc example as their are some parameters in this algorithm over which i need your suggestion that whether to leave them as optional or set it to the optimized one. These are the saliency and clustering thresholds.\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- [ ] Gallery example in `./doc/examples` (new features only)\r\n- [ ] Unit tests\r\n\r\n## References\r\nKadir, Timor, and Michael Brady. \"Saliency, scale and image description.\" International Journal of Computer Vision 45.2 (2001): 83-105.","created_at":"2016-09-09T14:27:01Z","updated_at":"2016-09-23T06:49:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b37891172f194e52cae65a1c959680a9ad06cf6d","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/scikit-image/scikit-image/pulls/2299/commits","review_comments_url":"https://api.github.com/repos/scikit-image/scikit-image/pulls/2299/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/2299/comments","statuses_url":"https://api.github.com/repos/scikit-image/scikit-image/statuses/35e9657b0571d292492d1dffbab2e4e6af758a72","head":{"label":"parulsethi:kbSaliencyDetection","ref":"kbSaliencyDetection","sha":"35e9657b0571d292492d1dffbab2e4e6af758a72","user":{"login":"parulsethi","id":11822050,"avatar_url":"https://avatars.githubusercontent.com/u/11822050?v=3","gravatar_id":"","url":"https://api.github.com/users/parulsethi","html_url":"https://github.com/parulsethi","followers_url":"https://api.github.com/users/parulsethi/followers","following_url":"https://api.github.com/users/parulsethi/following{/other_user}","gists_url":"https://api.github.com/users/parulsethi/gists{/gist_id}","starred_url":"https://api.github.com/users/parulsethi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/parulsethi/subscriptions","organizations_url":"https://api.github.com/users/parulsethi/orgs","repos_url":"https://api.github.com/users/parulsethi/repos","events_url":"https://api.github.com/users/parulsethi/events{/privacy}","received_events_url":"https://api.github.com/users/parulsethi/received_events","type":"User","site_admin":false},"repo":{"id":67429177,"name":"scikit-image","full_name":"parulsethi/scikit-image","owner":{"login":"parulsethi","id":11822050,"avatar_url":"https://avatars.githubusercontent.com/u/11822050?v=3","gravatar_id":"","url":"https://api.github.com/users/parulsethi","html_url":"https://github.com/parulsethi","followers_url":"https://api.github.com/users/parulsethi/followers","following_url":"https://api.github.com/users/parulsethi/following{/other_user}","gists_url":"https://api.github.com/users/parulsethi/gists{/gist_id}","starred_url":"https://api.github.com/users/parulsethi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/parulsethi/subscriptions","organizations_url":"https://api.github.com/users/parulsethi/orgs","repos_url":"https://api.github.com/users/parulsethi/repos","events_url":"https://api.github.com/users/parulsethi/events{/privacy}","received_events_url":"https://api.github.com/users/parulsethi/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/parulsethi/scikit-image","description":"Image Processing SciKit (Toolbox for SciPy)","fork":true,"url":"https://api.github.com/repos/parulsethi/scikit-image","forks_url":"https://api.github.com/repos/parulsethi/scikit-image/forks","keys_url":"https://api.github.com/repos/parulsethi/scikit-image/keys{/key_id}","collaborators_url":"https://api.github.com/repos/parulsethi/scikit-image/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/parulsethi/scikit-image/teams","hooks_url":"https://api.github.com/repos/parulsethi/scikit-image/hooks","issue_events_url":"https://api.github.com/repos/parulsethi/scikit-image/issues/events{/number}","events_url":"https://api.github.com/repos/parulsethi/scikit-image/events","assignees_url":"https://api.github.com/repos/parulsethi/scikit-image/assignees{/user}","branches_url":"https://api.github.com/repos/parulsethi/scikit-image/branches{/branch}","tags_url":"https://api.github.com/repos/parulsethi/scikit-image/tags","blobs_url":"https://api.github.com/repos/parulsethi/scikit-image/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/parulsethi/scikit-image/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/parulsethi/scikit-image/git/refs{/sha}","trees_url":"https://api.github.com/repos/parulsethi/scikit-image/git/trees{/sha}","statuses_url":"https://api.github.com/repos/parulsethi/scikit-image/statuses/{sha}","languages_url":"https://api.github.com/repos/parulsethi/scikit-image/languages","stargazers_url":"https://api.github.com/repos/parulsethi/scikit-image/stargazers","contributors_url":"https://api.github.com/repos/parulsethi/scikit-image/contributors","subscribers_url":"https://api.github.com/repos/parulsethi/scikit-image/subscribers","subscription_url":"https://api.github.com/repos/parulsethi/scikit-image/subscription","commits_url":"https://api.github.com/repos/parulsethi/scikit-image/commits{/sha}","git_commits_url":"https://api.github.com/repos/parulsethi/scikit-image/git/commits{/sha}","comments_url":"https://api.github.com/repos/parulsethi/scikit-image/comments{/number}","issue_comment_url":"https://api.github.com/repos/parulsethi/scikit-image/issues/comments{/number}","contents_url":"https://api.github.com/repos/parulsethi/scikit-image/contents/{+path}","compare_url":"https://api.github.com/repos/parulsethi/scikit-image/compare/{base}...{head}","merges_url":"https://api.github.com/repos/parulsethi/scikit-image/merges","archive_url":"https://api.github.com/repos/parulsethi/scikit-image/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/parulsethi/scikit-image/downloads","issues_url":"https://api.github.com/repos/parulsethi/scikit-image/issues{/number}","pulls_url":"https://api.github.com/repos/parulsethi/scikit-image/pulls{/number}","milestones_url":"https://api.github.com/repos/parulsethi/scikit-image/milestones{/number}","notifications_url":"https://api.github.com/repos/parulsethi/scikit-image/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/parulsethi/scikit-image/labels{/name}","releases_url":"https://api.github.com/repos/parulsethi/scikit-image/releases{/id}","deployments_url":"https://api.github.com/repos/parulsethi/scikit-image/deployments","created_at":"2016-09-05T14:50:29Z","updated_at":"2016-09-05T14:50:32Z","pushed_at":"2016-09-14T22:55:47Z","git_url":"git://github.com/parulsethi/scikit-image.git","ssh_url":"git@github.com:parulsethi/scikit-image.git","clone_url":"https://github.com/parulsethi/scikit-image.git","svn_url":"https://github.com/parulsethi/scikit-image","homepage":"http://scikit-image.org","size":41383,"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":"b1a020790cb4f0b5cad3fc4249b0e834e05d4cbe","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-09-22T21:00:10Z","pushed_at":"2016-09-22T20:10:32Z","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":75345,"stargazers_count":1253,"watchers_count":1253,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":637,"mirror_url":null,"open_issues_count":319,"forks":637,"open_issues":319,"watchers":1253,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/scikit-image/scikit-image/pulls/2299"},"html":{"href":"https://github.com/scikit-image/scikit-image/pull/2299"},"issue":{"href":"https://api.github.com/repos/scikit-image/scikit-image/issues/2299"},"comments":{"href":"https://api.github.com/repos/scikit-image/scikit-image/issues/2299/comments"},"review_comments":{"href":"https://api.github.com/repos/scikit-image/scikit-image/pulls/2299/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/2299/commits"},"statuses":{"href":"https://api.github.com/repos/scikit-image/scikit-image/statuses/35e9657b0571d292492d1dffbab2e4e6af758a72"}}}}
{"actor":{"display_login":"jni"}}