### Spatial and Mean Filtering of a 200 by 200 pixel image.

The images bellow are images that went through spatial, laplacian and sharpen, and mean, unweighted and weighted, filtering (the largest is the original image, the rest are mention from left to right and then top to bottom). This was done using openCV during the class hours of CMSC 165, with my partner Eliza Mae A. Saret. The workload of the activity was not distinctly divided, since both of us were concurrently working on the code.

The images above that are in greyscale were filtered through a means called kernel where a specified number of values are places in a matrix and then evaluated with intensity values of the greyscaled image. The greyscaled image can be called the source and the output after sliding the kernel throughout the src can be called the output. The kernel aims to process the middle most sell in comparison to the sides around it, which can be called the focal point of the kernel.

### SPATIAL FILTERING

The image to the upper left, among the 2 by 2 grid of greyscale images, was filtered using a laplacian filter, where the value of focal is computed like this:

Kernel basis:

0 1 0 1 -4 1 0 1 0

Applied matrix:

[n1*0] [n2] [n3*0] [n4] [n5*-4] [n6] [n7*0] [n8] [n9*0]

Using the formula of:

focal point = |((n1*0)+(n2)+(n3*0)+(n4)+(n5*-4)+(n6)+(n7*0)+(n8)+(n9*0))|

In spatial filtering there is no division or taking of the average sum of the interlaced coordinates to the kernel matrix, but rather the taking of the absolute value of the supposed sum. The absolute value is taken due to the sum not always being of positive value. The negative sum of spatial filtering shows the values to be quite far apart from the focal point, where in negative value it indicates that the focal point should achieve getting darker alike to the point around it. For a positive, sum it simply differentiates that is should have been lighter, alike to the points around it.

For the image found in the upper right of the greyscale grid, it was sharpen through:

Kernel basis:

0 -1 0 -1 5 -1 0 -1 0

Applied matrix:

[n1*0] [n2*-1] [n3*0] [n4*-1] [n5*5] [n6*-1] [n7*0] [n8*-1] [n9*0]

Using the formula of:

focal point = ((n1*0)+(n2*-1)+(n3*0)+(n4*-1)+(n5*5)+(n6*-1)+(n7*0)+(n8*-1)+(n9*0))

Sharpening an image aims to bring values further apart from each other.

### MEAN FILTERING

Mean filtering is done the same as spatial filtering just that the absolute values of the sum of values from the interlaced matrices are not taken but rather their average.

For unweighted mean filtering, which is found at the lower left corner, what was used was:

Kernel basis:

1 1 1 1 1 1 1 1 1

Applied matrix:

[n1] [n2] [n3] [n4] [n5] [n6] [n7] [n8] [n9]

Using the formula of:

focal point = (n1+n2+n3+n4+n5+n6+n7+n8+n9)/(sum of the kernel values, 9)

For weighted, which is found at the lower right corner, it only differentiates from the uniform distribution from the kernel values:

Kernel basis:

1 2 1 2 4 2 1 2 1

Applied matrix:

[n1] [n2*2] [n3] [n4*2] [n5*4] [n6*2] [n7] [n8*2] [n9]

Using the formula of:

focal point =(n1+(n2*2)+n3+(n4*2)+(n5*4)+(n6*2)+n7+(n8*2)+n9)/(sum of the kernel values, 16)