Update gaussian_filter.py (#1548)

* Update gaussian_filter.py

Changed embedded for loops with product. This way range(dst_height) is called only once, instead of being called $dst_height.

* Update gaussian_filter.py

fixed missing width
This commit is contained in:
Fakher Mokadem 2019-11-20 06:36:32 +01:00 committed by Anup Kumar Panwar
parent 28c02a1f21
commit e8aa81297a

View File

@ -3,6 +3,7 @@ Implementation of gaussian filter algorithm
"""
from cv2 import imread, cvtColor, COLOR_BGR2GRAY, imshow, waitKey
from numpy import pi, mgrid, exp, square, zeros, ravel, dot, uint8
from itertools import product
def gen_gaussian_kernel(k_size, sigma):
@ -21,8 +22,7 @@ def gaussian_filter(image, k_size, sigma):
# im2col, turn the k_size*k_size pixels into a row and np.vstack all rows
image_array = zeros((dst_height * dst_width, k_size * k_size))
row = 0
for i in range(0, dst_height):
for j in range(0, dst_width):
for i, j in product(range(dst_height), range(dst_width)):
window = ravel(image[i : i + k_size, j : j + k_size])
image_array[row, :] = window
row += 1