{"id":40,"date":"2011-09-27T20:34:21","date_gmt":"2011-09-27T20:34:21","guid":{"rendered":"http:\/\/teaching.thesystemis.com\/setpixel11\/blog\/?p=40"},"modified":"2011-09-27T20:34:21","modified_gmt":"2011-09-27T20:34:21","slug":"homework-5","status":"publish","type":"post","link":"http:\/\/teaching.thesystemis.com\/setpixel11\/blog\/?p=40","title":{"rendered":"Homework 5"},"content":{"rendered":"<p>a) implement these kernel filters for an image programmatically:<br \/>\n(multiply all 9 pixels by these values, add them up. divide by weight. set value of [me] pixel)<br \/>\nalso important: make sure the value you&#8217;re setting [me] pixel to is between 0 and 255, if it isn&#8217;t adjust it.\u00a0one easy way to do this is value = ofClamp(value, 0, 255);<\/p>\n<pre>sharpen: \t \r\n-1,-1,-1,\r\n-1,9,-1,\r\n-1,-1,-1 \r\nweight 1<\/pre>\n<pre>gaussian: \t \r\n1,2,1,\r\n2,4,2,\r\n1,2,1\r\nweight: 16<\/pre>\n<pre>prewitt (edge): \t \r\n1,1,1\r\n0,0,0\r\n-1,-1,-1\r\nweight 0<\/pre>\n<p>b) median filtering<\/p>\n<p>Given the pixel + neighbors routine do the following:<\/p>\n<p>for every pixel in an image, put it and it\u2019s 8 neighbors in a temporary array of 9 elements, that you sort with qsort. \u00a0then take the middle most element (the median) and use that as the new value<\/p>\n<p>try doing both gaussian blur (1,2,1 \/ 2,4,2 \/ 1,2,1 kernel) and median filtering on a noisy image, at least once but perhaps multiple times. \u00a0Which is better at fixing or removing points of noise?<\/p>\n<p>&nbsp;<\/p>\n<p>c) (advanced, optional,\u00a0this is for the hardcore folks!). \u00a0Try doing this both with squares and circles. \u00a0First threshold an image. \u00a0Then, find the largest square (or circle in the image). \u00a0It can be white or black. \u00a0Record it, then turn invert just those pixels and try to find the next larget box. \u00a0here\u2019s an input and result (via squares). \u00a0when you draw the outcome, you can draw it just a bit smaller then the actual found square so it\u2019s possible to see them.<\/p>\n<p>input image:<\/p>\n<p><a href=\"http:\/\/teaching.thesystemis.com\/setpixel11\/blog\/wp-content\/uploads\/2011\/09\/brucelee1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-42\" title=\"brucelee1\" src=\"http:\/\/teaching.thesystemis.com\/setpixel11\/blog\/wp-content\/uploads\/2011\/09\/brucelee1.jpg\" alt=\"\" width=\"300\" height=\"300\" srcset=\"http:\/\/teaching.thesystemis.com\/setpixel11\/blog\/wp-content\/uploads\/2011\/09\/brucelee1.jpg 300w, http:\/\/teaching.thesystemis.com\/setpixel11\/blog\/wp-content\/uploads\/2011\/09\/brucelee1-150x150.jpg 150w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>result after square finding:<br \/>\n<a href=\"http:\/\/teaching.thesystemis.com\/setpixel11\/blog\/wp-content\/uploads\/2011\/09\/brucelee_sq1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-43\" title=\"brucelee_sq1\" src=\"http:\/\/teaching.thesystemis.com\/setpixel11\/blog\/wp-content\/uploads\/2011\/09\/brucelee_sq1.jpg\" alt=\"\" width=\"300\" height=\"300\" srcset=\"http:\/\/teaching.thesystemis.com\/setpixel11\/blog\/wp-content\/uploads\/2011\/09\/brucelee_sq1.jpg 300w, http:\/\/teaching.thesystemis.com\/setpixel11\/blog\/wp-content\/uploads\/2011\/09\/brucelee_sq1-150x150.jpg 150w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>a) implement these kernel filters for an image programmatically: (multiply all 9 pixels by these values, add them up. divide by weight. set value of [me] pixel) also important: make sure the value you&#8217;re setting [me] pixel to is between 0 and 255, if it isn&#8217;t adjust it.\u00a0one easy way to do this is value &hellip;<\/p>\n<p><a href=\"http:\/\/teaching.thesystemis.com\/setpixel11\/blog\/?p=40\" class=\"more-link\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-40","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"http:\/\/teaching.thesystemis.com\/setpixel11\/blog\/index.php?rest_route=\/wp\/v2\/posts\/40","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/teaching.thesystemis.com\/setpixel11\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/teaching.thesystemis.com\/setpixel11\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/teaching.thesystemis.com\/setpixel11\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/teaching.thesystemis.com\/setpixel11\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=40"}],"version-history":[{"count":3,"href":"http:\/\/teaching.thesystemis.com\/setpixel11\/blog\/index.php?rest_route=\/wp\/v2\/posts\/40\/revisions"}],"predecessor-version":[{"id":45,"href":"http:\/\/teaching.thesystemis.com\/setpixel11\/blog\/index.php?rest_route=\/wp\/v2\/posts\/40\/revisions\/45"}],"wp:attachment":[{"href":"http:\/\/teaching.thesystemis.com\/setpixel11\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=40"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/teaching.thesystemis.com\/setpixel11\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=40"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/teaching.thesystemis.com\/setpixel11\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=40"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}