Reader small image

You're reading from  Raspberry Pi Computer Vision Programming. - Second Edition

Product typeBook
Published inJun 2020
Reading LevelBeginner
PublisherPackt
ISBN-139781800207219
Edition2nd Edition
Languages
Tools
Right arrow
Author (1)
Ashwin Pajankar
Ashwin Pajankar
author image
Ashwin Pajankar

Ashwin Pajankar is an author, a YouTuber, and an instructor. He graduated from the International Institute of Information Technology, Hyderabad, with an MTech in Computer Science and Engineering. He has been writing programs for over two and a half decades. He is proficient in Linux, Unix shell scripting, C, C++, Java, JavaScript, Python, PowerShell, Golang, HTML, and assembly language. He has worked on single-board computers such as Raspberry Pi and Banana Pro. He is also proficient with microcontroller boards such as Arduino and the BBC Micro:bit. He is currently self-employed and teaches on Udemy and YouTube. He also organizes programming boot camps for working professionals and software companies.
Read more about Ashwin Pajankar

Right arrow

Filtering and blurring with OpenCV

OpenCV also has many filtering and convolution functions. These filtering functions are cv2.filter2D(), cv2.boxFilter(), cv2.blur(), cv2.GaussianBlur(), cv2.medianBlur(), cv2.sepFilter2D(), and cv2.BilateralFilter(). In this section, we will explore all these functions in detail.

2D convolution filtering

The cv2.filter2D() function, just like the scipy.signal.convolve2d() function, convolves a kernel with an image, thus applying a linear filter to the image. The advantage of the cv2.filter2D() function is that we can apply it to data that has more than two dimensions. We can apply this to color images, too.

This function accepts the input image, the depth of the output image (-1 means the input and the output have the same depth), and a kernel for the convolution operation as arguments. The following code demonstrates the usage of this function:

import cv2
import numpy as np
from matplotlib import pyplot as plt
img = cv2.imread(&apos...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Raspberry Pi Computer Vision Programming. - Second Edition
Published in: Jun 2020Publisher: PacktISBN-13: 9781800207219

Author (1)

author image
Ashwin Pajankar

Ashwin Pajankar is an author, a YouTuber, and an instructor. He graduated from the International Institute of Information Technology, Hyderabad, with an MTech in Computer Science and Engineering. He has been writing programs for over two and a half decades. He is proficient in Linux, Unix shell scripting, C, C++, Java, JavaScript, Python, PowerShell, Golang, HTML, and assembly language. He has worked on single-board computers such as Raspberry Pi and Banana Pro. He is also proficient with microcontroller boards such as Arduino and the BBC Micro:bit. He is currently self-employed and teaches on Udemy and YouTube. He also organizes programming boot camps for working professionals and software companies.
Read more about Ashwin Pajankar