{"action":"created","comment":{"url":"https://api.github.com/repos/image-js/core/pulls/comments/34976942","id":34976942,"diff_hunk":"@@ -0,0 +1,62 @@\n+'use strict'\n+\n+import edgeHandlingMethod from './edgeHandlingMethod'\n+\n+//convolution using a square kernel\n+export default function convolution(newImage, kernel, edgeHandling){\n+    let kernelWidth = Math.sqrt(kernel.length);\n+    let k = Math.floor(kernelWidth/2);\n+    let div = 0;\n+    edgeHandling = edgeHandling || 'copy';\n+\n+    for(let i = 0; i < kernel.length; i++){div += kernel[i];}\n+\n+    for(let x = 0; x < this.width ; x++){\n+        for(let y = 0; y < this.height ; y++){\n+            let sum = 0;\n+            for(let i = -k; i <= k; i++){\n+                for(let j = -k; j <= k; j++){\n+                    let val = edgeHandling.toLowerCase() == 'mirror'","path":"src/operator/convolution.js","position":19,"original_position":19,"commit_id":"b2916d949d77b5bd8871a842b6171f0468d554bd","original_commit_id":"b2916d949d77b5bd8871a842b6171f0468d554bd","user":{"login":"lpatiny","id":1484241,"avatar_url":"https://avatars.githubusercontent.com/u/1484241?v=3","gravatar_id":"","url":"https://api.github.com/users/lpatiny","html_url":"https://github.com/lpatiny","followers_url":"https://api.github.com/users/lpatiny/followers","following_url":"https://api.github.com/users/lpatiny/following{/other_user}","gists_url":"https://api.github.com/users/lpatiny/gists{/gist_id}","starred_url":"https://api.github.com/users/lpatiny/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lpatiny/subscriptions","organizations_url":"https://api.github.com/users/lpatiny/orgs","repos_url":"https://api.github.com/users/lpatiny/repos","events_url":"https://api.github.com/users/lpatiny/events{/privacy}","received_events_url":"https://api.github.com/users/lpatiny/received_events","type":"User","site_admin":false},"body":"this part is the limiting step in the code, you must avoid as much as possible to use conditions and especially functions like toLowerCase.\r\nThe edgeHandling option does not change during the algorithm so it can be checked before starting the loop.\r\nYou can do something like that before the first loop:\r\n```js\r\nlet edgeHandler;\r\nswitch(edgeHandling.toLowerCase()){\r\n  case 'mirror':\r\n    edgeHandler = myMirrorHandler;\r\n    break;\r\n  case 'copy':\r\n      edgeHandler = myCopyHandler;\r\n    break;\r\n   ...\r\n   default:\r\n     throw new Error('unknown edge handler: ' + edgeHandling);\r\n}\r\n```","created_at":"2015-07-20T08:53:35Z","updated_at":"2015-07-20T08:53:35Z","html_url":"https://github.com/image-js/core/pull/41#discussion_r34976942","pull_request_url":"https://api.github.com/repos/image-js/core/pulls/41","_links":{"self":{"href":"https://api.github.com/repos/image-js/core/pulls/comments/34976942"},"html":{"href":"https://github.com/image-js/core/pull/41#discussion_r34976942"},"pull_request":{"href":"https://api.github.com/repos/image-js/core/pulls/41"}}},"pull_request":{"url":"https://api.github.com/repos/image-js/core/pulls/41","id":40028229,"html_url":"https://github.com/image-js/core/pull/41","diff_url":"https://github.com/image-js/core/pull/41.diff","patch_url":"https://github.com/image-js/core/pull/41.patch","issue_url":"https://api.github.com/repos/image-js/core/issues/41","number":41,"state":"open","locked":false,"title":"This is a first approach to the Gaussian filter with a one-dimensiona…","user":{"login":"diegoamt","id":7453389,"avatar_url":"https://avatars.githubusercontent.com/u/7453389?v=3","gravatar_id":"","url":"https://api.github.com/users/diegoamt","html_url":"https://github.com/diegoamt","followers_url":"https://api.github.com/users/diegoamt/followers","following_url":"https://api.github.com/users/diegoamt/following{/other_user}","gists_url":"https://api.github.com/users/diegoamt/gists{/gist_id}","starred_url":"https://api.github.com/users/diegoamt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/diegoamt/subscriptions","organizations_url":"https://api.github.com/users/diegoamt/orgs","repos_url":"https://api.github.com/users/diegoamt/repos","events_url":"https://api.github.com/users/diegoamt/events{/privacy}","received_events_url":"https://api.github.com/users/diegoamt/received_events","type":"User","site_admin":false},"body":"…l vector.","created_at":"2015-07-15T14:26:10Z","updated_at":"2015-07-20T08:53:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"21d1af141b96d189e3acb80b0d5559b8b8322667","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/image-js/core/pulls/41/commits","review_comments_url":"https://api.github.com/repos/image-js/core/pulls/41/comments","review_comment_url":"https://api.github.com/repos/image-js/core/pulls/comments{/number}","comments_url":"https://api.github.com/repos/image-js/core/issues/41/comments","statuses_url":"https://api.github.com/repos/image-js/core/statuses/b2916d949d77b5bd8871a842b6171f0468d554bd","head":{"label":"image-js:gaussian_filter","ref":"gaussian_filter","sha":"b2916d949d77b5bd8871a842b6171f0468d554bd","user":{"login":"image-js","id":12996949,"avatar_url":"https://avatars.githubusercontent.com/u/12996949?v=3","gravatar_id":"","url":"https://api.github.com/users/image-js","html_url":"https://github.com/image-js","followers_url":"https://api.github.com/users/image-js/followers","following_url":"https://api.github.com/users/image-js/following{/other_user}","gists_url":"https://api.github.com/users/image-js/gists{/gist_id}","starred_url":"https://api.github.com/users/image-js/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/image-js/subscriptions","organizations_url":"https://api.github.com/users/image-js/orgs","repos_url":"https://api.github.com/users/image-js/repos","events_url":"https://api.github.com/users/image-js/events{/privacy}","received_events_url":"https://api.github.com/users/image-js/received_events","type":"Organization","site_admin":false},"repo":{"id":37226136,"name":"core","full_name":"image-js/core","owner":{"login":"image-js","id":12996949,"avatar_url":"https://avatars.githubusercontent.com/u/12996949?v=3","gravatar_id":"","url":"https://api.github.com/users/image-js","html_url":"https://github.com/image-js","followers_url":"https://api.github.com/users/image-js/followers","following_url":"https://api.github.com/users/image-js/following{/other_user}","gists_url":"https://api.github.com/users/image-js/gists{/gist_id}","starred_url":"https://api.github.com/users/image-js/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/image-js/subscriptions","organizations_url":"https://api.github.com/users/image-js/orgs","repos_url":"https://api.github.com/users/image-js/repos","events_url":"https://api.github.com/users/image-js/events{/privacy}","received_events_url":"https://api.github.com/users/image-js/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/image-js/core","description":"Image processing and manipulation in JavaScript","fork":false,"url":"https://api.github.com/repos/image-js/core","forks_url":"https://api.github.com/repos/image-js/core/forks","keys_url":"https://api.github.com/repos/image-js/core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/image-js/core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/image-js/core/teams","hooks_url":"https://api.github.com/repos/image-js/core/hooks","issue_events_url":"https://api.github.com/repos/image-js/core/issues/events{/number}","events_url":"https://api.github.com/repos/image-js/core/events","assignees_url":"https://api.github.com/repos/image-js/core/assignees{/user}","branches_url":"https://api.github.com/repos/image-js/core/branches{/branch}","tags_url":"https://api.github.com/repos/image-js/core/tags","blobs_url":"https://api.github.com/repos/image-js/core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/image-js/core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/image-js/core/git/refs{/sha}","trees_url":"https://api.github.com/repos/image-js/core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/image-js/core/statuses/{sha}","languages_url":"https://api.github.com/repos/image-js/core/languages","stargazers_url":"https://api.github.com/repos/image-js/core/stargazers","contributors_url":"https://api.github.com/repos/image-js/core/contributors","subscribers_url":"https://api.github.com/repos/image-js/core/subscribers","subscription_url":"https://api.github.com/repos/image-js/core/subscription","commits_url":"https://api.github.com/repos/image-js/core/commits{/sha}","git_commits_url":"https://api.github.com/repos/image-js/core/git/commits{/sha}","comments_url":"https://api.github.com/repos/image-js/core/comments{/number}","issue_comment_url":"https://api.github.com/repos/image-js/core/issues/comments{/number}","contents_url":"https://api.github.com/repos/image-js/core/contents/{+path}","compare_url":"https://api.github.com/repos/image-js/core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/image-js/core/merges","archive_url":"https://api.github.com/repos/image-js/core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/image-js/core/downloads","issues_url":"https://api.github.com/repos/image-js/core/issues{/number}","pulls_url":"https://api.github.com/repos/image-js/core/pulls{/number}","milestones_url":"https://api.github.com/repos/image-js/core/milestones{/number}","notifications_url":"https://api.github.com/repos/image-js/core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/image-js/core/labels{/name}","releases_url":"https://api.github.com/repos/image-js/core/releases{/id}","created_at":"2015-06-10T22:32:45Z","updated_at":"2015-07-15T13:08:08Z","pushed_at":"2015-07-19T23:09:45Z","git_url":"git://github.com/image-js/core.git","ssh_url":"git@github.com:image-js/core.git","clone_url":"https://github.com/image-js/core.git","svn_url":"https://github.com/image-js/core","homepage":"https://image-js.org","size":6304,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":32,"forks":0,"open_issues":32,"watchers":1,"default_branch":"master"}},"base":{"label":"image-js:master","ref":"master","sha":"1013e11bc54c0783977f2d9a40925a3a3bbd44f8","user":{"login":"image-js","id":12996949,"avatar_url":"https://avatars.githubusercontent.com/u/12996949?v=3","gravatar_id":"","url":"https://api.github.com/users/image-js","html_url":"https://github.com/image-js","followers_url":"https://api.github.com/users/image-js/followers","following_url":"https://api.github.com/users/image-js/following{/other_user}","gists_url":"https://api.github.com/users/image-js/gists{/gist_id}","starred_url":"https://api.github.com/users/image-js/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/image-js/subscriptions","organizations_url":"https://api.github.com/users/image-js/orgs","repos_url":"https://api.github.com/users/image-js/repos","events_url":"https://api.github.com/users/image-js/events{/privacy}","received_events_url":"https://api.github.com/users/image-js/received_events","type":"Organization","site_admin":false},"repo":{"id":37226136,"name":"core","full_name":"image-js/core","owner":{"login":"image-js","id":12996949,"avatar_url":"https://avatars.githubusercontent.com/u/12996949?v=3","gravatar_id":"","url":"https://api.github.com/users/image-js","html_url":"https://github.com/image-js","followers_url":"https://api.github.com/users/image-js/followers","following_url":"https://api.github.com/users/image-js/following{/other_user}","gists_url":"https://api.github.com/users/image-js/gists{/gist_id}","starred_url":"https://api.github.com/users/image-js/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/image-js/subscriptions","organizations_url":"https://api.github.com/users/image-js/orgs","repos_url":"https://api.github.com/users/image-js/repos","events_url":"https://api.github.com/users/image-js/events{/privacy}","received_events_url":"https://api.github.com/users/image-js/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/image-js/core","description":"Image processing and manipulation in JavaScript","fork":false,"url":"https://api.github.com/repos/image-js/core","forks_url":"https://api.github.com/repos/image-js/core/forks","keys_url":"https://api.github.com/repos/image-js/core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/image-js/core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/image-js/core/teams","hooks_url":"https://api.github.com/repos/image-js/core/hooks","issue_events_url":"https://api.github.com/repos/image-js/core/issues/events{/number}","events_url":"https://api.github.com/repos/image-js/core/events","assignees_url":"https://api.github.com/repos/image-js/core/assignees{/user}","branches_url":"https://api.github.com/repos/image-js/core/branches{/branch}","tags_url":"https://api.github.com/repos/image-js/core/tags","blobs_url":"https://api.github.com/repos/image-js/core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/image-js/core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/image-js/core/git/refs{/sha}","trees_url":"https://api.github.com/repos/image-js/core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/image-js/core/statuses/{sha}","languages_url":"https://api.github.com/repos/image-js/core/languages","stargazers_url":"https://api.github.com/repos/image-js/core/stargazers","contributors_url":"https://api.github.com/repos/image-js/core/contributors","subscribers_url":"https://api.github.com/repos/image-js/core/subscribers","subscription_url":"https://api.github.com/repos/image-js/core/subscription","commits_url":"https://api.github.com/repos/image-js/core/commits{/sha}","git_commits_url":"https://api.github.com/repos/image-js/core/git/commits{/sha}","comments_url":"https://api.github.com/repos/image-js/core/comments{/number}","issue_comment_url":"https://api.github.com/repos/image-js/core/issues/comments{/number}","contents_url":"https://api.github.com/repos/image-js/core/contents/{+path}","compare_url":"https://api.github.com/repos/image-js/core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/image-js/core/merges","archive_url":"https://api.github.com/repos/image-js/core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/image-js/core/downloads","issues_url":"https://api.github.com/repos/image-js/core/issues{/number}","pulls_url":"https://api.github.com/repos/image-js/core/pulls{/number}","milestones_url":"https://api.github.com/repos/image-js/core/milestones{/number}","notifications_url":"https://api.github.com/repos/image-js/core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/image-js/core/labels{/name}","releases_url":"https://api.github.com/repos/image-js/core/releases{/id}","created_at":"2015-06-10T22:32:45Z","updated_at":"2015-07-15T13:08:08Z","pushed_at":"2015-07-19T23:09:45Z","git_url":"git://github.com/image-js/core.git","ssh_url":"git@github.com:image-js/core.git","clone_url":"https://github.com/image-js/core.git","svn_url":"https://github.com/image-js/core","homepage":"https://image-js.org","size":6304,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":32,"forks":0,"open_issues":32,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/image-js/core/pulls/41"},"html":{"href":"https://github.com/image-js/core/pull/41"},"issue":{"href":"https://api.github.com/repos/image-js/core/issues/41"},"comments":{"href":"https://api.github.com/repos/image-js/core/issues/41/comments"},"review_comments":{"href":"https://api.github.com/repos/image-js/core/pulls/41/comments"},"review_comment":{"href":"https://api.github.com/repos/image-js/core/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/image-js/core/pulls/41/commits"},"statuses":{"href":"https://api.github.com/repos/image-js/core/statuses/b2916d949d77b5bd8871a842b6171f0468d554bd"}}}}