mirror of https://github.com/2martens/uni.git
130 lines
2.9 KiB
Plaintext
130 lines
2.9 KiB
Plaintext
1.
|
|
------
|
|
| 1 |
|
|
-------------- ------
|
|
| 1 | -2 | 1 | + | -2 |
|
|
-------------- ------
|
|
| 1 |
|
|
------
|
|
|
|
The image has to be padded by 2 rows of zeros. The result of the correlation
|
|
follows:
|
|
|
|
-------------
|
|
| 0 | 1 | 0 |
|
|
-------------
|
|
| 1 |-4 | 1 |
|
|
-------------
|
|
| 0 | 1 | 0 |
|
|
-------------
|
|
|
|
The resulting filter is the Laplacian filter.
|
|
|
|
|
|
2.
|
|
|
|
The Prewitt edge detector for vertical edges follows:
|
|
|
|
-------------
|
|
|-1 | 0 | 1 |
|
|
-------------
|
|
|-1 | 0 | 1 |
|
|
-------------
|
|
|-1 | 0 | 1 |
|
|
-------------
|
|
|
|
The image of the exercise follows with 1 specifying white and 0 black.
|
|
|
|
-------------------------
|
|
| 0 | 0 | 0 | 1 | 1 | 1 |
|
|
-------------------------
|
|
| 0 | 0 | 0 | 1 | 1 | 1 |
|
|
-------------------------
|
|
| 0 | 0 | 0 | 1 | 1 | 1 |
|
|
-------------------------
|
|
| 0 | 0 | 0 | 1 | 1 | 1 |
|
|
-------------------------
|
|
| 0 | 0 | 0 | 1 | 1 | 1 |
|
|
-------------------------
|
|
| 0 | 0 | 0 | 1 | 1 | 1 |
|
|
-------------------------
|
|
|
|
The image has to be padded with 1 row and column of zeros to have a same size
|
|
result image. After that the convolution is applied. The padded image follows:
|
|
|
|
---------------------------------
|
|
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
|
|
---------------------------------
|
|
| 0 | 0 | 0 | 0 | 1 | 1 | 1 | 0 |
|
|
---------------------------------
|
|
| 0 | 0 | 0 | 0 | 1 | 1 | 1 | 0 |
|
|
---------------------------------
|
|
| 0 | 0 | 0 | 0 | 1 | 1 | 1 | 0 |
|
|
---------------------------------
|
|
| 0 | 0 | 0 | 0 | 1 | 1 | 1 | 0 |
|
|
---------------------------------
|
|
| 0 | 0 | 0 | 0 | 1 | 1 | 1 | 0 |
|
|
---------------------------------
|
|
| 0 | 0 | 0 | 0 | 1 | 1 | 1 | 0 |
|
|
---------------------------------
|
|
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
|
|
---------------------------------
|
|
|
|
The result of the convolution follows (without scalar product):
|
|
|
|
|
|
---------------------------
|
|
| 0 | 0 | -2 | -2 | 0 | 2 |
|
|
---------------------------
|
|
| 0 | 0 | -3 | -3 | 0 | 3 |
|
|
---------------------------
|
|
| 0 | 0 | -3 | -3 | 0 | 3 |
|
|
---------------------------
|
|
| 0 | 0 | -3 | -3 | 0 | 3 |
|
|
---------------------------
|
|
| 0 | 0 | -3 | -3 | 0 | 3 |
|
|
---------------------------
|
|
| 0 | 0 | -2 | -2 | 0 | 2 |
|
|
---------------------------
|
|
|
|
When the non zero values are replaced by ones, this is the result:
|
|
|
|
|
|
-------------------------
|
|
| 0 | 0 | 1 | 1 | 0 | 1 |
|
|
-------------------------
|
|
| 0 | 0 | 1 | 1 | 0 | 1 |
|
|
-------------------------
|
|
| 0 | 0 | 1 | 1 | 0 | 1 |
|
|
-------------------------
|
|
| 0 | 0 | 1 | 1 | 0 | 1 |
|
|
-------------------------
|
|
| 0 | 0 | 1 | 1 | 0 | 1 |
|
|
-------------------------
|
|
| 0 | 0 | 1 | 1 | 0 | 1 |
|
|
-------------------------
|
|
|
|
3.
|
|
|
|
-----
|
|
| 1 |
|
|
----- --------------
|
|
| 2 | * | -1 | 0 | 1 |
|
|
----- --------------
|
|
| 1 |
|
|
-----
|
|
|
|
To accurately process this convolution the image has to be padded by 2 columns
|
|
of zeros.
|
|
|
|
The result of the convolution follows:
|
|
--------------
|
|
| -1 | 0 | 1 |
|
|
--------------
|
|
| -2 | 0 | 2 |
|
|
--------------
|
|
| -1 | 0 | 1 |
|
|
--------------
|
|
|
|
This resulting filter is called Sobel edge detector for horizontal edges.
|