{"action":"closed","issue":{"url":"https://api.github.com/repos/jcupitt/libvips/issues/555","repository_url":"https://api.github.com/repos/jcupitt/libvips","labels_url":"https://api.github.com/repos/jcupitt/libvips/issues/555/labels{/name}","comments_url":"https://api.github.com/repos/jcupitt/libvips/issues/555/comments","events_url":"https://api.github.com/repos/jcupitt/libvips/issues/555/events","html_url":"https://github.com/jcupitt/libvips/issues/555","id":188916421,"number":555,"title":"Rank function allows neither 0 nor the number of window pixels as index argument","user":{"login":"erdmann","id":406404,"avatar_url":"https://avatars.githubusercontent.com/u/406404?v=3","gravatar_id":"","url":"https://api.github.com/users/erdmann","html_url":"https://github.com/erdmann","followers_url":"https://api.github.com/users/erdmann/followers","following_url":"https://api.github.com/users/erdmann/following{/other_user}","gists_url":"https://api.github.com/users/erdmann/gists{/gist_id}","starred_url":"https://api.github.com/users/erdmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/erdmann/subscriptions","organizations_url":"https://api.github.com/users/erdmann/orgs","repos_url":"https://api.github.com/users/erdmann/repos","events_url":"https://api.github.com/users/erdmann/events{/privacy}","received_events_url":"https://api.github.com/users/erdmann/received_events","type":"User","site_admin":false},"labels":[{"id":15592123,"url":"https://api.github.com/repos/jcupitt/libvips/labels/bug","name":"bug","color":"e10c02","default":true},{"id":110039376,"url":"https://api.github.com/repos/jcupitt/libvips/labels/in%20development","name":"in development","color":"eb6420","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-11-12T15:11:24Z","updated_at":"2016-11-13T07:21:17Z","closed_at":"2016-11-13T07:21:17Z","body":"It appears that the rank function limits its arguments too much (or I am not understanding its functionality).\r\n\r\n```\r\n$ vips --version\r\nvips-8.4.1-Sat Oct  8 13:04:04 CEST 2016\r\n\r\n$ vips rank\r\nrank filter\r\nusage:\r\n   rank in out width height index\r\nwhere:\r\n   in           - Input image argument, input VipsImage\r\n   out          - Output image, output VipsImage\r\n   width        - Window width in pixels, input gint\r\n\t\t\tdefault: 11\r\n\t\t\tmin: 1, max: 100000\r\n   height       - Window height in pixels, input gint\r\n\t\t\tdefault: 11\r\n\t\t\tmin: 1, max: 100000\r\n   index        - Select pixel at index, input gint\r\n\t\t\tdefault: 50\r\n\t\t\tmin: 1, max: 100000000\r\n```\r\n\r\nConsider the cases of constructing moving minimum and moving maximum filters with the `rank` function.\r\nIf I understand correctly, the rank filter moves a window over the image, and at each (non-edge) position the window contains `width*height` pixels.  This collection is sorted and then a pixel is selected from the sorted list with the `index` argument.  The indexing scheme for `index` is presumably either 0-based or 1-based.  In those cases, I expect the following in the case of a 5x1 window:\r\n\r\nIn the 0-based indexing scheme:\r\n  5x1 moving min filter:  `vips rank in.v out.v 5 1 0`\r\n  5x1 moving max filter:  `vips rank in.v out.v 5 1 4`\r\n\r\nIn the 1-based indexing scheme:\r\n  5x1 moving min filter:  `vips rank in.v out.v 5 1 1`\r\n  5x1 moving max filter:  `vips rank in.v out.v 5 1 5`\r\n\r\nHowever, vips prevents both 0 and the number of window pixels in the `index` argument:\r\n```\r\n\r\n$ vips rank in.v out.v 5 1 0\r\n(vips:25492): GLib-GObject-WARNING **: value \"0\" of type 'gint' is invalid or out of range for property 'index' of type 'gint'\r\nrank: parameter index not set\r\n\r\n$ vips rank in.v out.v 5 1 5\r\nrank: index out of range\r\n\r\n```\r\n\r\nAm I misunderstanding the way the rank function works?  Additionally (and possibly related), how does rank work when it reaches the edge of an image?  If the window falls off the edge of the image, are there still considered to be `width*height` pixels in the window?  How does one specify `index` for \"the highest (lowest) pixel in the window, even if the window is truncated?\"  And finally, if it is indeed edges that are causing the problem, what is the recommended way to construct a moving min/max filter?\r\n\r\nMany thanks in advance."}}
{"actor":{"display_login":"erdmann"}}