Skip to content

Commit eb0b4f5

Browse files
authored
made suggested changes in dilation
1 parent 0913eb2 commit eb0b4f5

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

digital_image_processing/morphological_operations/dilation_operation.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ def rgb2gray(rgb: np.array) -> np.array:
1515
array([[159.0524, 90.0635, 117.6989]])
1616
"""
1717
r, g, b = rgb[:, :, 0], rgb[:, :, 1], rgb[:, :, 2]
18-
gray = 0.2989 * r + 0.5870 * g + 0.1140 * b
19-
return gray
18+
return 0.2989 * r + 0.5870 * g + 0.1140 * b
2019

2120

2221
def gray2binary(gray: np.array) -> np.array:
@@ -58,10 +57,7 @@ def dilation(image: np.array, kernel: np.array) -> np.array:
5857
summation = (
5958
kernel * image_padded[y : y + kernel.shape[0], x : x + kernel.shape[1]]
6059
).sum()
61-
if summation > 0:
62-
output[y, x] = 1
63-
else:
64-
output[y, x] = 0
60+
output[y, x] = int(summation > 0)
6561
return output
6662

6763

0 commit comments

Comments
 (0)