{"action":"created","issue":{"url":"https://api.github.com/repos/anthonynsimon/bild/issues/31","repository_url":"https://api.github.com/repos/anthonynsimon/bild","labels_url":"https://api.github.com/repos/anthonynsimon/bild/issues/31/labels{/name}","comments_url":"https://api.github.com/repos/anthonynsimon/bild/issues/31/comments","events_url":"https://api.github.com/repos/anthonynsimon/bild/issues/31/events","html_url":"https://github.com/anthonynsimon/bild/issues/31","id":177674724,"number":31,"title":"Switch fuzz to diff tolerance between colours","user":{"login":"anthonynsimon","id":13251079,"avatar_url":"https://avatars.githubusercontent.com/u/13251079?v=3","gravatar_id":"","url":"https://api.github.com/users/anthonynsimon","html_url":"https://github.com/anthonynsimon","followers_url":"https://api.github.com/users/anthonynsimon/followers","following_url":"https://api.github.com/users/anthonynsimon/following{/other_user}","gists_url":"https://api.github.com/users/anthonynsimon/gists{/gist_id}","starred_url":"https://api.github.com/users/anthonynsimon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anthonynsimon/subscriptions","organizations_url":"https://api.github.com/users/anthonynsimon/orgs","repos_url":"https://api.github.com/users/anthonynsimon/repos","events_url":"https://api.github.com/users/anthonynsimon/events{/privacy}","received_events_url":"https://api.github.com/users/anthonynsimon/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-09-18T20:27:13Z","updated_at":"2016-09-19T06:19:20Z","closed_at":null,"body":"@defart would it make sense to switch from fuzz (distance based) to color difference tolerance?\r\n\r\nThis way setting the tolerance would allow the algorithm to fill pixels by similarity instead of by distance from point. So for example if tolerance is set to 12 (uint8 range 0...255), then all colours that are within a diff of +-12 will be matched.\r\n\r\nAfter some quick research it seems like most photo editing software, including Photoshop, use a version of this setting.\r\n\r\nI created a branch with the proposal, check it out [here](https://github.com/anthonynsimon/bild/blob/floodfill-tolerance/paint/fill.go#L137)\r\n\r\nPhotoshop result:\r\n![ps](https://cloud.githubusercontent.com/assets/13251079/18618807/5ec47216-7dee-11e6-9b89-09cd224bfb26.jpg)\r\n\r\nbild paint.FloodFill result (after switching to proposed method):\r\n![bild](https://cloud.githubusercontent.com/assets/13251079/18618808/6342356c-7dee-11e6-86bc-bdb28b9bf5a9.jpg)"},"comment":{"url":"https://api.github.com/repos/anthonynsimon/bild/issues/comments/247917841","html_url":"https://github.com/anthonynsimon/bild/issues/31#issuecomment-247917841","issue_url":"https://api.github.com/repos/anthonynsimon/bild/issues/31","id":247917841,"user":{"login":"anthonynsimon","id":13251079,"avatar_url":"https://avatars.githubusercontent.com/u/13251079?v=3","gravatar_id":"","url":"https://api.github.com/users/anthonynsimon","html_url":"https://github.com/anthonynsimon","followers_url":"https://api.github.com/users/anthonynsimon/followers","following_url":"https://api.github.com/users/anthonynsimon/following{/other_user}","gists_url":"https://api.github.com/users/anthonynsimon/gists{/gist_id}","starred_url":"https://api.github.com/users/anthonynsimon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anthonynsimon/subscriptions","organizations_url":"https://api.github.com/users/anthonynsimon/orgs","repos_url":"https://api.github.com/users/anthonynsimon/repos","events_url":"https://api.github.com/users/anthonynsimon/events{/privacy}","received_events_url":"https://api.github.com/users/anthonynsimon/received_events","type":"User","site_admin":false},"created_at":"2016-09-19T06:19:20Z","updated_at":"2016-09-19T06:19:20Z","body":"Oh, totally my bad haha. Sorry about that, I clearly messed up. \r\n\r\nBefore calling it off, I decided to run some benchmarks to check if the reduced casting has some effect on performance and surprisingly we got a 30% reduction in compute time on the proposal version.\r\n\r\nHere's a before and after:\r\n```\r\n$ go test -run=NONE -bench=. -benchtime=25s -benchmem > after.txt\r\n$ benchcmp before.txt after.txt\r\n\r\nbenchmark                old ns/op     new ns/op     delta\r\nBenchmarkFloodFill-8     121853788     84696242      -30.49%\r\n\r\nbenchmark                old allocs     new allocs     delta\r\nBenchmarkFloodFill-8     264409         264419         +0.00%\r\n\r\nbenchmark                old bytes     new bytes     delta\r\nBenchmarkFloodFill-8     24397236      24393712      -0.01%\r\n```\r\n\r\nThere's no considerable change in allocs or bytes, only on time per operation which is beneficial.\r\n\r\nOther than that, the change would also be using a 0 to 255 tolerance value in the function signature instead of a percent based one. I would lean towards the former as it's what I've been using for years in Photoshop, but I guess that's subjective :)"}}
{"actor":{"display_login":"anthonynsimon"}}