{"id":590,"date":"2010-04-15T13:27:54","date_gmt":"2010-04-15T20:27:54","guid":{"rendered":"http:\/\/www.giassa.net\/?page_id=590"},"modified":"2025-08-24T08:03:52","modified_gmt":"2025-08-24T15:03:52","slug":"ii-special-masks-and-edge-detection","status":"publish","type":"page","link":"https:\/\/www.giassa.net\/?page_id=590","title":{"rendered":"II &#8211; Special Masks and Edge Detection"},"content":{"rendered":"<p>Now that we&#8217;ve covered the basic of convolution masks, I&#8217;d like to cover a few special ones that have interesting uses in image processing. We&#8217;ll assume for now that we are simply using 3&#215;3 spatial convolution masks. A highly recommended experiment is to not only test these masks yourself, but to try making larger masks (ie: 5&#215;5, 7&#215;7, etc) of the same type to see what effects it may have. I have included a reference image with the examples below so that you may compare the before\/after effects of these masks.<\/p>\n<ul>\n<li><strong>Blurring\/Averaging: <\/strong>\n<ul>\n<li>Mask: <img src='https:\/\/s0.wp.com\/latex.php?latex=%5Cleft%5B%5Cbegin%7Barray%7D%7Bccc%7D%5E1%2F_9%26%5E1%2F_9%26%5E1%2F_9%5C%5C+%5E1%2F_9%26%5E1%2F_9%26%5E1%2F_9%5C%5C+%5E1%2F_9%26%5E1%2F_9%26%5E1%2F_9%5Cend%7Barray%7D%5Cright%5D&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\\left[\\begin{array}{ccc}^1\/_9&amp;^1\/_9&amp;^1\/_9\\\\ ^1\/_9&amp;^1\/_9&amp;^1\/_9\\\\ ^1\/_9&amp;^1\/_9&amp;^1\/_9\\end{array}\\right]' title='\\left[\\begin{array}{ccc}^1\/_9&amp;^1\/_9&amp;^1\/_9\\\\ ^1\/_9&amp;^1\/_9&amp;^1\/_9\\\\ ^1\/_9&amp;^1\/_9&amp;^1\/_9\\end{array}\\right]' class='latex' \/><\/li>\n<li>Example: <a href=\"https:\/\/www.giassa.net\/wp-content\/uploads\/2010\/04\/mask1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-626\" title=\"mask1\" src=\"https:\/\/www.giassa.net\/wp-content\/uploads\/2010\/04\/mask1-300x264.png\" alt=\"\" width=\"300\" height=\"264\" srcset=\"https:\/\/www.giassa.net\/wp-content\/uploads\/2010\/04\/mask1-300x264.png 300w, https:\/\/www.giassa.net\/wp-content\/uploads\/2010\/04\/mask1.png 576w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/li>\n<li>Notes: If you increase the size of the mask, the denominator in each mask element should be the total number of &#8220;pixels&#8221; in the mask (ie: for a 5&#215;5 mask, each element should be <img src='https:\/\/s0.wp.com\/latex.php?latex=%5E1%2F_25&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='^1\/_25' title='^1\/_25' class='latex' \/>, as this prevents saturation of the output image)<\/li>\n<\/ul>\n<\/li>\n<li><strong>Motion Blurring (Diagonal): <\/strong>\n<ul>\n<li>Mask: <img src='https:\/\/s0.wp.com\/latex.php?latex=%5Cleft%5B%5Cbegin%7Barray%7D%7Bccc%7D0%260%261%5C%5C+0%260%260%5C%5C+1%260%260%5Cend%7Barray%7D%5Cright%5D&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\\left[\\begin{array}{ccc}0&amp;0&amp;1\\\\ 0&amp;0&amp;0\\\\ 1&amp;0&amp;0\\end{array}\\right]' title='\\left[\\begin{array}{ccc}0&amp;0&amp;1\\\\ 0&amp;0&amp;0\\\\ 1&amp;0&amp;0\\end{array}\\right]' class='latex' \/><\/li>\n<li>Example: <a href=\"https:\/\/www.giassa.net\/wp-content\/uploads\/2010\/04\/mask2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-627\" title=\"mask2\" src=\"https:\/\/www.giassa.net\/wp-content\/uploads\/2010\/04\/mask2-300x264.png\" alt=\"\" width=\"300\" height=\"264\" srcset=\"https:\/\/www.giassa.net\/wp-content\/uploads\/2010\/04\/mask2-300x264.png 300w, https:\/\/www.giassa.net\/wp-content\/uploads\/2010\/04\/mask2.png 576w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/li>\n<li>Notes: none<\/li>\n<\/ul>\n<\/li>\n<li><strong>Motion Blurring (Horizontal): <\/strong>\n<ul>\n<li>Mask: <img src='https:\/\/s0.wp.com\/latex.php?latex=%5Cleft%5B%5Cbegin%7Barray%7D%7Bccc%7D0%260%260%5C%5C+1%260%261%5C%5C+0%260%260%5Cend%7Barray%7D%5Cright%5D&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\\left[\\begin{array}{ccc}0&amp;0&amp;0\\\\ 1&amp;0&amp;1\\\\ 0&amp;0&amp;0\\end{array}\\right]' title='\\left[\\begin{array}{ccc}0&amp;0&amp;0\\\\ 1&amp;0&amp;1\\\\ 0&amp;0&amp;0\\end{array}\\right]' class='latex' \/><\/li>\n<li>Example: <a href=\"https:\/\/www.giassa.net\/wp-content\/uploads\/2010\/04\/mask3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-628\" title=\"mask3\" src=\"https:\/\/www.giassa.net\/wp-content\/uploads\/2010\/04\/mask3-300x264.png\" alt=\"\" width=\"300\" height=\"264\" srcset=\"https:\/\/www.giassa.net\/wp-content\/uploads\/2010\/04\/mask3-300x264.png 300w, https:\/\/www.giassa.net\/wp-content\/uploads\/2010\/04\/mask3.png 576w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/li>\n<li>Notes: A vertical blur can be achieved by simply &#8220;rotating&#8221; the mask matrix<\/li>\n<\/ul>\n<\/li>\n<li><strong>Edge Detection: <\/strong>\n<ul>\n<li>Mask: <img src='https:\/\/s0.wp.com\/latex.php?latex=%5Cleft%5B%5Cbegin%7Barray%7D%7Bccc%7D0%261%260%5C%5C+1%26-4%261%5C%5C+0%261%260%5Cend%7Barray%7D%5Cright%5D&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\\left[\\begin{array}{ccc}0&amp;1&amp;0\\\\ 1&amp;-4&amp;1\\\\ 0&amp;1&amp;0\\end{array}\\right]' title='\\left[\\begin{array}{ccc}0&amp;1&amp;0\\\\ 1&amp;-4&amp;1\\\\ 0&amp;1&amp;0\\end{array}\\right]' class='latex' \/><\/li>\n<li>Example: <a href=\"https:\/\/www.giassa.net\/wp-content\/uploads\/2010\/04\/mask4.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-629\" title=\"mask4\" src=\"https:\/\/www.giassa.net\/wp-content\/uploads\/2010\/04\/mask4-300x264.png\" alt=\"\" width=\"300\" height=\"264\" srcset=\"https:\/\/www.giassa.net\/wp-content\/uploads\/2010\/04\/mask4-300x264.png 300w, https:\/\/www.giassa.net\/wp-content\/uploads\/2010\/04\/mask4.png 576w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/li>\n<li>Notes: The <img src='https:\/\/s0.wp.com\/latex.php?latex=-4&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='-4' title='-4' class='latex' \/> in the centre can be replaced with a zero; There are many ways to accomplish edge detection, and this is just one of them.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Now that we&#8217;ve covered the basic of convolution masks, I&#8217;d like to cover a few special ones that have interesting uses in image processing. We&#8217;ll assume for now that we are simply using 3&#215;3 spatial convolution masks. A highly recommended &hellip; <a href=\"https:\/\/www.giassa.net\/?page_id=590\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":584,"menu_order":1,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-590","page","type-page","status-publish","hentry"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.giassa.net\/index.php?rest_route=\/wp\/v2\/pages\/590","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.giassa.net\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.giassa.net\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.giassa.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.giassa.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=590"}],"version-history":[{"count":10,"href":"https:\/\/www.giassa.net\/index.php?rest_route=\/wp\/v2\/pages\/590\/revisions"}],"predecessor-version":[{"id":830,"href":"https:\/\/www.giassa.net\/index.php?rest_route=\/wp\/v2\/pages\/590\/revisions\/830"}],"up":[{"embeddable":true,"href":"https:\/\/www.giassa.net\/index.php?rest_route=\/wp\/v2\/pages\/584"}],"wp:attachment":[{"href":"https:\/\/www.giassa.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=590"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}