Blurring and Smoothing - OpenCV with Python for Image and Video Analysis 8

sentdex · Beginner ·🛠️ AI Tools & Apps ·10y ago
Skills: CV Basics90%

Key Takeaways

Covers blurring and smoothing techniques using OpenCV with Python for image and video analysis

Full Transcript

what's going on everybody welcome to another open CV with Python tutorial video where we left off we were filtering for a specific color you can imagine there's a lot of different filters that you might apply may not even be for a specific color where you apply the filter but you still have a lot of background noise and later on when we do like foreground extraction or background extraction the same thing happens you wind up still with a little bit of noise around just things are moving or whatever falsely detected and so on so you need to have some way to be able to remove noise so first we'll be talking about really simplistic ways like smoothing and blurring to get rid of noise and then we'll continue talking about in the subsequent tutorial how to even further get rid of noise in different types of noise so so anyways let's go ahead get started let me grab my head again and so right now we have the following we've got just the the regular frame the mask in the resolution we don't really or the result we don't need to we could probably keep masks just because it's easy to see the background stuff actually but we'll probably just keep doing the result instead and we'll stop displaying masks but anyway that's what we're dealing with so far so let's say you want to just apply like a really simple blur basically and that's you can basically do this with averaging the pixels so um I said we'd stop label set up a display masks because we got so many things for displaying feel free to like only display frame or only to spray the display the one thing we're working on like if you're having trouble with lag or something like that so to do averaging it's relatively simple we're going to make a kernel and the kernel will be numpy ones just a list of ones basically 15 by 15 datatype numpy float 32 and it's going to be so it's 15 by 15 and then we divide it by whatever this number times this number is in RK is 15 times 15 - 25 so that I make an average of 15 by 15 pixels okay you can go smaller you can say five by five and that would be 25 okay so that's your kernel and then we apply that kernel by saying smooth equals CV to filter 2d and then we're gonna say res negative one and calm so this will just apply like a simple average basically of our frame oh we need to display it almost made the same mistake as before okay so pay space good to go all right so we actually I mean with this we basically have no background noise but I see a few little specks back there but obviously it gets rid of a lot but we also lose a lot of clarity so it's kind of a bummer so we close this and we we assign and that's not really the best right and that's okay so now we're going to talk about another form and that will be a Gaussian blur so we'll just do it right underneath here and we're going to say blur blur blur is equal to CB - Gaussian blur we're going to apply it to that results this - will be a 15 by 15 in n0 and then we need to show it so let's copy that paste and blur and blur that and it even though it's like the same kind of size you should see this one's a lot clearer more clear than the other blur or average basically was so there's that option my favorite though for clarity is what's called this median blur so median will be equal to cv - median blur and we apply this to the results and it's a 15 of size so then we're going to call this paced medium meaning run that and at least here especially at a distance like if you backup and this thing is small like smaller on the frame you should notice that it almost like we can make it disappear and and I guess I mean that's just what's happening as opposed as you move it back it just doesn't want to show up I guess it's like falling out of the range that I specified probably but if we hold it like nice and close this one is the best as far as internal noise is concerned there's really no noise happening whereas there's a lot of noise happening over there and it's of course being returned in that blur but I happen to like this one the best just simply because it's the least noisy so anyway there's that and then finally there is a bilateral blur it's just another version of blurring so bilateral equals CV to bilateral filter apply to the res 15 then we'll choose a 75 by 75 and then see what call CB TM show down here just for the different versions of blurs okay so in my opinion the bilateral blur really is pretty much useless it got rid of a little bit of noise but not really so okay so anyways those are the various blurs that you have and I suppose a smooth that you have at your disposal but a lot of times that's just simply not going to be enough so in the next tutorial we're going to be talking about as morphological transformations and what that's going to allow us to do is is remove noise and a bit better of a method so anyway that's we're gonna be covering this tutorial if you have questions comments concerns or whatever up to this point feel free to let me know below otherwise as always thanks for watching thanks for all the support subscriptions in its seal next time

Original Description

In this OpenCV with Python tutorial, we're going to be covering how to try to eliminate noise from our filters, like simple thresholds or even a specific color filter like we had before. Text-based tutorial and sample code: https://pythonprogramming.net/blurring-smoothing-python-opencv-tutorial/ https://pythonprogramming.net https://twitter.com/sentdex https://www.facebook.com/pythonprogramming.net/ https://plus.google.com/+sentdex
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from sentdex · sentdex · 0 of 60

← Previous Next →
1 Matplotlib Python Tutorial Part 1: Basics and your first Graph!
Matplotlib Python Tutorial Part 1: Basics and your first Graph!
sentdex
2 Python Encryption Tutorial with PyCrypto
Python Encryption Tutorial with PyCrypto
sentdex
3 Python's Logging Function
Python's Logging Function
sentdex
4 wxPython Tutorials 1: Making Windows GUIs with Python : Installing + 1st window!
wxPython Tutorials 1: Making Windows GUIs with Python : Installing + 1st window!
sentdex
5 wxPython Tutorials 2: Making Windows GUIs with Python: Customizing Window Parameters
wxPython Tutorials 2: Making Windows GUIs with Python: Customizing Window Parameters
sentdex
6 wxPython Programming Tutorial 3: Menu Bar and Menu Button
wxPython Programming Tutorial 3: Menu Bar and Menu Button
sentdex
7 wxPython Programming Tutorial 4: Panels
wxPython Programming Tutorial 4: Panels
sentdex
8 wxPython Programming Tutorial 5: User Input Saved To Variables
wxPython Programming Tutorial 5: User Input Saved To Variables
sentdex
9 wxPython Programming Tutorial 6: Multiple Choice Input
wxPython Programming Tutorial 6: Multiple Choice Input
sentdex
10 wxPython Programming Tutorial 7: Adding Static Text and Colors
wxPython Programming Tutorial 7: Adding Static Text and Colors
sentdex
11 wxPython Programming Tutorial 8: Custom Button Images
wxPython Programming Tutorial 8: Custom Button Images
sentdex
12 wxPython Programming Tutorial 9: Tool Bar Items and Sub Menus!
wxPython Programming Tutorial 9: Tool Bar Items and Sub Menus!
sentdex
13 Basic PHP Tutorial 13: Multi-dimensional Array
Basic PHP Tutorial 13: Multi-dimensional Array
sentdex
14 Basic PHP Tutorial 15: Functions and Global Variables
Basic PHP Tutorial 15: Functions and Global Variables
sentdex
15 Basic PHP Tutorial 12: Associative Array
Basic PHP Tutorial 12: Associative Array
sentdex
16 Basic PHP Tutorial 14: Foreach loop
Basic PHP Tutorial 14: Foreach loop
sentdex
17 Basic PHP Tutorial 16: Include and Require
Basic PHP Tutorial 16: Include and Require
sentdex
18 Basic PHP Tutorial 7: Assignment, comparison and Logical operators
Basic PHP Tutorial 7: Assignment, comparison and Logical operators
sentdex
19 Basic PHP Tutorial 4: Variables and Comments
Basic PHP Tutorial 4: Variables and Comments
sentdex
20 Basic PHP Tutorial 11: Arrays part 1, basic array
Basic PHP Tutorial 11: Arrays part 1, basic array
sentdex
21 Basic PHP Tutorial 6: If else and else if conditionals cont'd
Basic PHP Tutorial 6: If else and else if conditionals cont'd
sentdex
22 Basic PHP Tutorial 1: Intro to PHP
Basic PHP Tutorial 1: Intro to PHP
sentdex
23 Basic PHP Tutorial 3: HTML with PHP
Basic PHP Tutorial 3: HTML with PHP
sentdex
24 Basic PHP Tutorial 9: While Loop
Basic PHP Tutorial 9: While Loop
sentdex
25 Basic PHP Tutorial 10: Switch Statement
Basic PHP Tutorial 10: Switch Statement
sentdex
26 Basic PHP Tutorial 2: Print and Echo
Basic PHP Tutorial 2: Print and Echo
sentdex
27 Basic PHP Tutorial 5: If else and else if conditional statements
Basic PHP Tutorial 5: If else and else if conditional statements
sentdex
28 Basic PHP Tutorial 8: Arithmatic Operators: Doing math with php
Basic PHP Tutorial 8: Arithmatic Operators: Doing math with php
sentdex
29 Basic PHP Tutorial 17: User Input Form Example / String Manipulation
Basic PHP Tutorial 17: User Input Form Example / String Manipulation
sentdex
30 Basic PHP Tutorial 18: HTML Entities and forms cont'd
Basic PHP Tutorial 18: HTML Entities and forms cont'd
sentdex
31 Basic PHP Tutorial 19: Finding words in strings
Basic PHP Tutorial 19: Finding words in strings
sentdex
32 Basic PHP Programming Tutorial 20: Saving to a File / writing and appending
Basic PHP Programming Tutorial 20: Saving to a File / writing and appending
sentdex
33 Basic PHP Programming Tutorial 22: Hashing part 2: salting
Basic PHP Programming Tutorial 22: Hashing part 2: salting
sentdex
34 Basic PHP Programming Tutorial 23: Variables in Strings and tokenizing
Basic PHP Programming Tutorial 23: Variables in Strings and tokenizing
sentdex
35 Basic PHP Programming Tutorial 21: MD5 Hashing For Security
Basic PHP Programming Tutorial 21: MD5 Hashing For Security
sentdex
36 Basic PHP Programming Tutorial 24: String similarity
Basic PHP Programming Tutorial 24: String similarity
sentdex
37 Basic PHP Programming Tutorial 25: Time and Time stamps
Basic PHP Programming Tutorial 25: Time and Time stamps
sentdex
38 Basic PHP Programming Tutorial 26: Die and Exit
Basic PHP Programming Tutorial 26: Die and Exit
sentdex
39 Basic PHP Programming Tutorial 27: MySQL Databases Part 1
Basic PHP Programming Tutorial 27: MySQL Databases Part 1
sentdex
40 Basic PHP Programming Tutorial 28: MySQL Database Part 2: Reading From Database
Basic PHP Programming Tutorial 28: MySQL Database Part 2: Reading From Database
sentdex
41 Basic PHP Programming Tutorial 29: MySQL Database Part 3: Inputting Data
Basic PHP Programming Tutorial 29: MySQL Database Part 3: Inputting Data
sentdex
42 Basic PHP Programming Tutorial 30: MySQL database in Use
Basic PHP Programming Tutorial 30: MySQL database in Use
sentdex
43 Django Tutorial Web Development with Python Part 1: Installing Django
Django Tutorial Web Development with Python Part 1: Installing Django
sentdex
44 Python Tutorial: File Deletion and Folder Deletion / directory deletion
Python Tutorial: File Deletion and Folder Deletion / directory deletion
sentdex
45 Python Tutorial: How to Rename Files and Move Files with Python
Python Tutorial: How to Rename Files and Move Files with Python
sentdex
46 3D Graphs in Matplotlib for Python: Basic 3D Line
3D Graphs in Matplotlib for Python: Basic 3D Line
sentdex
47 3D Plotting in Matplotlib for Python: 3D Scatter Plot
3D Plotting in Matplotlib for Python: 3D Scatter Plot
sentdex
48 3D Charts in Matplotlib for Python: Multiple datasets scatter plot
3D Charts in Matplotlib for Python: Multiple datasets scatter plot
sentdex
49 Sikuli Tutorial 1: Visually programming in python!
Sikuli Tutorial 1: Visually programming in python!
sentdex
50 Sikuli Tutorial 2: Program visually in python!
Sikuli Tutorial 2: Program visually in python!
sentdex
51 Sikuli Tutorial 3: Program visually in python!
Sikuli Tutorial 3: Program visually in python!
sentdex
52 3D Bar Charts in Python and Matplotlib
3D Bar Charts in Python and Matplotlib
sentdex
53 3D Plane wire frame Graph Chart in Python
3D Plane wire frame Graph Chart in Python
sentdex
54 Raspberry Pi Part 1 Introduction
Raspberry Pi Part 1 Introduction
sentdex
55 Raspberry Pi Part 8: First Download and Update! (Firmware)
Raspberry Pi Part 8: First Download and Update! (Firmware)
sentdex
56 Raspberry Pi Part 10: How to set up a Linux Web Server on your Pi
Raspberry Pi Part 10: How to set up a Linux Web Server on your Pi
sentdex
57 Raspberry Pi Part 11: Remote Desktop
Raspberry Pi Part 11: Remote Desktop
sentdex
58 Twitter Analysis: How to rank a user's influence
Twitter Analysis: How to rank a user's influence
sentdex
59 GPIO Tutorial for Pi Part 2 - Programming the GPIO
GPIO Tutorial for Pi Part 2 - Programming the GPIO
sentdex
60 GPIO Tutorial for Raspberry Pi Part 1 - Setting up
GPIO Tutorial for Raspberry Pi Part 1 - Setting up
sentdex

Related Reads

📰
Beyond 11,000: Navigating the Unified MCP Server Catalog That's Reshaping AI Tooling
Learn to navigate the Unified MCP Server Catalog with over 11,000 tools, reshaping AI tooling and streamlining development workflows
Dev.to · Robert Pelloni
📰
Could AI Save the English Major?
Explore how AI can enhance the English major curriculum and improve student learning outcomes
Medium · AI
📰
Six AI Tools Advancing Mental Health Care Access
Discover six AI tools revolutionizing mental health care access, enabling remote screenings and personalized support
Dev.to AI
📰
Runway Can’t Win on ‘Best Model’ Anymore. So It Stopped Trying To.
Runway launches Media Router, a tool that automatically selects the best image, shifting focus from 'best model' to practical solutions
Medium · AI
Up next
Clicky AI Telugu 🔥 Control Your Computer with Voice | Best Free AI Tool 2026
Withmesravani_
Watch →