{"id":301,"date":"2022-07-16T13:28:22","date_gmt":"2022-07-16T13:28:22","guid":{"rendered":"https:\/\/vishnusrinivas.com\/?page_id=301"},"modified":"2022-07-16T16:33:49","modified_gmt":"2022-07-16T16:33:49","slug":"simple-convolution-based-image-filters","status":"publish","type":"page","link":"https:\/\/vishnusrinivas.com\/?page_id=301","title":{"rendered":"Simple Convolution-Based Image Filters"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"640\" src=\"https:\/\/vishnusrinivas.com\/wp-content\/uploads\/2022\/07\/Screen-Shot-2022-07-16-at-8.17.35-AM-1024x640.png\" alt=\"\" class=\"wp-image-302\" srcset=\"https:\/\/vishnusrinivas.com\/wp-content\/uploads\/2022\/07\/Screen-Shot-2022-07-16-at-8.17.35-AM-1024x640.png 1024w, https:\/\/vishnusrinivas.com\/wp-content\/uploads\/2022\/07\/Screen-Shot-2022-07-16-at-8.17.35-AM-300x188.png 300w, https:\/\/vishnusrinivas.com\/wp-content\/uploads\/2022\/07\/Screen-Shot-2022-07-16-at-8.17.35-AM-768x480.png 768w, https:\/\/vishnusrinivas.com\/wp-content\/uploads\/2022\/07\/Screen-Shot-2022-07-16-at-8.17.35-AM-1536x960.png 1536w, https:\/\/vishnusrinivas.com\/wp-content\/uploads\/2022\/07\/Screen-Shot-2022-07-16-at-8.17.35-AM-2048x1280.png 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption>Section of original image on left, blurred on right<\/figcaption><\/figure>\n\n\n\n<h2 class=\"has-primary-color has-text-color\">Overview<\/h2>\n\n\n\n<p>I&#8217;ve been interested in signal and image processing for a while, so I thought it would be a fun and interesting project to try and implement some basic image processing features to learn about how they work.<\/p>\n\n\n\n<p>I followed along with <a href=\"https:\/\/www.youtube.com\/watch?v=0OHRJMNKhX0&amp;t=308s\">this video<\/a>, (which is part of an excellent series on image processing and computer vision), and implemented the convolution-based image filters both for black-and-white images as well as color images.<\/p>\n\n\n\n<p>It was a fun and insight-building look into the world of image processing, a topic that, along with graphics as a whole, I am looking forward to studying in depth.<\/p>\n\n\n\n<h2 class=\"has-primary-color has-text-color\">Box Blur<\/h2>\n\n\n\n<p>The simplest convolution filter to implement is box blur, which makes every pixel in the output an average of all of the pixels in a corresponding area of the input.<\/p>\n\n\n\n<p>The box blur kernel can be represented as a 3&#215;3 matrix with all values set to 1\/9<\/p>\n\n\n\n<div class=\"wp-block-media-text alignwide is-stacked-on-mobile\" style=\"grid-template-columns:82% auto\"><figure class=\"wp-block-media-text__media\"><img loading=\"lazy\" width=\"1024\" height=\"508\" src=\"https:\/\/vishnusrinivas.com\/wp-content\/uploads\/2022\/07\/Screen-Shot-2022-07-16-at-8.21.46-AM-1024x508.png\" alt=\"\" class=\"wp-image-303 size-full\" srcset=\"https:\/\/vishnusrinivas.com\/wp-content\/uploads\/2022\/07\/Screen-Shot-2022-07-16-at-8.21.46-AM-1024x508.png 1024w, https:\/\/vishnusrinivas.com\/wp-content\/uploads\/2022\/07\/Screen-Shot-2022-07-16-at-8.21.46-AM-300x149.png 300w, https:\/\/vishnusrinivas.com\/wp-content\/uploads\/2022\/07\/Screen-Shot-2022-07-16-at-8.21.46-AM-768x381.png 768w, https:\/\/vishnusrinivas.com\/wp-content\/uploads\/2022\/07\/Screen-Shot-2022-07-16-at-8.21.46-AM-1536x763.png 1536w, https:\/\/vishnusrinivas.com\/wp-content\/uploads\/2022\/07\/Screen-Shot-2022-07-16-at-8.21.46-AM-2048x1017.png 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><div class=\"wp-block-media-text__content\">\n<p>The image on the right has been box-blurred. This is visible in the less defined edges as opposed to the original<\/p>\n<\/div><\/div>\n\n\n\n<h2 class=\"has-primary-color has-text-color\">Sharpening<\/h2>\n\n\n\n<p>Sharpening is a slightly more complicated filter to implement, but it can still be done with a simple convolution<\/p>\n\n\n\n<p>The sharpening kernel seeks to increase the contrast between pixels, so it takes the form of the 3&#215;3 matrix {[0 -1 0] [-1 5 -1] [0 -1 0]}. This will negate the influence of nearby pixels while increasing the intensity of individual pixels.<\/p>\n\n\n\n<div class=\"wp-block-media-text alignwide is-stacked-on-mobile\" style=\"grid-template-columns:85% auto\"><figure class=\"wp-block-media-text__media\"><img loading=\"lazy\" width=\"1024\" height=\"509\" src=\"https:\/\/vishnusrinivas.com\/wp-content\/uploads\/2022\/07\/Screen-Shot-2022-07-16-at-8.27.06-AM-1024x509.png\" alt=\"\" class=\"wp-image-304 size-full\" srcset=\"https:\/\/vishnusrinivas.com\/wp-content\/uploads\/2022\/07\/Screen-Shot-2022-07-16-at-8.27.06-AM-1024x509.png 1024w, https:\/\/vishnusrinivas.com\/wp-content\/uploads\/2022\/07\/Screen-Shot-2022-07-16-at-8.27.06-AM-300x149.png 300w, https:\/\/vishnusrinivas.com\/wp-content\/uploads\/2022\/07\/Screen-Shot-2022-07-16-at-8.27.06-AM-768x382.png 768w, https:\/\/vishnusrinivas.com\/wp-content\/uploads\/2022\/07\/Screen-Shot-2022-07-16-at-8.27.06-AM-1536x763.png 1536w, https:\/\/vishnusrinivas.com\/wp-content\/uploads\/2022\/07\/Screen-Shot-2022-07-16-at-8.27.06-AM-2048x1018.png 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><div class=\"wp-block-media-text__content\">\n<p>The image on the left is the original, while the one on the right has been sharpened.<\/p>\n\n\n\n<p>It is a little hard to see the difference, but notice the slightly sharper edges and the introduction of noise at the edges<\/p>\n<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Overview I&#8217;ve been interested in signal and image processing for a while, so I thought it would be a fun and interesting project to try and implement some basic image processing features to learn about how they work. I followed along with this video, (which is part of an excellent series on image processing and [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"om_disable_all_campaigns":false,"ub_ctt_via":"","_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"featured_image_src":null,"_links":{"self":[{"href":"https:\/\/vishnusrinivas.com\/index.php?rest_route=\/wp\/v2\/pages\/301"}],"collection":[{"href":"https:\/\/vishnusrinivas.com\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/vishnusrinivas.com\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/vishnusrinivas.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vishnusrinivas.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=301"}],"version-history":[{"count":3,"href":"https:\/\/vishnusrinivas.com\/index.php?rest_route=\/wp\/v2\/pages\/301\/revisions"}],"predecessor-version":[{"id":352,"href":"https:\/\/vishnusrinivas.com\/index.php?rest_route=\/wp\/v2\/pages\/301\/revisions\/352"}],"wp:attachment":[{"href":"https:\/\/vishnusrinivas.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=301"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}