Skip to content

Commit

Permalink
Fix MedianBlur dropping single channels
Browse files Browse the repository at this point in the history
  • Loading branch information
aleju committed Oct 14, 2017
1 parent e945e93 commit 84c35a5
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion imgaug/augmenters/blur.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,12 @@ def _augment_images(self, images, random_state, parents, hooks):
ki = samples[i]
if ki > 1:
ki = ki + 1 if ki % 2 == 0 else ki
result[i] = cv2.medianBlur(result[i], ki)
image_aug = cv2.medianBlur(result[i], ki)
# cv2.medianBlur() removes channel axis for single-channel
# images
if image_aug.ndim == 2:
image_aug = image_aug[..., np.newaxis]
result[i] = image_aug
return result

def _augment_keypoints(self, keypoints_on_images, random_state, parents, hooks):
Expand Down

0 comments on commit 84c35a5

Please sign in to comment.