{"id":3440,"date":"2022-03-19T19:16:48","date_gmt":"2022-03-19T13:46:48","guid":{"rendered":"http:\/\/myprojectideas.com\/?p=3440"},"modified":"2025-11-01T11:57:40","modified_gmt":"2025-11-01T11:57:40","slug":"blur-an-image-using-opencv-library-in-python","status":"publish","type":"post","link":"https:\/\/rudelabs.ai\/blogs\/blur-an-image-using-opencv-library-in-python\/","title":{"rendered":"Blur An Image Using OpenCV Library In Python"},"content":{"rendered":"<h2><strong>Introduction of the Project<\/strong><\/h2>\n<p>OpenCV refers to Open source Computer Vision. It is a library that helps in performing various tasks related to image processing and computer vision tasks. So, today, we are going to implement one such project using its function to blur an image. So let\u2019s see this Python Program to blur an image using OpenCV Library.<\/p>\n<p>The images can be blurred with different techniques using the python OpenCV module, namely:<\/p>\n<p>1. The Averaging,<\/p>\n<p>2. The Gaussian Blurring,<\/p>\n<p>3. The Media Blurring and<\/p>\n<p>4. The Bilateral blurring.<\/p>\n<iframe loading=\"lazy\"  id=\"_ytid_18151\"  width=\"1080\" height=\"607\"  data-origwidth=\"1080\" data-origheight=\"607\" src=\"https:\/\/www.youtube.com\/embed\/dyEveq7Rx_M?enablejsapi=1&autoplay=0&cc_load_policy=0&cc_lang_pref=&iv_load_policy=1&loop=0&rel=1&fs=1&playsinline=0&autohide=2&theme=dark&color=red&controls=1&\" class=\"__youtube_prefs__  no-lazyload\" title=\"YouTube player\"  allow=\"fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen data-no-lazy=\"1\" data-skipgform_ajax_framebjll=\"\"><\/iframe>\n<p>&nbsp;<\/p>\n<h2><strong>Requirements<\/strong><\/h2>\n<p>1. <a href=\"https:\/\/www.python.org\/downloads\/release\/python-390\/\">Python 3.9 interpreter<\/a> and IDLE<\/p>\n<p>2. OpenCV library must be preinstalled on your PC<\/p>\n<p>3. HD image to test the code.<\/p>\n<h2><strong>Steps To Blur An Image Using OpenCV Library In Python<\/strong><\/h2>\n<p><strong>Step 1: <\/strong>Windows: Open Command Prompt and type<\/p>\n<p><strong>\u00a0<\/strong>macOS: Open Terminal and type<\/p>\n<p><strong><em>pip install opencv-python<\/em><\/strong><\/p>\n<p><strong>Step 2: <\/strong>Paste the below source code into your editor\/IDE.<\/p>\n<h2><strong>Source Code<\/strong><\/h2>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\"># Import computer vision module\r\n\r\nimport cv2\r\n\r\n\r\n\r\n\r\n# Load the original image\r\n\r\nimage = cv2.imread('videos\/hdimage.jpg')\r\n\r\n\r\n\r\n\r\n# Resize the image\r\n\r\nimg = cv2.resize(image, (500, 600))\r\n\r\n\r\n\r\n\r\n# To show original image\r\n\r\ncv2.imshow('Original Image', img)\r\n\r\n\r\n\r\n\r\n# To blur the image\r\n\r\nbimage = cv2.blur(image, (20, 20))\r\n\r\n\r\n\r\n\r\n# Resize the image\r\n\r\nimg = cv2.resize(bimage, (500, 600))\r\n\r\n\r\n\r\n\r\n# To display the blurred image\r\n\r\ncv2.imshow('Blurred Image', img)\r\n\r\n\r\n\r\n\r\n# To save the blurred image\r\n\r\ncv2.imwrite('videos\/blurredImage.jpg',bimage)\r\n\r\n\r\n\r\n\r\n# Waits for a pressed key\r\n\r\ncv2.waitKey(0)<\/pre>\n<h2><strong>Explanation Of The Code<\/strong><\/h2>\n<p>In the beginning, we imported the OpenCV module.<\/p>\n<p>1. At first, we are loading the original image from the file using imread() function.<\/p>\n<p>2. Then, we resize the image using resize function.<\/p>\n<p>3. Now, we have used imshow() function to show the image.<\/p>\n<p>4. Then, we use the blur function, which blurs an image using the normalised box filter.<\/p>\n<p>5. Again, we are resizing and displaying the burred image using resize and imshow() function.<\/p>\n<p>6. Now, to save the blurred image, we are using imwrite() function.<\/p>\n<p>7. In the end, we are using waitkey() function, which ensures the display of images till we press any key.<\/p>\n<h2><strong>Output<\/strong><\/h2>\n<p>After successfully running this code to Blur An Image Using OpenCV Library In Python, the original image and its blurred image are shown below.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-18430 size-full\" src=\"https:\/\/rudelabs.ai\/blogs\/wp-content\/uploads\/2022\/03\/Blur-An-Image-Using-OpenCV-Library-In-Python.webp\" alt=\"Blur An Image Using OpenCV Library In Python\" width=\"1003\" height=\"633\" \/><\/p>\n<h2><strong>Things to Remember\u00a0<\/strong><\/h2>\n<ul>\n<li>Install the OpenCV module prior to pasting the code.<\/li>\n<li>Write the name of the modules in lowercase only.<\/li>\n<li>Set the path of the image according to your image path.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This Python Program to blur an image using OpenCV Library allows you to successfully make an HD image blurred with a smaller piece of code.<\/p>\n","protected":false},"author":1,"featured_media":8364,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","footnotes":""},"categories":[7,5],"tags":[18,14,21,22],"class_list":["post-3440","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-coding-projects","category-python","tag-computer-science","tag-how-to","tag-opencv","tag-python"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.1.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Blur An Image Using OpenCV Library In Python - RUDE LABS<\/title>\n<meta name=\"description\" content=\"This Python Program to blur an image using OpenCV Library allows you to successfully make an HD image blurred with a smaller piece of code\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/rudelabs.ai\/blogs\/blur-an-image-using-opencv-library-in-python\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Blur An Image Using OpenCV Library In Python - RUDE LABS\" \/>\n<meta property=\"og:description\" content=\"This Python Program to blur an image using OpenCV Library allows you to successfully make an HD image blurred with a smaller piece of code\" \/>\n<meta property=\"og:url\" content=\"https:\/\/rudelabs.ai\/blogs\/blur-an-image-using-opencv-library-in-python\/\" \/>\n<meta property=\"og:site_name\" content=\"RUDE LABS\" \/>\n<meta property=\"article:published_time\" content=\"2022-03-19T13:46:48+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-11-01T11:57:40+00:00\" \/>\n<meta name=\"author\" content=\"rudelabs.ai\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@rudelabs_in\" \/>\n<meta name=\"twitter:site\" content=\"@rudelabs_in\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"rudelabs.ai\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/rudelabs.ai\/blogs\/blur-an-image-using-opencv-library-in-python\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/rudelabs.ai\/blogs\/blur-an-image-using-opencv-library-in-python\/\"},\"author\":{\"name\":\"rudelabs.ai\",\"@id\":\"https:\/\/rudelabs.ai\/blogs\/#\/schema\/person\/560bad88bae03cae99a326a46af0c894\"},\"headline\":\"Blur An Image Using OpenCV Library In Python\",\"datePublished\":\"2022-03-19T13:46:48+00:00\",\"dateModified\":\"2025-11-01T11:57:40+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/rudelabs.ai\/blogs\/blur-an-image-using-opencv-library-in-python\/\"},\"wordCount\":323,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/rudelabs.ai\/blogs\/#organization\"},\"image\":{\"@id\":\"https:\/\/rudelabs.ai\/blogs\/blur-an-image-using-opencv-library-in-python\/#primaryimage\"},\"thumbnailUrl\":\"\",\"keywords\":[\"computer science\",\"how to\",\"OpenCV\",\"Python\"],\"articleSection\":[\"Coding Projects\",\"Python\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/rudelabs.ai\/blogs\/blur-an-image-using-opencv-library-in-python\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/rudelabs.ai\/blogs\/blur-an-image-using-opencv-library-in-python\/\",\"url\":\"https:\/\/rudelabs.ai\/blogs\/blur-an-image-using-opencv-library-in-python\/\",\"name\":\"Blur An Image Using OpenCV Library In Python - RUDE LABS\",\"isPartOf\":{\"@id\":\"https:\/\/rudelabs.ai\/blogs\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/rudelabs.ai\/blogs\/blur-an-image-using-opencv-library-in-python\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/rudelabs.ai\/blogs\/blur-an-image-using-opencv-library-in-python\/#primaryimage\"},\"thumbnailUrl\":\"\",\"datePublished\":\"2022-03-19T13:46:48+00:00\",\"dateModified\":\"2025-11-01T11:57:40+00:00\",\"description\":\"This Python Program to blur an image using OpenCV Library allows you to successfully make an HD image blurred with a smaller piece of code\",\"breadcrumb\":{\"@id\":\"https:\/\/rudelabs.ai\/blogs\/blur-an-image-using-opencv-library-in-python\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/rudelabs.ai\/blogs\/blur-an-image-using-opencv-library-in-python\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/rudelabs.ai\/blogs\/blur-an-image-using-opencv-library-in-python\/#primaryimage\",\"url\":\"\",\"contentUrl\":\"\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/rudelabs.ai\/blogs\/blur-an-image-using-opencv-library-in-python\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/rudelabs.ai\/blogs\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Blur An Image Using OpenCV Library In Python\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/rudelabs.ai\/blogs\/#website\",\"url\":\"https:\/\/rudelabs.ai\/blogs\/\",\"name\":\"RUDE LABS\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/rudelabs.ai\/blogs\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/rudelabs.ai\/blogs\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/rudelabs.ai\/blogs\/#organization\",\"name\":\"RUDE LABS\",\"url\":\"https:\/\/rudelabs.ai\/blogs\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/rudelabs.ai\/blogs\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/rudelabs.ai\/blogs\/wp-content\/uploads\/2025\/09\/RUDE-LABS.webp\",\"contentUrl\":\"https:\/\/rudelabs.ai\/blogs\/wp-content\/uploads\/2025\/09\/RUDE-LABS.webp\",\"width\":2459,\"height\":414,\"caption\":\"RUDE LABS\"},\"image\":{\"@id\":\"https:\/\/rudelabs.ai\/blogs\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/rudelabs_in\",\"https:\/\/www.linkedin.com\/company\/ru-delabs\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/rudelabs.ai\/blogs\/#\/schema\/person\/560bad88bae03cae99a326a46af0c894\",\"name\":\"rudelabs.ai\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/rudelabs.ai\/blogs\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/4d9f672e72f97294dfb6fac3d78e9f0bb5421a701cd2141cf2a2e540b4d67191?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/4d9f672e72f97294dfb6fac3d78e9f0bb5421a701cd2141cf2a2e540b4d67191?s=96&d=mm&r=g\",\"caption\":\"rudelabs.ai\"},\"sameAs\":[\"https:\/\/rudelabs.ai\/blogs\"],\"url\":\"https:\/\/rudelabs.ai\/blogs\/author\/rudelabs-ai\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Blur An Image Using OpenCV Library In Python - RUDE LABS","description":"This Python Program to blur an image using OpenCV Library allows you to successfully make an HD image blurred with a smaller piece of code","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/rudelabs.ai\/blogs\/blur-an-image-using-opencv-library-in-python\/","og_locale":"en_US","og_type":"article","og_title":"Blur An Image Using OpenCV Library In Python - RUDE LABS","og_description":"This Python Program to blur an image using OpenCV Library allows you to successfully make an HD image blurred with a smaller piece of code","og_url":"https:\/\/rudelabs.ai\/blogs\/blur-an-image-using-opencv-library-in-python\/","og_site_name":"RUDE LABS","article_published_time":"2022-03-19T13:46:48+00:00","article_modified_time":"2025-11-01T11:57:40+00:00","author":"rudelabs.ai","twitter_card":"summary_large_image","twitter_creator":"@rudelabs_in","twitter_site":"@rudelabs_in","twitter_misc":{"Written by":"rudelabs.ai","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/rudelabs.ai\/blogs\/blur-an-image-using-opencv-library-in-python\/#article","isPartOf":{"@id":"https:\/\/rudelabs.ai\/blogs\/blur-an-image-using-opencv-library-in-python\/"},"author":{"name":"rudelabs.ai","@id":"https:\/\/rudelabs.ai\/blogs\/#\/schema\/person\/560bad88bae03cae99a326a46af0c894"},"headline":"Blur An Image Using OpenCV Library In Python","datePublished":"2022-03-19T13:46:48+00:00","dateModified":"2025-11-01T11:57:40+00:00","mainEntityOfPage":{"@id":"https:\/\/rudelabs.ai\/blogs\/blur-an-image-using-opencv-library-in-python\/"},"wordCount":323,"commentCount":0,"publisher":{"@id":"https:\/\/rudelabs.ai\/blogs\/#organization"},"image":{"@id":"https:\/\/rudelabs.ai\/blogs\/blur-an-image-using-opencv-library-in-python\/#primaryimage"},"thumbnailUrl":"","keywords":["computer science","how to","OpenCV","Python"],"articleSection":["Coding Projects","Python"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/rudelabs.ai\/blogs\/blur-an-image-using-opencv-library-in-python\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/rudelabs.ai\/blogs\/blur-an-image-using-opencv-library-in-python\/","url":"https:\/\/rudelabs.ai\/blogs\/blur-an-image-using-opencv-library-in-python\/","name":"Blur An Image Using OpenCV Library In Python - RUDE LABS","isPartOf":{"@id":"https:\/\/rudelabs.ai\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/rudelabs.ai\/blogs\/blur-an-image-using-opencv-library-in-python\/#primaryimage"},"image":{"@id":"https:\/\/rudelabs.ai\/blogs\/blur-an-image-using-opencv-library-in-python\/#primaryimage"},"thumbnailUrl":"","datePublished":"2022-03-19T13:46:48+00:00","dateModified":"2025-11-01T11:57:40+00:00","description":"This Python Program to blur an image using OpenCV Library allows you to successfully make an HD image blurred with a smaller piece of code","breadcrumb":{"@id":"https:\/\/rudelabs.ai\/blogs\/blur-an-image-using-opencv-library-in-python\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/rudelabs.ai\/blogs\/blur-an-image-using-opencv-library-in-python\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/rudelabs.ai\/blogs\/blur-an-image-using-opencv-library-in-python\/#primaryimage","url":"","contentUrl":""},{"@type":"BreadcrumbList","@id":"https:\/\/rudelabs.ai\/blogs\/blur-an-image-using-opencv-library-in-python\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/rudelabs.ai\/blogs\/"},{"@type":"ListItem","position":2,"name":"Blur An Image Using OpenCV Library In Python"}]},{"@type":"WebSite","@id":"https:\/\/rudelabs.ai\/blogs\/#website","url":"https:\/\/rudelabs.ai\/blogs\/","name":"RUDE LABS","description":"","publisher":{"@id":"https:\/\/rudelabs.ai\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/rudelabs.ai\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/rudelabs.ai\/blogs\/#organization","name":"RUDE LABS","url":"https:\/\/rudelabs.ai\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/rudelabs.ai\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/rudelabs.ai\/blogs\/wp-content\/uploads\/2025\/09\/RUDE-LABS.webp","contentUrl":"https:\/\/rudelabs.ai\/blogs\/wp-content\/uploads\/2025\/09\/RUDE-LABS.webp","width":2459,"height":414,"caption":"RUDE LABS"},"image":{"@id":"https:\/\/rudelabs.ai\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/rudelabs_in","https:\/\/www.linkedin.com\/company\/ru-delabs\/"]},{"@type":"Person","@id":"https:\/\/rudelabs.ai\/blogs\/#\/schema\/person\/560bad88bae03cae99a326a46af0c894","name":"rudelabs.ai","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/rudelabs.ai\/blogs\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/4d9f672e72f97294dfb6fac3d78e9f0bb5421a701cd2141cf2a2e540b4d67191?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4d9f672e72f97294dfb6fac3d78e9f0bb5421a701cd2141cf2a2e540b4d67191?s=96&d=mm&r=g","caption":"rudelabs.ai"},"sameAs":["https:\/\/rudelabs.ai\/blogs"],"url":"https:\/\/rudelabs.ai\/blogs\/author\/rudelabs-ai\/"}]}},"_links":{"self":[{"href":"https:\/\/rudelabs.ai\/blogs\/wp-json\/wp\/v2\/posts\/3440","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/rudelabs.ai\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rudelabs.ai\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rudelabs.ai\/blogs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rudelabs.ai\/blogs\/wp-json\/wp\/v2\/comments?post=3440"}],"version-history":[{"count":1,"href":"https:\/\/rudelabs.ai\/blogs\/wp-json\/wp\/v2\/posts\/3440\/revisions"}],"predecessor-version":[{"id":18431,"href":"https:\/\/rudelabs.ai\/blogs\/wp-json\/wp\/v2\/posts\/3440\/revisions\/18431"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/rudelabs.ai\/blogs\/wp-json\/"}],"wp:attachment":[{"href":"https:\/\/rudelabs.ai\/blogs\/wp-json\/wp\/v2\/media?parent=3440"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rudelabs.ai\/blogs\/wp-json\/wp\/v2\/categories?post=3440"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rudelabs.ai\/blogs\/wp-json\/wp\/v2\/tags?post=3440"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}