Skip to content

Commit e8aa812

Browse files
frifichAnupKumarPanwar
authored andcommitted
Update gaussian_filter.py (TheAlgorithms#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
1 parent 28c02a1 commit e8aa812

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

digital_image_processing/filters/gaussian_filter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"""
44
from cv2 import imread, cvtColor, COLOR_BGR2GRAY, imshow, waitKey
55
from numpy import pi, mgrid, exp, square, zeros, ravel, dot, uint8
6+
from itertools import product
67

78

89
def gen_gaussian_kernel(k_size, sigma):
@@ -21,8 +22,7 @@ def gaussian_filter(image, k_size, sigma):
2122
# im2col, turn the k_size*k_size pixels into a row and np.vstack all rows
2223
image_array = zeros((dst_height * dst_width, k_size * k_size))
2324
row = 0
24-
for i in range(0, dst_height):
25-
for j in range(0, dst_width):
25+
for i, j in product(range(dst_height), range(dst_width)):
2626
window = ravel(image[i : i + k_size, j : j + k_size])
2727
image_array[row, :] = window
2828
row += 1

0 commit comments

Comments
 (0)