{"action":"created","issue":{"url":"https://api.github.com/repos/scikit-image/scikit-image/issues/1529","labels_url":"https://api.github.com/repos/scikit-image/scikit-image/issues/1529/labels{/name}","comments_url":"https://api.github.com/repos/scikit-image/scikit-image/issues/1529/comments","events_url":"https://api.github.com/repos/scikit-image/scikit-image/issues/1529/events","html_url":"https://github.com/scikit-image/scikit-image/issues/1529","id":81001531,"number":1529,"title":"Chaining issue: X -> Grey -> Resize -> Gaussian !!->!! Median ","user":{"login":"sschnug","id":8052880,"avatar_url":"https://avatars.githubusercontent.com/u/8052880?v=3","gravatar_id":"","url":"https://api.github.com/users/sschnug","html_url":"https://github.com/sschnug","followers_url":"https://api.github.com/users/sschnug/followers","following_url":"https://api.github.com/users/sschnug/following{/other_user}","gists_url":"https://api.github.com/users/sschnug/gists{/gist_id}","starred_url":"https://api.github.com/users/sschnug/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sschnug/subscriptions","organizations_url":"https://api.github.com/users/sschnug/orgs","repos_url":"https://api.github.com/users/sschnug/repos","events_url":"https://api.github.com/users/sschnug/events{/privacy}","received_events_url":"https://api.github.com/users/sschnug/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2015-05-26T15:00:48Z","updated_at":"2015-05-28T22:24:30Z","closed_at":null,"body":"Hi, i'm using skimage for the first time (one day of experience; it looks like a very very interesting library) for implementing a perceptual hash algorithm on images.\r\n\r\nPlaying around with my prototype-implementation (not that complex), **i observed the following error**:\r\n```\r\n    self.img = skimage.filters.median(self.img, self.preprocess_median_filter_ne\r\nighborhood)\r\n  File \"C:\\Miniconda_v2\\lib\\site-packages\\skimage\\filters\\rank\\generic.py\", line\r\n 422, in median\r\n    shift_x=shift_x, shift_y=shift_y)\r\n  File \"C:\\Miniconda_v2\\lib\\site-packages\\skimage\\filters\\rank\\generic.py\", line\r\n 77, in _apply_scalar_per_pixel\r\n    out_dtype)\r\n  File \"C:\\Miniconda_v2\\lib\\site-packages\\skimage\\filters\\rank\\generic.py\", line\r\n 36, in _handle_input\r\n    image = img_as_ubyte(image)\r\n  File \"C:\\Miniconda_v2\\lib\\site-packages\\skimage\\util\\dtype.py\", line 364, in i\r\nmg_as_ubyte\r\n    return convert(image, np.uint8, force_copy)\r\n  File \"C:\\Miniconda_v2\\lib\\site-packages\\skimage\\util\\dtype.py\", line 195, in c\r\nonvert\r\n    raise ValueError(\"Images of type float must be between -1 and 1.\")\r\nValueError: Images of type float must be between -1 and 1.\r\n```\r\nI found the open issue #1334, but this didn't help and i think that my chain may be even simpler.\r\n\r\nLet's look at the **chaining-sequence i implemented**:\r\n````python\r\nimg = skimage.data.load(\"x.jpg\")\r\nimg = skimage.color.rgb2grey(img)\r\nimg = skimage.transform.resize(img, (512, 384)) # will be downscaled\r\nimg = skimage.filters.gaussian_filter(img, 1.0)\r\nimg = skimage.filters.median(img, skimage.morphology.disk(1))\r\n# CRASHES HERE\r\n# hist_equalization + a lot of statistics stuff follows -> will work for some images\r\n````\r\nThis is working for 8 out of 9 manually tested images. One of these (not different in style; all img's are screenshots from video-media or transformed versions of these) will crash with the error posted above! \r\n\r\n**skimage print's out the following warning during the call to \"filter.median\"** (printed once during my program; i assume this is printed at the first call to filter.median):\r\n```\r\nC:\\Miniconda_v2\\lib\\site-packages\\skimage\\util\\dtype.py:111: UserWarning: Possib\r\nle precision loss when converting from float64 to uint8\r\n  \"%s to %s\" % (dtypeobj_in, dtypeobj))\r\n```\r\n\r\n- Any ideas for handling this error?\r\n- Is the chaining of a gaussian and a median-filter not valid? \r\n\r\nThanks!\r\n- Sascha\r\n\r\n**Edit 1**: I just found #1419  \"median only for integer-type images\" -> I need to have a look at this, but skimage will accept my non-integer image when i call filter.median!"},"comment":{"url":"https://api.github.com/repos/scikit-image/scikit-image/issues/comments/106617103","html_url":"https://github.com/scikit-image/scikit-image/issues/1529#issuecomment-106617103","issue_url":"https://api.github.com/repos/scikit-image/scikit-image/issues/1529","id":106617103,"user":{"login":"stefanv","id":45071,"avatar_url":"https://avatars.githubusercontent.com/u/45071?v=3","gravatar_id":"","url":"https://api.github.com/users/stefanv","html_url":"https://github.com/stefanv","followers_url":"https://api.github.com/users/stefanv/followers","following_url":"https://api.github.com/users/stefanv/following{/other_user}","gists_url":"https://api.github.com/users/stefanv/gists{/gist_id}","starred_url":"https://api.github.com/users/stefanv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stefanv/subscriptions","organizations_url":"https://api.github.com/users/stefanv/orgs","repos_url":"https://api.github.com/users/stefanv/repos","events_url":"https://api.github.com/users/stefanv/events{/privacy}","received_events_url":"https://api.github.com/users/stefanv/received_events","type":"User","site_admin":false},"created_at":"2015-05-28T22:24:30Z","updated_at":"2015-05-28T22:24:30Z","body":"How about a simple rule that can be applied consistently: clip to the maximum input value and document it as such."}}