- OpenCV 4 with Python Blueprints
- Dr. Menua Gevorgyan Arsen Mamikonyan Michael Beyeler
- 318字
- 2021-06-24 16:49:57
Implementing a Gaussian blur with two-dimensional convolution
A Gaussian blur is implemented by convolving the image with a kernel of Gaussian values. Two- dimensional convolution is something that is used very widely in image processing. Usually, we have a big picture (let's look at a 5 x 5 subsection of that particular image), and we have a kernel (or filter) that is another matrix of a smaller size (in our example, 3 x 3).
In order to get the convolution values, let's suppose that we want to get the value at location (2, 3). We place the kernel centered at the location (2, 3), and we calculate the pointwise product of the overlay matrix (highlighted area, in the following image (red color)) with the kernel and take the overall sum. The resulting value (that is, 158.4) is the value we write on the other matrix at the location (2, 3).
We repeat this process for all elements, and the resulting matrix (the matrix on the right) is the convolution of the kernel with the image. In the following diagram, on the left, you can see the original image with the pixel values in the boxes (values higher than 100). We also see an orange filter with values in the bottom right of each cell (a collection of 0.1 or 0.2 that sum to 1). In the matrix on the right, you see the values when the filter is applied to the image on the left:
Note that, for points on the boundaries, the kernel is not aligned with the matrix, so we have to figure out a strategy to give values for those points. There is no single good strategy that works for everything; some of the approaches are to either extend the border with zeros or extend with border values.
Let's take a look at how to transform a normal picture into a pencil sketch.
- .NET之美:.NET關(guān)鍵技術(shù)深入解析
- Building Modern Web Applications Using Angular
- Mastering Adobe Captivate 2017(Fourth Edition)
- Python從小白到大牛
- Learning ArcGIS Pro 2
- HoloLens Beginner's Guide
- Spring Boot+Spring Cloud+Vue+Element項(xiàng)目實(shí)戰(zhàn):手把手教你開發(fā)權(quán)限管理系統(tǒng)
- 教孩子學(xué)編程:C++入門圖解
- Visual Basic學(xué)習(xí)手冊(cè)
- Jupyter數(shù)據(jù)科學(xué)實(shí)戰(zhàn)
- Integrating Facebook iOS SDK with Your Application
- 搞定J2EE:Struts+Spring+Hibernate整合詳解與典型案例
- 運(yùn)維前線:一線運(yùn)維專家的運(yùn)維方法、技巧與實(shí)踐
- Django Design Patterns and Best Practices
- 大學(xué)計(jì)算機(jī)應(yīng)用基礎(chǔ)(Windows 7+Office 2010)(IC3)