{"action":"created","issue":{"url":"https://api.github.com/repos/akvo/caddisfly-app/issues/5","labels_url":"https://api.github.com/repos/akvo/caddisfly-app/issues/5/labels{/name}","comments_url":"https://api.github.com/repos/akvo/caddisfly-app/issues/5/comments","events_url":"https://api.github.com/repos/akvo/caddisfly-app/issues/5/events","html_url":"https://github.com/akvo/caddisfly-app/issues/5","id":92834351,"number":5,"title":"2.2 Capture sharp image when calibration code is found","user":{"login":"mtwestra","id":478954,"avatar_url":"https://avatars.githubusercontent.com/u/478954?v=3","gravatar_id":"","url":"https://api.github.com/users/mtwestra","html_url":"https://github.com/mtwestra","followers_url":"https://api.github.com/users/mtwestra/followers","following_url":"https://api.github.com/users/mtwestra/following{/other_user}","gists_url":"https://api.github.com/users/mtwestra/gists{/gist_id}","starred_url":"https://api.github.com/users/mtwestra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mtwestra/subscriptions","organizations_url":"https://api.github.com/users/mtwestra/orgs","repos_url":"https://api.github.com/users/mtwestra/repos","events_url":"https://api.github.com/users/mtwestra/events{/privacy}","received_events_url":"https://api.github.com/users/mtwestra/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/akvo/caddisfly-app/labels/Strip%20test","name":"Strip test","color":"fbca04"}],"state":"open","locked":false,"assignee":{"login":"ldporsius","id":9623423,"avatar_url":"https://avatars.githubusercontent.com/u/9623423?v=3","gravatar_id":"","url":"https://api.github.com/users/ldporsius","html_url":"https://github.com/ldporsius","followers_url":"https://api.github.com/users/ldporsius/followers","following_url":"https://api.github.com/users/ldporsius/following{/other_user}","gists_url":"https://api.github.com/users/ldporsius/gists{/gist_id}","starred_url":"https://api.github.com/users/ldporsius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ldporsius/subscriptions","organizations_url":"https://api.github.com/users/ldporsius/orgs","repos_url":"https://api.github.com/users/ldporsius/repos","events_url":"https://api.github.com/users/ldporsius/events{/privacy}","received_events_url":"https://api.github.com/users/ldporsius/received_events","type":"User","site_admin":false},"milestone":null,"comments":8,"created_at":"2015-07-03T09:30:57Z","updated_at":"2015-07-09T14:19:04Z","closed_at":null,"body":"We need to check ourselves if the preview image the camera has captured is sharp. For this, we need to create a focus measure, based on the captured images.\r\n\r\nIt is likely that before we use these methods, we need to correct the overall illumination of the image by normalising the grayscale image to the (0,255) value range. We might also need to use a gaussian filter first, to reduce noise.\r\n\r\nThere are diffent ways to handle this:\r\n1) using the normalised variance\r\nThis method computes the normalised variance of (part of) a grayscale image. For example, we could use the finder pattern part of the image, for which we know the location.\r\n\r\nThe variance is defined as:\r\n(1/N mu) * SUM (p(i,j) - mu)^2\r\n\r\nwhere mu is the mean of the grayscale image, and p(i,j) is the grayscale value of a pixel.\r\nIf there is more contrast in the image, this value will be larger.\r\n\r\n2) using the laplace filter \r\nIn this case, we apply a laplace filter over the image. A laplace filter compares nearby pixels and computes the rate of change: the larger the contrast between two nearby pixels, the larger this value.\r\n\r\nAfter the laplace operation, there are two possibilities:\r\na) find the maximum value. This is the easiest, but might be susceptible to noise, because a single noise pixel with a high contrast value will dominate the results. We should probably try this first.\r\nb) compute the value where 90% of the values falls in. For a low-focus image, most differences between the pixels are small, so 90% of the values will lower than some value. For a high-focus image, there will be more differences that are large, so the 90% border will be at a higher value. This is shown in this image: http://stackoverflow.com/questions/15839928/how-to-detect-when-an-image-is-out-of-focus \r\n\r\nWe will try both and compare the results.\r\n\r\nThe code will need to:\r\n1) as fast as possible, determine if an image is in focus or not. For this, we might want to cut out the 3 finder patterns, and determine the focus only on those parts. As these have the highest contrast (black/white).\r\n2) be insensitive to the global illumination level, so determine focus in both light and dark images\r\n\r\nTo test this, we need to create some test patters and determine the efficiency of the method. This can be done in photoshop.\r\n\r\nIn addition, we should capture and store some 100 images, and determine the focus visually.\r\n"},"comment":{"url":"https://api.github.com/repos/akvo/caddisfly-app/issues/comments/119998222","html_url":"https://github.com/akvo/caddisfly-app/issues/5#issuecomment-119998222","issue_url":"https://api.github.com/repos/akvo/caddisfly-app/issues/5","id":119998222,"user":{"login":"ldporsius","id":9623423,"avatar_url":"https://avatars.githubusercontent.com/u/9623423?v=3","gravatar_id":"","url":"https://api.github.com/users/ldporsius","html_url":"https://github.com/ldporsius","followers_url":"https://api.github.com/users/ldporsius/followers","following_url":"https://api.github.com/users/ldporsius/following{/other_user}","gists_url":"https://api.github.com/users/ldporsius/gists{/gist_id}","starred_url":"https://api.github.com/users/ldporsius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ldporsius/subscriptions","organizations_url":"https://api.github.com/users/ldporsius/orgs","repos_url":"https://api.github.com/users/ldporsius/repos","events_url":"https://api.github.com/users/ldporsius/events{/privacy}","received_events_url":"https://api.github.com/users/ldporsius/received_events","type":"User","site_admin":false},"created_at":"2015-07-09T14:19:03Z","updated_at":"2015-07-09T14:19:03Z","body":"*http://docs.opencv.org/modules/imgproc/doc/filtering.html*\n\nOn 07/09/2015 02:59 PM, Mark Westra wrote:\n> What is a bilateral filter?\n>\n> I think the first thing to do now is improve the focus.\n> m\n>\n> On 9 Jul 2015, at 14:11, Linda Porsius <notifications@github.com> wrote:\n>\n> > By applying a bilateral filter I get the above result. It is a bit \n> improved don't you think? But the colors are still much bleaker than \n> the original.\n> >\n> > —\n> > Reply to this email directly or view it on GitHub.\n> >\n>\n> —\n> Reply to this email directly or view it on GitHub \n> <https://github.com/akvo/caddisfly-app/issues/5#issuecomment-119953811>.\n>\n\n"}}