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