# Basic Functions

## :pushpin: Making gray the picture

```python
import cv2

img = cv2.imread("Resources/Wally.jpg")

imgGray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

cv2.imshow("Gray Image", imgGray)
cv2.waitKey(0)
```

## :pushpin: Blur image

{% hint style="success" %}
ksize = kernelSize of matrix which is (7, 7) in our case.
{% endhint %}

{% hint style="success" %}
xSigma = 0, when you increase the value of xSigma you basically get more blur.
{% endhint %}

```
imgBlur = cv2.GaussianBlur(imgGray, (7,7), 0) #imgGray is the source picture
cv2.imshow("Blur Image", imgBlur)
```

## :pushpin: Canny Edge Detection

```
imgCanny = cv2.Canny(img,100,100)
```

## &#x20;:pushpin: Image Dialation

{% hint style="success" %}
We need a little bit matrix here, therefore, we're gonna import another package which is called numpy
{% endhint %}

```
import numpy as np
kernel = np.ones((5,5),np.uint8)
imgDialation = cv2.dilate(imgCanny, kernel, iterations=1)
cv2.imshow("Dialation Image", imgDialation)
```

## :pushpin: Opposite of Dialation = Eroded Image

```
kernel = np.ones((5,5), np.uint8)
imgEroded = cv2.erode(imgDialation, kernel, iterations=1)
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://capellac.gitbook.io/opencv/week1/opencv-basics/basic-functions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
