In [ ]:
import cv2
import numpy as np
import matplotlib.pyplot as plt
In [ ]:
image = cv2.imread('car.jpg',0)

# we create a simple blur filter or a mean filter
# all coefficients of this filter are the same and this
# filter is also normalized.

cv2.imshow('Original image',image)

processed_image = cv2.blur(image,(5,5))

cv2.imshow('Blur filter applied of size 5',processed_image)
In [ ]:
# Here we can create an image of all zeros.
# Only one pixel will be 1.
# In this example we will generate a very small image so that we can better
# visualize the filtering effect with such an image.

image_impulse = np.zeros((31,31),dtype='uint8')
image_impulse[16,16] = 255

cv2.imshow('Impulse image',image_impulse)
In [ ]:
image_impulse_processed1 = cv2.blur(image_impulse,(3,3))

cv2.imshow('Impulse image',image_impulse_processed1)

# This will produce a small square of size 3x3 in the center
# Notice that, since the filter is normalized, if we increase the size of the filter,
# the intesity values of the square in the ouput image will be more lower.
# Hence, more  challenging to be detected.

image_impulse_processed2 = cv2.blur(image_impulse,(7,7))

cv2.imshow('Impulse image',image_impulse_processed2)