{"action":"created","issue":{"url":"https://api.github.com/repos/scikit-image/scikit-image/issues/1541","labels_url":"https://api.github.com/repos/scikit-image/scikit-image/issues/1541/labels{/name}","comments_url":"https://api.github.com/repos/scikit-image/scikit-image/issues/1541/comments","events_url":"https://api.github.com/repos/scikit-image/scikit-image/issues/1541/events","html_url":"https://github.com/scikit-image/scikit-image/issues/1541","id":85145430,"number":1541,"title":"crash in CLAHE adapthist","user":{"login":"hunter-87","id":1197544,"avatar_url":"https://avatars.githubusercontent.com/u/1197544?v=3","gravatar_id":"","url":"https://api.github.com/users/hunter-87","html_url":"https://github.com/hunter-87","followers_url":"https://api.github.com/users/hunter-87/followers","following_url":"https://api.github.com/users/hunter-87/following{/other_user}","gists_url":"https://api.github.com/users/hunter-87/gists{/gist_id}","starred_url":"https://api.github.com/users/hunter-87/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hunter-87/subscriptions","organizations_url":"https://api.github.com/users/hunter-87/orgs","repos_url":"https://api.github.com/users/hunter-87/repos","events_url":"https://api.github.com/users/hunter-87/events{/privacy}","received_events_url":"https://api.github.com/users/hunter-87/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"blink1073","id":2096628,"avatar_url":"https://avatars.githubusercontent.com/u/2096628?v=3","gravatar_id":"","url":"https://api.github.com/users/blink1073","html_url":"https://github.com/blink1073","followers_url":"https://api.github.com/users/blink1073/followers","following_url":"https://api.github.com/users/blink1073/following{/other_user}","gists_url":"https://api.github.com/users/blink1073/gists{/gist_id}","starred_url":"https://api.github.com/users/blink1073/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/blink1073/subscriptions","organizations_url":"https://api.github.com/users/blink1073/orgs","repos_url":"https://api.github.com/users/blink1073/repos","events_url":"https://api.github.com/users/blink1073/events{/privacy}","received_events_url":"https://api.github.com/users/blink1073/received_events","type":"User","site_admin":false},"milestone":null,"comments":6,"created_at":"2015-06-04T15:23:49Z","updated_at":"2015-06-07T01:39:46Z","closed_at":null,"body":"Hi,\r\ni've found a possible bug in the adapthist implementation:\r\nto replicate the bug, it happens with the following input:\r\n\r\nfunction:  skimage.exposure.equalize_adapthist\r\nwith input\r\nany image of shape (1000, 236)\r\ntile_num_x = 12\r\ntile_num_y = 50\r\n\r\nit crash with error:\r\n```\r\n<type 'exceptions.ValueError'>: ((0, 54), (0, -2)) cannot contain negative values.\r\n```\r\nreading the code i think is in the part where w_pad and h_pad is calculated ( in this case w_pad is -2)\r\n\r\ni tried to fix it to avoid the crash but i'm unsure if it's the right solution:\r\nafter line 135: https://github.com/scikit-image/scikit-image/blob/master/skimage/exposure/_adapthist.py#L135\r\ni added:\r\n```\r\nif w_pad <0:\r\n    w_pad += width\r\nif h_pad <0:\r\n    h_pad += height\r\n```\r\n\r\ndo you think there is a better solution?\r\n\r\n\r\nedit: to replicate use\r\n\r\n```\r\nimport numpy as np\r\nfrom skimage.exposure import equalize_adapthist\r\na = np.ones((1000, 236))\r\nequalize_adapthist(a , ntiles_x= 12, ntiles_y=50)\r\n```"},"comment":{"url":"https://api.github.com/repos/scikit-image/scikit-image/issues/comments/109670476","html_url":"https://github.com/scikit-image/scikit-image/issues/1541#issuecomment-109670476","issue_url":"https://api.github.com/repos/scikit-image/scikit-image/issues/1541","id":109670476,"user":{"login":"blink1073","id":2096628,"avatar_url":"https://avatars.githubusercontent.com/u/2096628?v=3","gravatar_id":"","url":"https://api.github.com/users/blink1073","html_url":"https://github.com/blink1073","followers_url":"https://api.github.com/users/blink1073/followers","following_url":"https://api.github.com/users/blink1073/following{/other_user}","gists_url":"https://api.github.com/users/blink1073/gists{/gist_id}","starred_url":"https://api.github.com/users/blink1073/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/blink1073/subscriptions","organizations_url":"https://api.github.com/users/blink1073/orgs","repos_url":"https://api.github.com/users/blink1073/repos","events_url":"https://api.github.com/users/blink1073/events{/privacy}","received_events_url":"https://api.github.com/users/blink1073/received_events","type":"User","site_admin":false},"created_at":"2015-06-07T01:39:46Z","updated_at":"2015-06-07T01:39:46Z","body":"Or I should say it influences the stride of the new array."}}