pythonopencvimage-processinggaussiangaussianblur# How do I get to show Gaussian Kernel for 2d? (opencv)

I am using this:

```
blur = cv2.GaussianBlur(dst,(5,5),0)
```

And I wanted to show the kernel matrix by this:

```
print(cv2.getGaussianKernel(ksize=(5,5),sigma=0))
```

But I am getting a type error:

```
TypeError: an integer is required (got type tuple)
```

If I only put 5, I get a 5x1 matrix. Isn't the blur kernel 5x5? Or am I missing on something fundamental?

Solution

The Gaussian kernel is separable. Therefore, the kernel generated is 1D. The `GaussianBlur`

function applies this 1D kernel along each image dimension in turn. The separability property means that this process yields exactly the same result as applying a 2D convolution (or 3D in case of a 3D image). But the amount of work is strongly reduced. For your 5x5 kernel, the 2D convolution does 25 multiplications and additions, the separable implementation does only 5+5=10. For larger kernels, the gains are increasingly significant.

To see the full 2D kernel, apply the `GaussianBlur`

function to an image that is all zeros and has a single pixel in the middle set to 1. This is the discrete equivalent to the Dirac delta function, which we can use to analyze linear time-invariant functions (==convolution filters).

- Python Jinja2 LaTeX Table
- Getting attributes of a class
- How can I print many significant figures in Python?
- How to allow list append() method to return the new list
- Calculate Last Friday of Month in Pandas
- Python type hint for Iterable[str] that isn't str
- How to iterate over a list in chunks
- How to exit the entire application from a Python thread?
- Running shell command and capturing the output
- How do I pass a variable by reference?
- Convert range(r) to list of strings of length 2 in python
- How can I get the start and end dates for each week?
- how to use send_message() in python-telegram-bot
- Python conditional replacement based on element type
- How can I count the number of items in an arbitrary iterable (such as a generator)?
- Find longest consecutive range of numbers in list
- Insert text in braces with asyncpg
- How does one put a link / url to the web-site's home page in Django?
- How to determine if a path is a subdirectory of another?
- Custom Keybindings for Ipython terminal
- FastAPI asynchronous background tasks blocks other requests?
- How to make sure that information from one file is duplicated into several text documents, without specific lines
- Installing a Python environment with Anaconda
- sklearn pipeline model predicting same results for all input
- Brew command not found after installing Anaconda Python
- How to get an XPath from selenium webelement or from lxml?
- Pipe PuTTY console to Python script
- How to align the axes of a figure in matplotlib?
- Persist ParentDocumentRetriever of langchain
- How to reset index in a pandas dataframe?