{"action":"created","issue":{"url":"https://api.github.com/repos/peterbraden/node-opencv/issues/242","repository_url":"https://api.github.com/repos/peterbraden/node-opencv","labels_url":"https://api.github.com/repos/peterbraden/node-opencv/issues/242/labels{/name}","comments_url":"https://api.github.com/repos/peterbraden/node-opencv/issues/242/comments","events_url":"https://api.github.com/repos/peterbraden/node-opencv/issues/242/events","html_url":"https://github.com/peterbraden/node-opencv/issues/242","id":65175490,"number":242,"title":"Unexpected result from \"set\" function","user":{"login":"i-liszt","id":7455359,"avatar_url":"https://avatars.githubusercontent.com/u/7455359?v=3","gravatar_id":"","url":"https://api.github.com/users/i-liszt","html_url":"https://github.com/i-liszt","followers_url":"https://api.github.com/users/i-liszt/followers","following_url":"https://api.github.com/users/i-liszt/following{/other_user}","gists_url":"https://api.github.com/users/i-liszt/gists{/gist_id}","starred_url":"https://api.github.com/users/i-liszt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/i-liszt/subscriptions","organizations_url":"https://api.github.com/users/i-liszt/orgs","repos_url":"https://api.github.com/users/i-liszt/repos","events_url":"https://api.github.com/users/i-liszt/events{/privacy}","received_events_url":"https://api.github.com/users/i-liszt/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2015-03-30T09:49:44Z","updated_at":"2016-09-23T03:43:21Z","closed_at":"2016-09-23T03:43:21Z","body":"Hi, I try to use \"set\" function to modify pixels of an image; however, the result is so strange. The image becomes whole black. The following code is an example. The expected result should be a binary image. Do I misunderstand the set function? Thanks!\r\n\r\n```javascript\r\nvar cv = require('opencv');\r\n\r\ncv.readImage(\"./sample_1.jpg\", function(err, img) {\r\n\tif (err) {\r\n\t\tconsole.log(err);\r\n\t\treturn;\r\n\t} else {\r\n\t\tvar height = img.height(), \r\n\t\t\twidth = img.width(),\r\n\t\t\tmat = new cv.Matrix(height, width);\r\n\r\n\t\tmat = img.copy();\r\n\t\tmat.convertGrayscale();\r\n\t\t\r\n\t\tfor (var i = 0; i < height; i++) {\r\n\t\t\tfor (var j = 0; j < width; j++) {\r\n\t\t\t\tif (mat.pixel(i, j) < 150) {\r\n\t\t\t\t\tmat.set(i, j, 0);\r\n\t\t\t\t} else {\r\n\t\t\t\t\tmat.set(i, j, 255);\r\n\t\t\t\t}\r\n\t\t\t}\t\r\n\t\t}\r\n\t\tmat.save(\"./out.jpg\");\r\n\t}\r\n});\r\n```"},"comment":{"url":"https://api.github.com/repos/peterbraden/node-opencv/issues/comments/249095339","html_url":"https://github.com/peterbraden/node-opencv/issues/242#issuecomment-249095339","issue_url":"https://api.github.com/repos/peterbraden/node-opencv/issues/242","id":249095339,"user":{"login":"danschultzer","id":1254724,"avatar_url":"https://avatars.githubusercontent.com/u/1254724?v=3","gravatar_id":"","url":"https://api.github.com/users/danschultzer","html_url":"https://github.com/danschultzer","followers_url":"https://api.github.com/users/danschultzer/followers","following_url":"https://api.github.com/users/danschultzer/following{/other_user}","gists_url":"https://api.github.com/users/danschultzer/gists{/gist_id}","starred_url":"https://api.github.com/users/danschultzer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danschultzer/subscriptions","organizations_url":"https://api.github.com/users/danschultzer/orgs","repos_url":"https://api.github.com/users/danschultzer/repos","events_url":"https://api.github.com/users/danschultzer/events{/privacy}","received_events_url":"https://api.github.com/users/danschultzer/received_events","type":"User","site_admin":false},"created_at":"2016-09-23T03:43:21Z","updated_at":"2016-09-23T03:43:21Z","body":"I guess @paulovsm's comment is sufficient. I'll close this."}}
{"actor":{"display_login":"danschultzer"}}