Skip to content

Commit

Permalink
[FIX] add check for shape images in remove_outliers/PreproFilters
Browse files Browse the repository at this point in the history
  • Loading branch information
marta-seq committed Oct 8, 2024
1 parent b43dba0 commit 6bca058
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/ImagePreprocessFilters.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ def remove_outliers(img: np.array, up_limit=99, down_limit=1) -> np.array:
The function modifies the image in-place and saturates pixel values based on the specified
percentile limits per channel.
"""
# Check if the image has 3 dimensions (height, width, channels)
if len(img.shape) < 3:
# If not, add an extra dimension to make it a 3-channel image
img = np.expand_dims(img, axis=-1)

imOutlier = img
for i in range(img.shape[2]):
Expand Down

0 comments on commit 6bca058

Please sign in to comment.