{"action":"created","comment":{"url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/pulls/comments/150007978","pull_request_review_id":75493332,"id":150007978,"diff_hunk":"@@ -264,4 +269,133 @@ object SphericalHarmonicsLightProposals {\n \n     override def toString = s\"SHLightSolverProposal($sphericalHarmonicsOptimizer)\"\n   }\n+\n+  /** This proposal performs RANSAC to try to estimate illumination excluding outliers/occlusions\n+    * The face model is used as appearance prior\n+    *\n+    * The procedure is explained in:\n+    * Occlusion-aware 3D Morphable Face Models,\n+    * Bernhard Egger, Andreas Schneider, Clemens Blumer, Andreas Morel-Forster, Sandro Schönborn, Thomas Vetter\n+    * IN: British Machine Vision Conference (BMVC), September 2016\n+    * https://dx.doi.org/10.5244/C.30.64\n+    * */\n+  case class  RobustSHLightSolverProposal(modelRenderer: ParametricImageRenderer[RGBA] with ParametricModel,\n+                                          shOpt: SphericalHarmonicsOptimizer,\n+                                          pixelEvaluator: PairEvaluator[RGB],\n+                                          target: PixelImage[RGBA],\n+                                          nSamples: Int = 30,\n+                                          sigmaThreshold: Double = 2,\n+                                          percentage: Double = 0.4,\n+                                          iterations: Int = 500,\n+                                          updateLight: Boolean = true,\n+                                          maxVarianceForMask: Double = 0.5,\n+                                          nSamplesIllumination: Int = 1000)(implicit rnd: Random)\n+    extends ProposalGenerator[(RenderParameter, PixelImage[Int])] with TransitionProbability[(RenderParameter, PixelImage[Int])] {\n+\n+\n+\n+    // the normalizer for the given pixel evaluator\n+    val normalizer = pixelEvaluator.logValue(RGB.White, RGB.White)\n+    // the corresponding threshold depending on sigmaThreshold\n+    val threshold: Double = Math.exp(-0.5 * Math.pow(sigmaThreshold, 2) - normalizer)\n+\n+    /** this function measures the quality of a given set of renderParameters.\n+      * it returns a double which is the quality of the current parameters,\n+      * as well as an image indicating which pixels are good under this threshold\n+      * */\n+    private def measureModelQuality(rps: RenderParameter): (Double, PixelImage[Int]) = {\n+      val curSample: PixelImage[RGBA] = modelRenderer.renderImage(rps).withAccessMode(AccessMode.Strict[RGBA])\n+      var counter = 0\n+\n+      val differenceImage = PixelImage(curSample.width,curSample.height,(x,y) => {\n+        val c = curSample(x,y)\n+        if (c.a > 0  ) {\n+          counter = counter + 1\n+          val eval = pixelEvaluator.logValue(c.toRGB, target(x, y).toRGB)\n+          eval\n+        }\n+        else\n+          Math.log(threshold) - normalizer + 1 // just to be above threshold\n+      }, AccessMode.Strict[Double])\n+      val thresholded = differenceImage.map(d => if (Math.exp(d - normalizer) > threshold) 1 else 0)\n+      val count: Double = thresholded.foldLeft(0.0)((a, b) => a + b) / counter","path":"src/main/scala/scalismo/faces/sampling/face/proposals/SphericalHarmonicsLightProposals.scala","position":73,"original_position":73,"commit_id":"5301005f73fc362c95f088e5689db474eee05198","original_commit_id":"5301005f73fc362c95f088e5689db474eee05198","user":{"login":"BernhardEgger","id":24292834,"avatar_url":"https://avatars3.githubusercontent.com/u/24292834?v=4","gravatar_id":"","url":"https://api.github.com/users/BernhardEgger","html_url":"https://github.com/BernhardEgger","followers_url":"https://api.github.com/users/BernhardEgger/followers","following_url":"https://api.github.com/users/BernhardEgger/following{/other_user}","gists_url":"https://api.github.com/users/BernhardEgger/gists{/gist_id}","starred_url":"https://api.github.com/users/BernhardEgger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BernhardEgger/subscriptions","organizations_url":"https://api.github.com/users/BernhardEgger/orgs","repos_url":"https://api.github.com/users/BernhardEgger/repos","events_url":"https://api.github.com/users/BernhardEgger/events{/privacy}","received_events_url":"https://api.github.com/users/BernhardEgger/received_events","type":"User","site_admin":false},"body":"there is no such thing as a sum for a PixelImage ","created_at":"2017-11-09T16:12:45Z","updated_at":"2017-11-09T16:12:45Z","html_url":"https://github.com/unibas-gravis/scalismo-faces/pull/75#discussion_r150007978","pull_request_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/pulls/75","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/unibas-gravis/scalismo-faces/pulls/comments/150007978"},"html":{"href":"https://github.com/unibas-gravis/scalismo-faces/pull/75#discussion_r150007978"},"pull_request":{"href":"https://api.github.com/repos/unibas-gravis/scalismo-faces/pulls/75"}},"in_reply_to_id":149895073},"pull_request":{"url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/pulls/75","id":151497840,"html_url":"https://github.com/unibas-gravis/scalismo-faces/pull/75","diff_url":"https://github.com/unibas-gravis/scalismo-faces/pull/75.diff","patch_url":"https://github.com/unibas-gravis/scalismo-faces/pull/75.patch","issue_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/issues/75","number":75,"state":"open","locked":false,"title":"Robust illumination estimation","user":{"login":"BernhardEgger","id":24292834,"avatar_url":"https://avatars3.githubusercontent.com/u/24292834?v=4","gravatar_id":"","url":"https://api.github.com/users/BernhardEgger","html_url":"https://github.com/BernhardEgger","followers_url":"https://api.github.com/users/BernhardEgger/followers","following_url":"https://api.github.com/users/BernhardEgger/following{/other_user}","gists_url":"https://api.github.com/users/BernhardEgger/gists{/gist_id}","starred_url":"https://api.github.com/users/BernhardEgger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BernhardEgger/subscriptions","organizations_url":"https://api.github.com/users/BernhardEgger/orgs","repos_url":"https://api.github.com/users/BernhardEgger/repos","events_url":"https://api.github.com/users/BernhardEgger/events{/privacy}","received_events_url":"https://api.github.com/users/BernhardEgger/received_events","type":"User","site_admin":false},"body":"Adds the RANSAC based robust illumination estimation method as described in:\r\n_Occlusion-aware 3D Morphable Face Models \r\nBernhard Egger, Andreas Schneider, Clemens Blumer, Andreas Morel-Forster, Sandro Schönborn, Thomas Vetter\r\nBritish Machine Vision Conference (BMVC), September 2016\r\nDOI: https://dx.doi.org/10.5244/C.30.64_","created_at":"2017-11-08T21:17:53Z","updated_at":"2017-11-09T16:12:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a2748e3ef96f8c6f02fc1d7b55a166b5bc1436af","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/pulls/75/commits","review_comments_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/pulls/75/comments","review_comment_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/pulls/comments{/number}","comments_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/issues/75/comments","statuses_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/statuses/5301005f73fc362c95f088e5689db474eee05198","head":{"label":"unibas-gravis:RobustIlluminationEstimation","ref":"RobustIlluminationEstimation","sha":"5301005f73fc362c95f088e5689db474eee05198","user":{"login":"unibas-gravis","id":2787582,"avatar_url":"https://avatars0.githubusercontent.com/u/2787582?v=4","gravatar_id":"","url":"https://api.github.com/users/unibas-gravis","html_url":"https://github.com/unibas-gravis","followers_url":"https://api.github.com/users/unibas-gravis/followers","following_url":"https://api.github.com/users/unibas-gravis/following{/other_user}","gists_url":"https://api.github.com/users/unibas-gravis/gists{/gist_id}","starred_url":"https://api.github.com/users/unibas-gravis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/unibas-gravis/subscriptions","organizations_url":"https://api.github.com/users/unibas-gravis/orgs","repos_url":"https://api.github.com/users/unibas-gravis/repos","events_url":"https://api.github.com/users/unibas-gravis/events{/privacy}","received_events_url":"https://api.github.com/users/unibas-gravis/received_events","type":"Organization","site_admin":false},"repo":{"id":74349014,"name":"scalismo-faces","full_name":"unibas-gravis/scalismo-faces","owner":{"login":"unibas-gravis","id":2787582,"avatar_url":"https://avatars0.githubusercontent.com/u/2787582?v=4","gravatar_id":"","url":"https://api.github.com/users/unibas-gravis","html_url":"https://github.com/unibas-gravis","followers_url":"https://api.github.com/users/unibas-gravis/followers","following_url":"https://api.github.com/users/unibas-gravis/following{/other_user}","gists_url":"https://api.github.com/users/unibas-gravis/gists{/gist_id}","starred_url":"https://api.github.com/users/unibas-gravis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/unibas-gravis/subscriptions","organizations_url":"https://api.github.com/users/unibas-gravis/orgs","repos_url":"https://api.github.com/users/unibas-gravis/repos","events_url":"https://api.github.com/users/unibas-gravis/events{/privacy}","received_events_url":"https://api.github.com/users/unibas-gravis/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/unibas-gravis/scalismo-faces","description":"Scalable Image Analysis and Shape Modelling: Module to work with 2d images, with a focus on face images","fork":false,"url":"https://api.github.com/repos/unibas-gravis/scalismo-faces","forks_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/forks","keys_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/keys{/key_id}","collaborators_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/teams","hooks_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/hooks","issue_events_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/issues/events{/number}","events_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/events","assignees_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/assignees{/user}","branches_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/branches{/branch}","tags_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/tags","blobs_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/git/refs{/sha}","trees_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/git/trees{/sha}","statuses_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/statuses/{sha}","languages_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/languages","stargazers_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/stargazers","contributors_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/contributors","subscribers_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/subscribers","subscription_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/subscription","commits_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/commits{/sha}","git_commits_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/git/commits{/sha}","comments_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/comments{/number}","issue_comment_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/issues/comments{/number}","contents_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/contents/{+path}","compare_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/compare/{base}...{head}","merges_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/merges","archive_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/downloads","issues_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/issues{/number}","pulls_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/pulls{/number}","milestones_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/milestones{/number}","notifications_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/labels{/name}","releases_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/releases{/id}","deployments_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/deployments","created_at":"2016-11-21T09:44:55Z","updated_at":"2017-11-02T14:14:54Z","pushed_at":"2017-11-08T21:17:53Z","git_url":"git://github.com/unibas-gravis/scalismo-faces.git","ssh_url":"git@github.com:unibas-gravis/scalismo-faces.git","clone_url":"https://github.com/unibas-gravis/scalismo-faces.git","svn_url":"https://github.com/unibas-gravis/scalismo-faces","homepage":"","size":1182,"stargazers_count":15,"watchers_count":15,"language":"Scala","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"archived":false,"open_issues_count":12,"forks":5,"open_issues":12,"watchers":15,"default_branch":"master"}},"base":{"label":"unibas-gravis:master","ref":"master","sha":"473aa31036e4bc67966f001116bc15ec58a8f9f0","user":{"login":"unibas-gravis","id":2787582,"avatar_url":"https://avatars0.githubusercontent.com/u/2787582?v=4","gravatar_id":"","url":"https://api.github.com/users/unibas-gravis","html_url":"https://github.com/unibas-gravis","followers_url":"https://api.github.com/users/unibas-gravis/followers","following_url":"https://api.github.com/users/unibas-gravis/following{/other_user}","gists_url":"https://api.github.com/users/unibas-gravis/gists{/gist_id}","starred_url":"https://api.github.com/users/unibas-gravis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/unibas-gravis/subscriptions","organizations_url":"https://api.github.com/users/unibas-gravis/orgs","repos_url":"https://api.github.com/users/unibas-gravis/repos","events_url":"https://api.github.com/users/unibas-gravis/events{/privacy}","received_events_url":"https://api.github.com/users/unibas-gravis/received_events","type":"Organization","site_admin":false},"repo":{"id":74349014,"name":"scalismo-faces","full_name":"unibas-gravis/scalismo-faces","owner":{"login":"unibas-gravis","id":2787582,"avatar_url":"https://avatars0.githubusercontent.com/u/2787582?v=4","gravatar_id":"","url":"https://api.github.com/users/unibas-gravis","html_url":"https://github.com/unibas-gravis","followers_url":"https://api.github.com/users/unibas-gravis/followers","following_url":"https://api.github.com/users/unibas-gravis/following{/other_user}","gists_url":"https://api.github.com/users/unibas-gravis/gists{/gist_id}","starred_url":"https://api.github.com/users/unibas-gravis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/unibas-gravis/subscriptions","organizations_url":"https://api.github.com/users/unibas-gravis/orgs","repos_url":"https://api.github.com/users/unibas-gravis/repos","events_url":"https://api.github.com/users/unibas-gravis/events{/privacy}","received_events_url":"https://api.github.com/users/unibas-gravis/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/unibas-gravis/scalismo-faces","description":"Scalable Image Analysis and Shape Modelling: Module to work with 2d images, with a focus on face images","fork":false,"url":"https://api.github.com/repos/unibas-gravis/scalismo-faces","forks_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/forks","keys_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/keys{/key_id}","collaborators_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/teams","hooks_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/hooks","issue_events_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/issues/events{/number}","events_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/events","assignees_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/assignees{/user}","branches_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/branches{/branch}","tags_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/tags","blobs_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/git/refs{/sha}","trees_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/git/trees{/sha}","statuses_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/statuses/{sha}","languages_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/languages","stargazers_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/stargazers","contributors_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/contributors","subscribers_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/subscribers","subscription_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/subscription","commits_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/commits{/sha}","git_commits_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/git/commits{/sha}","comments_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/comments{/number}","issue_comment_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/issues/comments{/number}","contents_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/contents/{+path}","compare_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/compare/{base}...{head}","merges_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/merges","archive_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/downloads","issues_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/issues{/number}","pulls_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/pulls{/number}","milestones_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/milestones{/number}","notifications_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/labels{/name}","releases_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/releases{/id}","deployments_url":"https://api.github.com/repos/unibas-gravis/scalismo-faces/deployments","created_at":"2016-11-21T09:44:55Z","updated_at":"2017-11-02T14:14:54Z","pushed_at":"2017-11-08T21:17:53Z","git_url":"git://github.com/unibas-gravis/scalismo-faces.git","ssh_url":"git@github.com:unibas-gravis/scalismo-faces.git","clone_url":"https://github.com/unibas-gravis/scalismo-faces.git","svn_url":"https://github.com/unibas-gravis/scalismo-faces","homepage":"","size":1182,"stargazers_count":15,"watchers_count":15,"language":"Scala","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"archived":false,"open_issues_count":12,"forks":5,"open_issues":12,"watchers":15,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/unibas-gravis/scalismo-faces/pulls/75"},"html":{"href":"https://github.com/unibas-gravis/scalismo-faces/pull/75"},"issue":{"href":"https://api.github.com/repos/unibas-gravis/scalismo-faces/issues/75"},"comments":{"href":"https://api.github.com/repos/unibas-gravis/scalismo-faces/issues/75/comments"},"review_comments":{"href":"https://api.github.com/repos/unibas-gravis/scalismo-faces/pulls/75/comments"},"review_comment":{"href":"https://api.github.com/repos/unibas-gravis/scalismo-faces/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/unibas-gravis/scalismo-faces/pulls/75/commits"},"statuses":{"href":"https://api.github.com/repos/unibas-gravis/scalismo-faces/statuses/5301005f73fc362c95f088e5689db474eee05198"}},"author_association":"OWNER"}}
{"actor":{"display_login":"BernhardEgger"}}